1 #+Title: a collection of examples for Babel tests
4 * =:noweb= header argument expansion
6 :ID: eb1f6498-5bd9-45e0-9c56-50717053e7b7
10 #+begin_src emacs-lisp :results silent :exports code
14 #+name: noweb-example2
15 #+begin_src emacs-lisp :results silent
19 #+begin_src emacs-lisp :noweb yes :results silent
24 #+begin_src emacs-lisp :noweb no :results silent
29 #+begin_src emacs-lisp :noweb yes :results silent
34 #+begin_src emacs-lisp :noweb tangle :results silent
40 * =:noweb= header argument expansion using :exports results
42 :ID: 8701beb4-13d9-468c-997a-8e63e8b66f8d
46 #+begin_src emacs-lisp :exports results
50 #+name: noweb-example2
51 #+begin_src emacs-lisp :exports results
55 #+begin_src emacs-lisp :noweb yes :exports results
60 #+begin_src emacs-lisp :noweb no :exports code
65 #+begin_src emacs-lisp :noweb yes :exports results
70 #+begin_src emacs-lisp :noweb tangle :exports code
75 * excessive id links on tangling
77 :ID: ef06fd7f-012b-4fde-87a2-2ae91504ea7e
80 ** no, don't give me an ID
81 #+begin_src emacs-lisp :tangle no
82 (message "not to be tangled")
85 ** yes, I'd love an ID
87 :ID: ae7b55ca-9ef2-4d30-bd48-da30e35fd0f3
89 #+begin_src emacs-lisp :tangle no
90 (message "for tangling")
92 * simple named code block
94 :ID: 0d82b52d-1bb9-4916-816b-2c67c8108dbb
98 #+begin_src emacs-lisp
105 #+name: i-have-a-name
108 * Pascal's Triangle -- exports both test
110 :ID: 92518f2a-a46a-4205-a3ab-bcce1008a4bb
113 #+name: pascals-triangle
114 #+begin_src emacs-lisp :var n=5 :exports both
115 (defun pascals-triangle (n)
118 (let* ((prev-triangle (pascals-triangle (- n 1)))
119 (prev-row (car (reverse prev-triangle))))
120 (append prev-triangle
122 (append prev-row '(0))
123 (append '(0) prev-row)))))))
128 * calling code blocks from inside table
130 :ID: 6d2ff4ce-4489-4e2a-9c65-e3f71f77d975
134 #+begin_src emacs-lisp :var n=9
138 * executing an lob call line
141 :ID: fab7e291-fde6-45fc-bf6e-a485b8bca2f0
144 #+call: echo(input="testing")
145 #+call: echo(input="testing") :results vector
146 #+call: echo[:var input="testing"]()
147 #+call: echo[:var input="testing"]() :results vector
148 #+call: echo("testing")
149 #+call: echo("testing") :results vector
150 This is an inline call call_echo(input="testing") embedded in prose.
151 This is an inline call call_echo(input="testing")[:results vector] embedded in prose.
152 #+call: lob-minus(8, 4)
157 #+begin_src emacs-lisp :var a=0 :var b=0 :var c=0
158 (format "%S%S%S" a b c)
161 * exporting an lob call line
163 :ID: 72ddeed3-2d17-4c7f-8192-a575d535d3fc
167 #+begin_src emacs-lisp :var it=0
171 The following exports as a normal call line
174 Now here is an inline call call_double(it=1) stuck in the middle of
177 This one should not be exported =call_double(it=2)= because it is
180 Finally this next one should export, even though it starts a line
181 call_double(it=3) because sometimes inline blocks fold with a
184 And, a call with raw results call_double(4)[:results raw] should not
187 The following 2*5=call_double(5) should export even when prefixed by
190 * inline source block
193 :ID: 54cb8dc3-298c-4883-a933-029b3c9d4b18
195 Here is one in the middle src_sh{echo 1} of a line.
196 Here is one at the end of a line. src_sh{echo 2}
197 src_sh{echo 3} Here is one at the beginning of a line.
199 * mixed blocks with exports both
201 :ID: 5daa4d03-e3ea-46b7-b093-62c1b7632df3
209 #+begin_src emacs-lisp :exports both
213 #+begin_src emacs-lisp :var lst=a-list :results list :exports both
217 * using the =:noweb-ref= header argument
219 :ID: 54d68d4b-1544-4745-85ab-4f03b3cbd8a0
222 #+begin_src sh :tangle yes :noweb yes :shebang #!/bin/sh
226 ** query all mounted disks
227 #+begin_src sh :noweb-ref fullest-disk
231 ** strip the header row
232 #+begin_src sh :noweb-ref fullest-disk
236 ** sort by the percent full
237 #+begin_src sh :noweb-ref fullest-disk
238 |awk '{print $5 " " $6}'|sort -n |tail -1
241 ** extract the mount point
242 #+begin_src sh :noweb-ref fullest-disk
245 * resolving sub-trees as references
247 :ID: 2409e8ba-7b5f-4678-8888-e48aa02d8cb4
251 #+begin_src emacs-lisp :var text=d4faa7b3-072b-4dcf-813c-dd7141c633f3
255 #+begin_src org :noweb yes
257 <<d4faa7b3-072b-4dcf-813c-dd7141c633f3>>
260 ** simple subtree with custom ID
262 :CUSTOM_ID: simple-subtree
266 ** simple subtree with global ID
268 :ID: d4faa7b3-072b-4dcf-813c-dd7141c633f3
272 * org-babel-get-inline-src-block-matches
275 :ID: 0D0983D4-DE33-400A-8A05-A225A567BC74
277 src_sh{echo "One"} block at start of line
278 One spaced block in src_sh{ echo "middle" } of line
279 src_sh{echo 2} blocks on the src_emacs-lisp{"same"} line
280 Inline block with src_sh[:results silent]{ echo "parameters" }.
281 * exporting a code block with a name
283 :ID: b02ddd8a-eeb8-42ab-8664-8a759e6f43d9
286 exporting a code block with a name
288 #+begin_src sh :foo "baz"
291 * noweb no-export and exports both
293 :ID: 8a820f6c-7980-43db-8a24-0710d33729c9
299 #+name: noweb-no-export-and-exports-both-1
300 #+BEGIN_SRC sh :exports none
306 #+BEGIN_SRC sh :noweb no-export :exports both
307 # I am inside the code block
308 <<noweb-no-export-and-exports-both-1>>