在Orgmode中,有没有办法纠缠子树中匹配(或不匹配)特定标签的块?
例如,使用以下代码
* A
#+BEGIN_SRC c
printf("Not exported");
#+END_SRC
* B :D:
#+BEGIN_SRC c
printf("Exported");
#+END_SRC
Run Code Online (Sandbox Code Playgroud)
沿着标签D导出,纠缠C文件将只包含printf("Exported");
我org-mode用来组织我的emacs配置,我的目标是从主设备中获得不同的配置emacs-config.org.(例如通过仅标记特定的lightconfig)
我正在尝试将源块添加到可见性循环树中。本质上,我希望将源块视为其标题的子项。考虑以下组织模式文档:
* Heading 1
** Heading 2
#+BEGIN_SRC R
print("hello world")
#+END_SRC
** Heading 3
Run Code Online (Sandbox Code Playgroud)
我希望能够在标题一上按 TAB 来循环折叠各个部分,包括源块。目前 org-mode 似乎确实具有折叠源代码块的功能,因为如果我转到 #+BEGIN_SRC R 并点击选项卡,我可以折叠它,但它似乎没有在全局循环中得到处理。有什么建议可以添加吗?
谢谢!
使用组织模式,我想在导出代码块时导出黑色代码的名称。
例如,
#+NAME:code-segment-1
#+BEGIN_SRC javascript
var x = 5;
#+END_SRC
#+NAME:code-segment-2
#+BEGIN_SRC javascript
var y = 2;
#+END_SRC
#+NAME:assembly
#+BEGIN_SRC javascript :noweb yes :tangle "./assembly.js"
<<code-segment-1>>
<<code-segment-2>>
return x + y;
#+END_SRC
Run Code Online (Sandbox Code Playgroud)
我希望导出看起来像:
code-segment-1:
var x = 5;
code-segment-2:
var y = 2;
assembly:
var x = 5;
var y = 2;
return x + y;
Run Code Online (Sandbox Code Playgroud) 有什么方法可以启用#+RESULTS块中的字体粗细和颜色org-babel吗?
例如,使用ls选项--color调用会按照 shell 中的预期呈现字体粗细和颜色,但在#+RESULTS块内呈现时不会呈现:
#+BEGIN_SRC shell
ls --color ~/
#+END_SRC
#+RESULTS:
| Applications |
| Desktop |
| Documents |
| Downloads |
| Library |
...
Run Code Online (Sandbox Code Playgroud)
终端中lswith 和 without的屏幕截图--color
另一个例子是nodemodule chalk,它#+RESULTS以明文形式出现在块中:
#+BEGIN_SRC js
const chalk = require('chalk');
console.log(chalk.red('Hello world!'));
#+END_SRC
#+RESULTS:
: Hello world!
: undefined
Run Code Online (Sandbox Code Playgroud)
我正在尝试做这样的事情:
* Define some functions
#+begin_src python :noweb_ref defs
def f1(a,b,c):
return True
def f2(d,e,f):
return False
#+end_src
* Use them in a results-exported block later
#+begin_src python :results output :exports both :tangle yes
<<defs>>
print "test results:"
print f1(1,2,3)
#end_src
Run Code Online (Sandbox Code Playgroud)
我想要发生的是,当评估块以产生导出输出时,<< defs >>将被扩展为纠结样式.实际发生的是<< defs >>按字面意思进行评估并导致语法错误.
当这样的拼接块输出到输出文件时,一切都运行得很好,但是当我导出缓冲区时,我无法弄清楚如何做同样的事情.
建议?
emacs literate-programming org-mode org-babel reproducible-research
我的Babel库中有许多Org Babel代码块,我经常会依次调用它们。
是否可以制作一个Org Babel代码块来依次调用其他代码块?
组织8.2.10 Emacs 24.5.1 OSX 10.10.3
#+BEGIN_SRC R
1 + 2
#+END_SRC
#+RESULTS:
: 3
Run Code Online (Sandbox Code Playgroud)
但随着
#+BEGIN_SRC R
x <- rnorm(100)
summary(x)
#+END_SRC
#+RESULTS:
Run Code Online (Sandbox Code Playgroud)
"代码块没有产生输出",*Messages*缓冲区包含:
Error reading results: (beginning-of-buffer)
Code block produced no output.
Run Code Online (Sandbox Code Playgroud)
我不知道为什么我没有看到第二个例子的任何输出.它在我的机器上的R安装中运行find,
我会非常感谢任何帮助.
请考虑Common Lisp中的以下代码:
(defun range (max &key (min 0) (step 1))
(loop for n from min below max by step
collect n))
(reduce #'* (range 61 :min 1))
Run Code Online (Sandbox Code Playgroud)
这使得预期的bignum值为60 !,即
8320987112741390144276341183223364380754172606361245952449277696409600000000000000
Run Code Online (Sandbox Code Playgroud)
但是,以下代码(不包括我可以看到的任何浮点强制)产生浮点答案:
(defun fact (n)
(if (= 0 n)
1
(* n (fact (- n 1)))))
(fact 60)
8.32098711274139e+81
Run Code Online (Sandbox Code Playgroud)
问题是"为什么?" 并且"我如何fact在SBCL(Steel-Bank Common Lisp)中写出一个简单的递归,产生一个bignum结果?"
我正在尝试为此添加标题:
#+BEGIN_SRC sh :dir ~ :results table
for n in 1 2 3 4; do
echo $n $(($n * $n))
done
#+END_SRC
Run Code Online (Sandbox Code Playgroud)
结果是:
#+RESULTS:
| 1 | 1 |
| 2 | 4 |
| 3 | 9 |
| 4 | 16 |
Run Code Online (Sandbox Code Playgroud)
我想要的输出是:
#+RESULTS:
| N | N*N |
|---+-----|
| 1 | 1 |
| 2 | 4 |
| 3 | 9 |
| 4 | 16 |
Run Code Online (Sandbox Code Playgroud)
我遇到的困难是注入第二行。这不起作用:
#+BEGIN_SRC sh :dir ~ :results table
echo …Run Code Online (Sandbox Code Playgroud) 我已经从这个页面尝试了所有四个源代码块:https : //orgmode.org/worg/org-contrib/babel/languages/ob-doc-R.html
* does /not/ produce a file
#+begin_src R :file 1.png :results value graphics
library(lattice)
xyplot(1:10 ~ 1:10)
#+end_src
* does produce a file, by printing object
#+begin_src R :file 2.png :results value graphics
library(lattice)
print(xyplot(1:10 ~ 1:10))
#+end_src
* does produce a file, by using :results output
#+begin_src R :file 3.png :results output graphics
library(lattice)
xyplot(1:10 ~ 1:10)
#+end_src
* does produce a file, by evaluating in :session
#+begin_src R :file 4.png :session :results graphics
library(lattice) …Run Code Online (Sandbox Code Playgroud)