emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
blob bb9cab9197e793c4c087360118b1e2aacf1bd4f6 6634 bytes (raw)
name: testing/examples/babel.org 	 # note: path name is non-authoritative(*)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
 
#+Title: a collection of examples for Babel tests
#+OPTIONS: ^:nil

* =:noweb= header argument expansion
  :PROPERTIES:
  :ID:       eb1f6498-5bd9-45e0-9c56-50717053e7b7
  :END:

#+name: noweb-example
#+begin_src emacs-lisp
  (message "expanded")
#+end_src

#+begin_src emacs-lisp :noweb yes
  ;; noweb-yes-start
  <<noweb-example>>
  ;; noweb-yes-end
#+end_src

#+begin_src emacs-lisp :noweb no
  ;; noweb-no-start
  <<noweb-example>>
  ;; noweb-no-end
#+end_src

#+begin_src emacs-lisp :noweb tangle
  ;; noweb-tangle-start
  <<noweb-example>>
  ;; noweb-tangle-end
#+end_src

* elisp forms in header arguments
  :PROPERTIES:
  :ID:       22d67284-bf14-4cdc-8319-f4bd876829d7
  :var:      prop=(+ 2 2)
  :END:

#+begin_src emacs-lisp
  prop
#+end_src

#+name:
: 4

* excessive id links on tangling
  :PROPERTIES:
  :ID:       ef06fd7f-012b-4fde-87a2-2ae91504ea7e
  :END:

** no, don't give me an ID
#+begin_src emacs-lisp :tangle no
  (message "not to be tangled")
#+end_src

** yes, I'd love an ID
   :PROPERTIES:
   :ID:       ae7b55ca-9ef2-4d30-bd48-da30e35fd0f3
   :END:
#+begin_src emacs-lisp :tangle no
  (message "for tangling")
#+end_src
* simple variable resolution
  :PROPERTIES:
  :ID:       f68821bc-7f49-4389-85b5-914791ee3718
  :END:

#+name: four
#+begin_src emacs-lisp
  (list 1 2 3 4)
#+end_src

#+begin_src emacs-lisp :var four=four
  (length four)
#+end_src

#+name:
: 4

* multi-line header arguments
  :PROPERTIES:
  :ID:       b77c8857-6c76-4ea9-8a61-ddc2648d96c4
  :END:

#+headers: :var letters='(a b c d e f g)
#+begin_src emacs-lisp :var numbers='(1 2 3 4 5 6 7)
  (map 'list #'list numbers letters)
#+end_src

#+name:
| 1 | a |
| 2 | b |
| 3 | c |
| 4 | d |
| 5 | e |
| 6 | f |
| 7 | g |

* simple named code block
  :PROPERTIES:
  :ID:       0d82b52d-1bb9-4916-816b-2c67c8108dbb
  :END:

#+name: i-have-a-name
#+begin_src emacs-lisp
  42
#+end_src

#+name:
: 42

#+name: i-have-a-name
: 42

* Pascal's Triangle -- export test
  :PROPERTIES:
  :ID:       92518f2a-a46a-4205-a3ab-bcce1008a4bb
  :END:

