org-mode/testing/examples/babel.org

113 lines
1.9 KiB
Org Mode
Raw Normal View History

#+Title: a collection of examples for Babel tests
* =:noweb= header argument expansion
:PROPERTIES:
:ID: eb1f6498-5bd9-45e0-9c56-50717053e7b7
:END:
#+source: 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
#+results:
: 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:
#+source: four
#+begin_src emacs-lisp
(list 1 2 3 4)
#+end_src
#+begin_src emacs-lisp :var four=four
(length four)
#+end_src
#+results:
: 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
#+results:
| 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:
#+source: i-have-a-name
#+begin_src emacs-lisp
42
#+end_src
#+results:
: 42
#+results: i-have-a-name
: 42