#+name: pascals-triangle
#+begin_src emacs-lisp :var n=5 :exports both
  (defun pascals-triangle (n)
    (if (= n 0)
        (list (list 1))
      (let* ((prev-triangle (pascals-triangle (- n 1)))
             (prev-row (car (reverse prev-triangle))))
        (append prev-triangle
                (list (map 'list #'+
                           (append prev-row '(0))
                           (append '(0) prev-row)))))))

  (pascals-triangle n)
#+end_src

* calling code blocks from inside table
  :PROPERTIES:
  :ID:       6d2ff4ce-4489-4e2a-9c65-e3f71f77d975
  :END:

#+name: take-sqrt
#+begin_src emacs-lisp :var n=9
  (sqrt n)
#+end_src

* executing an lob call line
  :PROPERTIES:
  :results:  silent
  :ID:       fab7e291-fde6-45fc-bf6e-a485b8bca2f0
  :END:

#+call: echo(input="testing")
#+call: echo(input="testing") :results vector
#+call: echo[:var input="testing"]()
#+call: echo[:var input="testing"]() :results vector
#+call: echo("testing")
#+call: echo("testing") :results vector
This is an inline call call_echo(input="testing") embedded in prose.
This is an inline call call_echo(input="testing")[:results vector] embedded in prose.
#+call: lob-minus(8, 4)
call_echo("testing")
call_concat(1,2,3)

#+name: concat
#+begin_src emacs-lisp :var a=0 :var b=0 :var c=0
  (format "%S%S%S" a b c)
#+end_src

* exporting an lob call line
  :PROPERTIES:
  :ID:       72ddeed3-2d17-4c7f-8192-a575d535d3fc
  :END:

#+name: double
#+begin_src emacs-lisp :var it=0
  (* 2 it)
#+end_src

The following exports as a normal call line
#+call: double(it=0)

Now here is an inline call call_double(it=1) stuck in the middle of
some prose.

This one should not be exported =call_double(it=2)= because it is
quoted.

Finally this next one should export, even though it starts a line
call_double(it=3) because sometimes inline blocks fold with a
paragraph.

And, a call with raw results call_double(4)[:results raw] should not
have quoted results.

The following 2*5=call_double(5) should export even when prefixed by
an = sign.

* inline source block
  :PROPERTIES:
  :results:  silent
  :ID:       54cb8dc3-298c-4883-a933-029b3c9d4b18
  :END:
Here is one in the middle src_sh{echo 1} of a line.
Here is one at the end of a line. src_sh{echo 2}
src_sh{echo 3} Here is one at the beginning of a line.

* parsing header arguments
  :PROPERTIES:
  :ID:       7eb0dc6e-1c53-4275-88b3-b22f3113b9c3
  :END:

#+begin_src example-lang :session     :results output :var num=9
  the body
#+end_src
* conflicting blocks on export
  :PROPERTIES:
  :ID:       5daa4d03-e3ea-46b7-b093-62c1b7632df3
  :END:
#+name: a-list
- a
- b
- c

#+begin_src emacs-lisp :results wrap :exports both
    "code block results"
#+end_src
#+begin_src emacs-lisp :var lst=a-list :results list
  (reverse lst)
#+end_src
* using the =:noweb-ref= header argument
  :PROPERTIES:
  :ID:       54d68d4b-1544-4745-85ab-4f03b3cbd8a0
  :END:

#+begin_src sh :tangle yes :noweb yes :shebang #!/bin/sh
  <<fullest-disk>>
#+end_src

** query all mounted disks
#+begin_src sh :noweb-ref fullest-disk
  df
#+end_src

** strip the header row
#+begin_src sh :noweb-ref fullest-disk
  |sed '1d'
#+end_src

** sort by the percent full
#+begin_src sh :noweb-ref fullest-disk
  |awk '{print $5 " " $6}'|sort -n |tail -1
#+end_src

** extract the mount point
#+begin_src sh :noweb-ref fullest-disk
  |awk '{print $2}'
#+end_src
* resolving sub-trees as references
  :PROPERTIES:
  :ID:       2409e8ba-7b5f-4678-8888-e48aa02d8cb4
  :results:  silent
  :END:

#+begin_src emacs-lisp :var text=d4faa7b3-072b-4dcf-813c-dd7141c633f3
  (length text)
#+end_src

#+begin_src org :noweb yes
  <<simple-subtree>>
  <<d4faa7b3-072b-4dcf-813c-dd7141c633f3>>
#+end_src

** simple subtree with custom ID
   :PROPERTIES:
   :CUSTOM_ID: simple-subtree
   :END:
this is simple

** simple subtree with global ID
   :PROPERTIES:
   :ID:       d4faa7b3-072b-4dcf-813c-dd7141c633f3
   :END:
has length 14

* org-babel-get-inline-src-block-matches
  :PROPERTIES:  
  :results:  silent
  :ID:       0D0983D4-DE33-400A-8A05-A225A567BC74
  :END:
src_sh{echo "One"} block at start of line
 One spaced block in  src_sh{ echo "middle" } of line 
src_sh{echo 2} blocks on the src_emacs-lisp{"same"} line
 Inline block with src_sh[:results silent]{ echo "parameters" }.
* returning file names -- interpreted as lists
  :PROPERTIES:
  :ID:       a73a2ab6-b8b2-4c0e-ae7f-23ad14eab7bc
  :END:

#+begin_src sh :results scalar
  echo "[[file:./cv.cls]]"
#+end_src

#+name:
: [[file:./cv.cls]]

#+begin_src sh :results raw scalar
   echo "[[file:./cv.cls]]"
#+end_src

#+name:
[[file:./cv.cls]]


debug log:

solving 45d0171 ...
found 45d0171 in https://list.orgmode.org/orgmode/87d3dhosn3.fsf@gmail.com/ ||
	https://list.orgmode.org/orgmode/87hb2totly.fsf@gmail.com/ ||
	https://list.orgmode.org/orgmode/87pqhhqcxr.fsf@gmail.com/
found 9c61b0c in https://git.savannah.gnu.org/cgit/emacs/org-mode.git
preparing index
index prepared:
100644 9c61b0c72e713c18b3aea54d116ff24b5dc1e81c	testing/examples/babel.org

applying [1/1] https://list.orgmode.org/orgmode/87d3dhosn3.fsf@gmail.com/
diff --git a/testing/examples/babel.org b/testing/examples/babel.org
index 9c61b0c..45d0171 100644

Checking patch testing/examples/babel.org...
Applied patch testing/examples/babel.org cleanly.

skipping https://list.orgmode.org/orgmode/87hb2totly.fsf@gmail.com/ for 45d0171
skipping https://list.orgmode.org/orgmode/87pqhhqcxr.fsf@gmail.com/ for 45d0171
index at:
100644 bb9cab9197e793c4c087360118b1e2aacf1bd4f6	testing/examples/babel.org

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).