2010-10-06 12:23:50 -04:00
|
|
|
#+Title: a collection of examples for Babel tests
|
2011-06-25 18:06:46 -04:00
|
|
|
#+OPTIONS: ^:nil
|
2010-10-06 12:23:50 -04:00
|
|
|
|
|
|
|
* =:noweb= header argument expansion
|
|
|
|
:PROPERTIES:
|
|
|
|
:ID: eb1f6498-5bd9-45e0-9c56-50717053e7b7
|
|
|
|
:END:
|
|
|
|
|
Standardized code block keywords
Nick Dokos <nicholas.dokos@hp.com> writes:
> Eric Schulte <schulte.eric@gmail.com> wrote:
>
>> The attached updated patch fixes a bug in the original.
>>
>
> Minor problem in applying:
>
> ,----
> | $ git apply ~/Mail/inbox/724
> | /home/nick/Mail/inbox/724:671: trailing whitespace.
> | #+name:
> | /home/nick/Mail/inbox/724:599: new blank line at EOF.
> | +
> | warning: 2 lines add whitespace errors.
> `----
The attached version fixes these issues, Thanks -- Eric
>From 0e43d59ee8d46a63f86780a502de726271bc39de Mon Sep 17 00:00:00 2001
From: Eric Schulte <schulte.eric@gmail.com>
Date: Fri, 28 Oct 2011 10:44:21 -0600
Subject: [PATCH] removing code block, results and call-line synonyms -- BREAKING CHANGE
Following a round of on-list discussion many code block synonyms have
been removed, moving forward the following syntax is valid.
- call lines are specified with #+call:
- code blocks are named with #+name:
- results are named with #+name:, however results generated by a code
block may still be labeled with #+results:, and tables named with
#+tblname: will be considered to be named results
The following function may be used to update an existing Org-mode
buffer to the new syntax.
(defun update-org-buffer ()
"Update an Org-mode buffer to the new data, code block and call line syntax."
(interactive)
(save-excursion
(flet ((to-re (lst) (concat "^[ \t]*#\\+" (regexp-opt lst t)
"\\(\\[\\([[:alnum:]]+\\)\\]\\)?\\:[ \t]*"))
(update (re new)
(goto-char (point-min))
(while (re-search-forward re nil t)
(replace-match new nil nil nil 1))))
(let ((old-re (to-re '("RESULTS" "DATA" "SRCNAME" "SOURCE")))
(lob-re (to-re '("LOB")))
(case-fold-search t))
(update old-re "name")
(update lob-re "call")))))
Note: If an old version of Org-mode (e.g., the one shipped with Emacs)
is installed on your system many of the important variables will
be pre-defined with a defvar and *will not* have their values
automatically updated, these include the following.
- org-babel-data-names
- org-babel-result-regexp
- org-babel-src-block-regexp
- org-babel-src-name-regexp
- org-babel-src-name-w-name-regexp
It may be necessary to either remove the source code of older
versions of Org-mode, or to explicitly evaluate the ob.el file.
* lisp/ob-exp.el (org-exp-res/src-name-cleanup): Updated
Documentation.
* lisp/ob-lob.el (org-babel-block-lob-one-liner-regexp): Updated
regular expression.
(org-babel-inline-lob-one-liner-regexp): Updated regular expression.
* lisp/ob-ref.el (org-babel-ref-resolve): Notice when something that
looks like a data results may actually be a code block.
* lisp/ob-table.el: Updated documentation.
* lisp/ob.el (org-babel-src-name-regexp): Simplified regexp.
(org-babel-get-src-block-info): Updated match strings.
(org-babel-data-names): Simplified acceptable names.
(org-babel-find-named-block): Indentation.
(org-babel-find-named-result): Updated to not return a code block as
a result.
* lisp/org.el (org-fontify-meta-lines-and-blocks-1): Removing
references to old syntactic elements.
(org-additional-option-like-keywords): Removing references to old
syntactic elements.
* contrib/babel/library-of-babel.org: Updated to make use of the new
syntax.
* testing/examples/babel-dangerous.org: Updated to make use of the new
syntax.
* testing/examples/babel.org: Updated to make use of the new syntax.
* testing/examples/ob-awk-test.org: Updated to make use of the new
syntax.
* testing/examples/ob-fortran-test.org: Updated to make use of the new
syntax.
* testing/lisp/test-ob.el: Removed two bad tests which tested the
literal values of old regular expressions rather than their
behavior.
2011-10-28 19:52:48 -04:00
|
|
|
#+name: noweb-example
|
2012-03-19 16:38:12 -04:00
|
|
|
#+begin_src emacs-lisp :results silent :exports code
|
|
|
|
(message "expanded1")
|
2010-10-06 12:23:50 -04:00
|
|
|
#+end_src
|
|
|
|
|
2012-03-19 16:38:12 -04:00
|
|
|
#+name: noweb-example2
|
|
|
|
#+begin_src emacs-lisp :results silent
|
|
|
|
(message "expanded2")
|
2012-01-05 10:49:16 -05:00
|
|
|
#+end_src
|
|
|
|
|
2012-03-19 16:38:12 -04:00
|
|
|
#+begin_src emacs-lisp :noweb yes :results silent
|
|
|
|
;; noweb-1-yes-start
|
2012-03-17 11:28:46 -04:00
|
|
|
<<noweb-example>>
|
2012-03-17 10:52:24 -04:00
|
|
|
#+end_src
|
|
|
|
|
2012-03-19 16:38:12 -04:00
|
|
|
#+begin_src emacs-lisp :noweb no :results silent
|
|
|
|
;; noweb-no-start
|
|
|
|
<<noweb-example1>>
|
|
|
|
#+end_src
|
|
|
|
|
|
|
|
#+begin_src emacs-lisp :noweb yes :results silent
|
|
|
|
;; noweb-2-yes-start
|
|
|
|
<<noweb-example2>>
|
|
|
|
#+end_src
|
|
|
|
|
|
|
|
#+begin_src emacs-lisp :noweb tangle :results silent
|
2010-10-06 12:23:50 -04:00
|
|
|
;; noweb-tangle-start
|
2012-03-19 16:38:12 -04:00
|
|
|
<<noweb-example1>>
|
|
|
|
<<noweb-example2>>
|
2012-01-05 10:49:16 -05:00
|
|
|
#+end_src
|
|
|
|
|
2012-03-19 16:38:12 -04:00
|
|
|
* =:noweb= header argument expansion using :exports results
|
2012-01-05 10:49:16 -05:00
|
|
|
:PROPERTIES:
|
2012-03-19 16:38:12 -04:00
|
|
|
:ID: 8701beb4-13d9-468c-997a-8e63e8b66f8d
|
2012-01-05 10:49:16 -05:00
|
|
|
:END:
|
|
|
|
|
2012-03-19 16:38:12 -04:00
|
|
|
#+name: noweb-example
|
|
|
|
#+begin_src emacs-lisp :exports results
|
|
|
|
(message "expanded1")
|
2012-03-17 10:52:24 -04:00
|
|
|
#+end_src
|
|
|
|
|
2012-03-19 16:38:12 -04:00
|
|
|
#+name: noweb-example2
|
|
|
|
#+begin_src emacs-lisp :exports results
|
|
|
|
(message "expanded2")
|
|
|
|
#+end_src
|
|
|
|
|
|
|
|
#+begin_src emacs-lisp :noweb yes :exports results
|
|
|
|
;; noweb-1-yes-start
|
|
|
|
<<noweb-example>>
|
|
|
|
#+end_src
|
|
|
|
|
|
|
|
#+begin_src emacs-lisp :noweb no :exports code
|
|
|
|
;; noweb-no-start
|
|
|
|
<<noweb-example1>>
|
|
|
|
#+end_src
|
|
|
|
|
|
|
|
#+begin_src emacs-lisp :noweb yes :exports results
|
|
|
|
;; noweb-2-yes-start
|
|
|
|
<<noweb-example2>>
|
|
|
|
#+end_src
|
|
|
|
|
|
|
|
#+begin_src emacs-lisp :noweb tangle :exports code
|
|
|
|
<<noweb-example1>>
|
|
|
|
<<noweb-example2>>
|
|
|
|
#+end_src
|
2010-10-14 09:32:21 -04:00
|
|
|
|
2010-10-14 19:15:11 -04:00
|
|
|
* 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
|
2010-10-15 17:46:20 -04:00
|
|
|
* simple named code block
|
|
|
|
:PROPERTIES:
|
|
|
|
:ID: 0d82b52d-1bb9-4916-816b-2c67c8108dbb
|
|
|
|
:END:
|
|
|
|
|
Standardized code block keywords
Nick Dokos <nicholas.dokos@hp.com> writes:
> Eric Schulte <schulte.eric@gmail.com> wrote:
>
>> The attached updated patch fixes a bug in the original.
>>
>
> Minor problem in applying:
>
> ,----
> | $ git apply ~/Mail/inbox/724
> | /home/nick/Mail/inbox/724:671: trailing whitespace.
> | #+name:
> | /home/nick/Mail/inbox/724:599: new blank line at EOF.
> | +
> | warning: 2 lines add whitespace errors.
> `----
The attached version fixes these issues, Thanks -- Eric
>From 0e43d59ee8d46a63f86780a502de726271bc39de Mon Sep 17 00:00:00 2001
From: Eric Schulte <schulte.eric@gmail.com>
Date: Fri, 28 Oct 2011 10:44:21 -0600
Subject: [PATCH] removing code block, results and call-line synonyms -- BREAKING CHANGE
Following a round of on-list discussion many code block synonyms have
been removed, moving forward the following syntax is valid.
- call lines are specified with #+call:
- code blocks are named with #+name:
- results are named with #+name:, however results generated by a code
block may still be labeled with #+results:, and tables named with
#+tblname: will be considered to be named results
The following function may be used to update an existing Org-mode
buffer to the new syntax.
(defun update-org-buffer ()
"Update an Org-mode buffer to the new data, code block and call line syntax."
(interactive)
(save-excursion
(flet ((to-re (lst) (concat "^[ \t]*#\\+" (regexp-opt lst t)
"\\(\\[\\([[:alnum:]]+\\)\\]\\)?\\:[ \t]*"))
(update (re new)
(goto-char (point-min))
(while (re-search-forward re nil t)
(replace-match new nil nil nil 1))))
(let ((old-re (to-re '("RESULTS" "DATA" "SRCNAME" "SOURCE")))
(lob-re (to-re '("LOB")))
(case-fold-search t))
(update old-re "name")
(update lob-re "call")))))
Note: If an old version of Org-mode (e.g., the one shipped with Emacs)
is installed on your system many of the important variables will
be pre-defined with a defvar and *will not* have their values
automatically updated, these include the following.
- org-babel-data-names
- org-babel-result-regexp
- org-babel-src-block-regexp
- org-babel-src-name-regexp
- org-babel-src-name-w-name-regexp
It may be necessary to either remove the source code of older
versions of Org-mode, or to explicitly evaluate the ob.el file.
* lisp/ob-exp.el (org-exp-res/src-name-cleanup): Updated
Documentation.
* lisp/ob-lob.el (org-babel-block-lob-one-liner-regexp): Updated
regular expression.
(org-babel-inline-lob-one-liner-regexp): Updated regular expression.
* lisp/ob-ref.el (org-babel-ref-resolve): Notice when something that
looks like a data results may actually be a code block.
* lisp/ob-table.el: Updated documentation.
* lisp/ob.el (org-babel-src-name-regexp): Simplified regexp.
(org-babel-get-src-block-info): Updated match strings.
(org-babel-data-names): Simplified acceptable names.
(org-babel-find-named-block): Indentation.
(org-babel-find-named-result): Updated to not return a code block as
a result.
* lisp/org.el (org-fontify-meta-lines-and-blocks-1): Removing
references to old syntactic elements.
(org-additional-option-like-keywords): Removing references to old
syntactic elements.
* contrib/babel/library-of-babel.org: Updated to make use of the new
syntax.
* testing/examples/babel-dangerous.org: Updated to make use of the new
syntax.
* testing/examples/babel.org: Updated to make use of the new syntax.
* testing/examples/ob-awk-test.org: Updated to make use of the new
syntax.
* testing/examples/ob-fortran-test.org: Updated to make use of the new
syntax.
* testing/lisp/test-ob.el: Removed two bad tests which tested the
literal values of old regular expressions rather than their
behavior.
2011-10-28 19:52:48 -04:00
|
|
|
#+name: i-have-a-name
|
2010-10-15 17:46:20 -04:00
|
|
|
#+begin_src emacs-lisp
|
|
|
|
42
|
|
|
|
#+end_src
|
|
|
|
|
Standardized code block keywords
Nick Dokos <nicholas.dokos@hp.com> writes:
> Eric Schulte <schulte.eric@gmail.com> wrote:
>
>> The attached updated patch fixes a bug in the original.
>>
>
> Minor problem in applying:
>
> ,----
> | $ git apply ~/Mail/inbox/724
> | /home/nick/Mail/inbox/724:671: trailing whitespace.
> | #+name:
> | /home/nick/Mail/inbox/724:599: new blank line at EOF.
> | +
> | warning: 2 lines add whitespace errors.
> `----
The attached version fixes these issues, Thanks -- Eric
>From 0e43d59ee8d46a63f86780a502de726271bc39de Mon Sep 17 00:00:00 2001
From: Eric Schulte <schulte.eric@gmail.com>
Date: Fri, 28 Oct 2011 10:44:21 -0600
Subject: [PATCH] removing code block, results and call-line synonyms -- BREAKING CHANGE
Following a round of on-list discussion many code block synonyms have
been removed, moving forward the following syntax is valid.
- call lines are specified with #+call:
- code blocks are named with #+name:
- results are named with #+name:, however results generated by a code
block may still be labeled with #+results:, and tables named with
#+tblname: will be considered to be named results
The following function may be used to update an existing Org-mode
buffer to the new syntax.
(defun update-org-buffer ()
"Update an Org-mode buffer to the new data, code block and call line syntax."
(interactive)
(save-excursion
(flet ((to-re (lst) (concat "^[ \t]*#\\+" (regexp-opt lst t)
"\\(\\[\\([[:alnum:]]+\\)\\]\\)?\\:[ \t]*"))
(update (re new)
(goto-char (point-min))
(while (re-search-forward re nil t)
(replace-match new nil nil nil 1))))
(let ((old-re (to-re '("RESULTS" "DATA" "SRCNAME" "SOURCE")))
(lob-re (to-re '("LOB")))
(case-fold-search t))
(update old-re "name")
(update lob-re "call")))))
Note: If an old version of Org-mode (e.g., the one shipped with Emacs)
is installed on your system many of the important variables will
be pre-defined with a defvar and *will not* have their values
automatically updated, these include the following.
- org-babel-data-names
- org-babel-result-regexp
- org-babel-src-block-regexp
- org-babel-src-name-regexp
- org-babel-src-name-w-name-regexp
It may be necessary to either remove the source code of older
versions of Org-mode, or to explicitly evaluate the ob.el file.
* lisp/ob-exp.el (org-exp-res/src-name-cleanup): Updated
Documentation.
* lisp/ob-lob.el (org-babel-block-lob-one-liner-regexp): Updated
regular expression.
(org-babel-inline-lob-one-liner-regexp): Updated regular expression.
* lisp/ob-ref.el (org-babel-ref-resolve): Notice when something that
looks like a data results may actually be a code block.
* lisp/ob-table.el: Updated documentation.
* lisp/ob.el (org-babel-src-name-regexp): Simplified regexp.
(org-babel-get-src-block-info): Updated match strings.
(org-babel-data-names): Simplified acceptable names.
(org-babel-find-named-block): Indentation.
(org-babel-find-named-result): Updated to not return a code block as
a result.
* lisp/org.el (org-fontify-meta-lines-and-blocks-1): Removing
references to old syntactic elements.
(org-additional-option-like-keywords): Removing references to old
syntactic elements.
* contrib/babel/library-of-babel.org: Updated to make use of the new
syntax.
* testing/examples/babel-dangerous.org: Updated to make use of the new
syntax.
* testing/examples/babel.org: Updated to make use of the new syntax.
* testing/examples/ob-awk-test.org: Updated to make use of the new
syntax.
* testing/examples/ob-fortran-test.org: Updated to make use of the new
syntax.
* testing/lisp/test-ob.el: Removed two bad tests which tested the
literal values of old regular expressions rather than their
behavior.
2011-10-28 19:52:48 -04:00
|
|
|
#+name:
|
2010-10-15 17:46:20 -04:00
|
|
|
: 42
|
|
|
|
|
Standardized code block keywords
Nick Dokos <nicholas.dokos@hp.com> writes:
> Eric Schulte <schulte.eric@gmail.com> wrote:
>
>> The attached updated patch fixes a bug in the original.
>>
>
> Minor problem in applying:
>
> ,----
> | $ git apply ~/Mail/inbox/724
> | /home/nick/Mail/inbox/724:671: trailing whitespace.
> | #+name:
> | /home/nick/Mail/inbox/724:599: new blank line at EOF.
> | +
> | warning: 2 lines add whitespace errors.
> `----
The attached version fixes these issues, Thanks -- Eric
>From 0e43d59ee8d46a63f86780a502de726271bc39de Mon Sep 17 00:00:00 2001
From: Eric Schulte <schulte.eric@gmail.com>
Date: Fri, 28 Oct 2011 10:44:21 -0600
Subject: [PATCH] removing code block, results and call-line synonyms -- BREAKING CHANGE
Following a round of on-list discussion many code block synonyms have
been removed, moving forward the following syntax is valid.
- call lines are specified with #+call:
- code blocks are named with #+name:
- results are named with #+name:, however results generated by a code
block may still be labeled with #+results:, and tables named with
#+tblname: will be considered to be named results
The following function may be used to update an existing Org-mode
buffer to the new syntax.
(defun update-org-buffer ()
"Update an Org-mode buffer to the new data, code block and call line syntax."
(interactive)
(save-excursion
(flet ((to-re (lst) (concat "^[ \t]*#\\+" (regexp-opt lst t)
"\\(\\[\\([[:alnum:]]+\\)\\]\\)?\\:[ \t]*"))
(update (re new)
(goto-char (point-min))
(while (re-search-forward re nil t)
(replace-match new nil nil nil 1))))
(let ((old-re (to-re '("RESULTS" "DATA" "SRCNAME" "SOURCE")))
(lob-re (to-re '("LOB")))
(case-fold-search t))
(update old-re "name")
(update lob-re "call")))))
Note: If an old version of Org-mode (e.g., the one shipped with Emacs)
is installed on your system many of the important variables will
be pre-defined with a defvar and *will not* have their values
automatically updated, these include the following.
- org-babel-data-names
- org-babel-result-regexp
- org-babel-src-block-regexp
- org-babel-src-name-regexp
- org-babel-src-name-w-name-regexp
It may be necessary to either remove the source code of older
versions of Org-mode, or to explicitly evaluate the ob.el file.
* lisp/ob-exp.el (org-exp-res/src-name-cleanup): Updated
Documentation.
* lisp/ob-lob.el (org-babel-block-lob-one-liner-regexp): Updated
regular expression.
(org-babel-inline-lob-one-liner-regexp): Updated regular expression.
* lisp/ob-ref.el (org-babel-ref-resolve): Notice when something that
looks like a data results may actually be a code block.
* lisp/ob-table.el: Updated documentation.
* lisp/ob.el (org-babel-src-name-regexp): Simplified regexp.
(org-babel-get-src-block-info): Updated match strings.
(org-babel-data-names): Simplified acceptable names.
(org-babel-find-named-block): Indentation.
(org-babel-find-named-result): Updated to not return a code block as
a result.
* lisp/org.el (org-fontify-meta-lines-and-blocks-1): Removing
references to old syntactic elements.
(org-additional-option-like-keywords): Removing references to old
syntactic elements.
* contrib/babel/library-of-babel.org: Updated to make use of the new
syntax.
* testing/examples/babel-dangerous.org: Updated to make use of the new
syntax.
* testing/examples/babel.org: Updated to make use of the new syntax.
* testing/examples/ob-awk-test.org: Updated to make use of the new
syntax.
* testing/examples/ob-fortran-test.org: Updated to make use of the new
syntax.
* testing/lisp/test-ob.el: Removed two bad tests which tested the
literal values of old regular expressions rather than their
behavior.
2011-10-28 19:52:48 -04:00
|
|
|
#+name: i-have-a-name
|
2010-10-15 17:46:20 -04:00
|
|
|
: 42
|
|
|
|
|
2012-03-19 16:38:12 -04:00
|
|
|
* Pascal's Triangle -- exports both test
|
2010-10-15 20:00:57 -04:00
|
|
|
:PROPERTIES:
|
|
|
|
:ID: 92518f2a-a46a-4205-a3ab-bcce1008a4bb
|
|
|
|
:END:
|
|
|
|
|
Standardized code block keywords
Nick Dokos <nicholas.dokos@hp.com> writes:
> Eric Schulte <schulte.eric@gmail.com> wrote:
>
>> The attached updated patch fixes a bug in the original.
>>
>
> Minor problem in applying:
>
> ,----
> | $ git apply ~/Mail/inbox/724
> | /home/nick/Mail/inbox/724:671: trailing whitespace.
> | #+name:
> | /home/nick/Mail/inbox/724:599: new blank line at EOF.
> | +
> | warning: 2 lines add whitespace errors.
> `----
The attached version fixes these issues, Thanks -- Eric
>From 0e43d59ee8d46a63f86780a502de726271bc39de Mon Sep 17 00:00:00 2001
From: Eric Schulte <schulte.eric@gmail.com>
Date: Fri, 28 Oct 2011 10:44:21 -0600
Subject: [PATCH] removing code block, results and call-line synonyms -- BREAKING CHANGE
Following a round of on-list discussion many code block synonyms have
been removed, moving forward the following syntax is valid.
- call lines are specified with #+call:
- code blocks are named with #+name:
- results are named with #+name:, however results generated by a code
block may still be labeled with #+results:, and tables named with
#+tblname: will be considered to be named results
The following function may be used to update an existing Org-mode
buffer to the new syntax.
(defun update-org-buffer ()
"Update an Org-mode buffer to the new data, code block and call line syntax."
(interactive)
(save-excursion
(flet ((to-re (lst) (concat "^[ \t]*#\\+" (regexp-opt lst t)
"\\(\\[\\([[:alnum:]]+\\)\\]\\)?\\:[ \t]*"))
(update (re new)
(goto-char (point-min))
(while (re-search-forward re nil t)
(replace-match new nil nil nil 1))))
(let ((old-re (to-re '("RESULTS" "DATA" "SRCNAME" "SOURCE")))
(lob-re (to-re '("LOB")))
(case-fold-search t))
(update old-re "name")
(update lob-re "call")))))
Note: If an old version of Org-mode (e.g., the one shipped with Emacs)
is installed on your system many of the important variables will
be pre-defined with a defvar and *will not* have their values
automatically updated, these include the following.
- org-babel-data-names
- org-babel-result-regexp
- org-babel-src-block-regexp
- org-babel-src-name-regexp
- org-babel-src-name-w-name-regexp
It may be necessary to either remove the source code of older
versions of Org-mode, or to explicitly evaluate the ob.el file.
* lisp/ob-exp.el (org-exp-res/src-name-cleanup): Updated
Documentation.
* lisp/ob-lob.el (org-babel-block-lob-one-liner-regexp): Updated
regular expression.
(org-babel-inline-lob-one-liner-regexp): Updated regular expression.
* lisp/ob-ref.el (org-babel-ref-resolve): Notice when something that
looks like a data results may actually be a code block.
* lisp/ob-table.el: Updated documentation.
* lisp/ob.el (org-babel-src-name-regexp): Simplified regexp.
(org-babel-get-src-block-info): Updated match strings.
(org-babel-data-names): Simplified acceptable names.
(org-babel-find-named-block): Indentation.
(org-babel-find-named-result): Updated to not return a code block as
a result.
* lisp/org.el (org-fontify-meta-lines-and-blocks-1): Removing
references to old syntactic elements.
(org-additional-option-like-keywords): Removing references to old
syntactic elements.
* contrib/babel/library-of-babel.org: Updated to make use of the new
syntax.
* testing/examples/babel-dangerous.org: Updated to make use of the new
syntax.
* testing/examples/babel.org: Updated to make use of the new syntax.
* testing/examples/ob-awk-test.org: Updated to make use of the new
syntax.
* testing/examples/ob-fortran-test.org: Updated to make use of the new
syntax.
* testing/lisp/test-ob.el: Removed two bad tests which tested the
literal values of old regular expressions rather than their
behavior.
2011-10-28 19:52:48 -04:00
|
|
|
#+name: pascals-triangle
|
2010-10-15 20:00:57 -04:00
|
|
|
#+begin_src emacs-lisp :var n=5 :exports both
|
2012-08-10 12:56:14 -04:00
|
|
|
(require 'cl)
|
2012-08-20 08:24:14 -04:00
|
|
|
(defalias 'my-map (if (org-version-check "24.2.50" "cl" :predicate)
|
2012-08-10 12:56:14 -04:00
|
|
|
'cl-map
|
|
|
|
'map))
|
2010-10-15 20:00:57 -04:00
|
|
|
(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
|
2012-08-10 12:56:14 -04:00
|
|
|
(list (my-map 'list #'+
|
|
|
|
(append prev-row '(0))
|
|
|
|
(append '(0) prev-row)))))))
|
|
|
|
|
2010-10-15 20:00:57 -04:00
|
|
|
(pascals-triangle n)
|
|
|
|
#+end_src
|
2010-10-16 15:55:54 -04:00
|
|
|
|
2010-10-16 00:43:45 -04:00
|
|
|
* calling code blocks from inside table
|
|
|
|
:PROPERTIES:
|
|
|
|
:ID: 6d2ff4ce-4489-4e2a-9c65-e3f71f77d975
|
|
|
|
:END:
|
|
|
|
|
Standardized code block keywords
Nick Dokos <nicholas.dokos@hp.com> writes:
> Eric Schulte <schulte.eric@gmail.com> wrote:
>
>> The attached updated patch fixes a bug in the original.
>>
>
> Minor problem in applying:
>
> ,----
> | $ git apply ~/Mail/inbox/724
> | /home/nick/Mail/inbox/724:671: trailing whitespace.
> | #+name:
> | /home/nick/Mail/inbox/724:599: new blank line at EOF.
> | +
> | warning: 2 lines add whitespace errors.
> `----
The attached version fixes these issues, Thanks -- Eric
>From 0e43d59ee8d46a63f86780a502de726271bc39de Mon Sep 17 00:00:00 2001
From: Eric Schulte <schulte.eric@gmail.com>
Date: Fri, 28 Oct 2011 10:44:21 -0600
Subject: [PATCH] removing code block, results and call-line synonyms -- BREAKING CHANGE
Following a round of on-list discussion many code block synonyms have
been removed, moving forward the following syntax is valid.
- call lines are specified with #+call:
- code blocks are named with #+name:
- results are named with #+name:, however results generated by a code
block may still be labeled with #+results:, and tables named with
#+tblname: will be considered to be named results
The following function may be used to update an existing Org-mode
buffer to the new syntax.
(defun update-org-buffer ()
"Update an Org-mode buffer to the new data, code block and call line syntax."
(interactive)
(save-excursion
(flet ((to-re (lst) (concat "^[ \t]*#\\+" (regexp-opt lst t)
"\\(\\[\\([[:alnum:]]+\\)\\]\\)?\\:[ \t]*"))
(update (re new)
(goto-char (point-min))
(while (re-search-forward re nil t)
(replace-match new nil nil nil 1))))
(let ((old-re (to-re '("RESULTS" "DATA" "SRCNAME" "SOURCE")))
(lob-re (to-re '("LOB")))
(case-fold-search t))
(update old-re "name")
(update lob-re "call")))))
Note: If an old version of Org-mode (e.g., the one shipped with Emacs)
is installed on your system many of the important variables will
be pre-defined with a defvar and *will not* have their values
automatically updated, these include the following.
- org-babel-data-names
- org-babel-result-regexp
- org-babel-src-block-regexp
- org-babel-src-name-regexp
- org-babel-src-name-w-name-regexp
It may be necessary to either remove the source code of older
versions of Org-mode, or to explicitly evaluate the ob.el file.
* lisp/ob-exp.el (org-exp-res/src-name-cleanup): Updated
Documentation.
* lisp/ob-lob.el (org-babel-block-lob-one-liner-regexp): Updated
regular expression.
(org-babel-inline-lob-one-liner-regexp): Updated regular expression.
* lisp/ob-ref.el (org-babel-ref-resolve): Notice when something that
looks like a data results may actually be a code block.
* lisp/ob-table.el: Updated documentation.
* lisp/ob.el (org-babel-src-name-regexp): Simplified regexp.
(org-babel-get-src-block-info): Updated match strings.
(org-babel-data-names): Simplified acceptable names.
(org-babel-find-named-block): Indentation.
(org-babel-find-named-result): Updated to not return a code block as
a result.
* lisp/org.el (org-fontify-meta-lines-and-blocks-1): Removing
references to old syntactic elements.
(org-additional-option-like-keywords): Removing references to old
syntactic elements.
* contrib/babel/library-of-babel.org: Updated to make use of the new
syntax.
* testing/examples/babel-dangerous.org: Updated to make use of the new
syntax.
* testing/examples/babel.org: Updated to make use of the new syntax.
* testing/examples/ob-awk-test.org: Updated to make use of the new
syntax.
* testing/examples/ob-fortran-test.org: Updated to make use of the new
syntax.
* testing/lisp/test-ob.el: Removed two bad tests which tested the
literal values of old regular expressions rather than their
behavior.
2011-10-28 19:52:48 -04:00
|
|
|
#+name: take-sqrt
|
2010-10-16 00:43:45 -04:00
|
|
|
#+begin_src emacs-lisp :var n=9
|
|
|
|
(sqrt n)
|
|
|
|
#+end_src
|
2010-10-16 15:55:54 -04:00
|
|
|
|
2010-10-16 12:02:57 -04:00
|
|
|
* executing an lob call line
|
|
|
|
:PROPERTIES:
|
|
|
|
:results: silent
|
2010-11-23 11:39:26 -05:00
|
|
|
:ID: fab7e291-fde6-45fc-bf6e-a485b8bca2f0
|
2010-10-16 12:02:57 -04:00
|
|
|
:END:
|
|
|
|
|
|
|
|
#+call: echo(input="testing")
|
|
|
|
#+call: echo(input="testing") :results vector
|
2010-11-08 16:26:47 -05:00
|
|
|
#+call: echo[:var input="testing"]()
|
|
|
|
#+call: echo[:var input="testing"]() :results vector
|
2011-06-25 17:41:13 -04:00
|
|
|
#+call: echo("testing")
|
|
|
|
#+call: echo("testing") :results vector
|
2011-06-25 18:06:46 -04:00
|
|
|
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.
|
2011-06-25 18:21:02 -04:00
|
|
|
#+call: lob-minus(8, 4)
|
2011-06-25 20:46:57 -04:00
|
|
|
call_echo("testing")
|
2011-06-28 13:21:12 -04:00
|
|
|
call_concat(1,2,3)
|
|
|
|
|
Standardized code block keywords
Nick Dokos <nicholas.dokos@hp.com> writes:
> Eric Schulte <schulte.eric@gmail.com> wrote:
>
>> The attached updated patch fixes a bug in the original.
>>
>
> Minor problem in applying:
>
> ,----
> | $ git apply ~/Mail/inbox/724
> | /home/nick/Mail/inbox/724:671: trailing whitespace.
> | #+name:
> | /home/nick/Mail/inbox/724:599: new blank line at EOF.
> | +
> | warning: 2 lines add whitespace errors.
> `----
The attached version fixes these issues, Thanks -- Eric
>From 0e43d59ee8d46a63f86780a502de726271bc39de Mon Sep 17 00:00:00 2001
From: Eric Schulte <schulte.eric@gmail.com>
Date: Fri, 28 Oct 2011 10:44:21 -0600
Subject: [PATCH] removing code block, results and call-line synonyms -- BREAKING CHANGE
Following a round of on-list discussion many code block synonyms have
been removed, moving forward the following syntax is valid.
- call lines are specified with #+call:
- code blocks are named with #+name:
- results are named with #+name:, however results generated by a code
block may still be labeled with #+results:, and tables named with
#+tblname: will be considered to be named results
The following function may be used to update an existing Org-mode
buffer to the new syntax.
(defun update-org-buffer ()
"Update an Org-mode buffer to the new data, code block and call line syntax."
(interactive)
(save-excursion
(flet ((to-re (lst) (concat "^[ \t]*#\\+" (regexp-opt lst t)
"\\(\\[\\([[:alnum:]]+\\)\\]\\)?\\:[ \t]*"))
(update (re new)
(goto-char (point-min))
(while (re-search-forward re nil t)
(replace-match new nil nil nil 1))))
(let ((old-re (to-re '("RESULTS" "DATA" "SRCNAME" "SOURCE")))
(lob-re (to-re '("LOB")))
(case-fold-search t))
(update old-re "name")
(update lob-re "call")))))
Note: If an old version of Org-mode (e.g., the one shipped with Emacs)
is installed on your system many of the important variables will
be pre-defined with a defvar and *will not* have their values
automatically updated, these include the following.
- org-babel-data-names
- org-babel-result-regexp
- org-babel-src-block-regexp
- org-babel-src-name-regexp
- org-babel-src-name-w-name-regexp
It may be necessary to either remove the source code of older
versions of Org-mode, or to explicitly evaluate the ob.el file.
* lisp/ob-exp.el (org-exp-res/src-name-cleanup): Updated
Documentation.
* lisp/ob-lob.el (org-babel-block-lob-one-liner-regexp): Updated
regular expression.
(org-babel-inline-lob-one-liner-regexp): Updated regular expression.
* lisp/ob-ref.el (org-babel-ref-resolve): Notice when something that
looks like a data results may actually be a code block.
* lisp/ob-table.el: Updated documentation.
* lisp/ob.el (org-babel-src-name-regexp): Simplified regexp.
(org-babel-get-src-block-info): Updated match strings.
(org-babel-data-names): Simplified acceptable names.
(org-babel-find-named-block): Indentation.
(org-babel-find-named-result): Updated to not return a code block as
a result.
* lisp/org.el (org-fontify-meta-lines-and-blocks-1): Removing
references to old syntactic elements.
(org-additional-option-like-keywords): Removing references to old
syntactic elements.
* contrib/babel/library-of-babel.org: Updated to make use of the new
syntax.
* testing/examples/babel-dangerous.org: Updated to make use of the new
syntax.
* testing/examples/babel.org: Updated to make use of the new syntax.
* testing/examples/ob-awk-test.org: Updated to make use of the new
syntax.
* testing/examples/ob-fortran-test.org: Updated to make use of the new
syntax.
* testing/lisp/test-ob.el: Removed two bad tests which tested the
literal values of old regular expressions rather than their
behavior.
2011-10-28 19:52:48 -04:00
|
|
|
#+name: concat
|
2011-06-28 13:21:12 -04:00
|
|
|
#+begin_src emacs-lisp :var a=0 :var b=0 :var c=0
|
|
|
|
(format "%S%S%S" a b c)
|
|
|
|
#+end_src
|
2010-11-23 11:39:26 -05:00
|
|
|
|
2011-06-27 14:34:00 -04:00
|
|
|
* exporting an lob call line
|
|
|
|
:PROPERTIES:
|
|
|
|
:ID: 72ddeed3-2d17-4c7f-8192-a575d535d3fc
|
|
|
|
:END:
|
|
|
|
|
Standardized code block keywords
Nick Dokos <nicholas.dokos@hp.com> writes:
> Eric Schulte <schulte.eric@gmail.com> wrote:
>
>> The attached updated patch fixes a bug in the original.
>>
>
> Minor problem in applying:
>
> ,----
> | $ git apply ~/Mail/inbox/724
> | /home/nick/Mail/inbox/724:671: trailing whitespace.
> | #+name:
> | /home/nick/Mail/inbox/724:599: new blank line at EOF.
> | +
> | warning: 2 lines add whitespace errors.
> `----
The attached version fixes these issues, Thanks -- Eric
>From 0e43d59ee8d46a63f86780a502de726271bc39de Mon Sep 17 00:00:00 2001
From: Eric Schulte <schulte.eric@gmail.com>
Date: Fri, 28 Oct 2011 10:44:21 -0600
Subject: [PATCH] removing code block, results and call-line synonyms -- BREAKING CHANGE
Following a round of on-list discussion many code block synonyms have
been removed, moving forward the following syntax is valid.
- call lines are specified with #+call:
- code blocks are named with #+name:
- results are named with #+name:, however results generated by a code
block may still be labeled with #+results:, and tables named with
#+tblname: will be considered to be named results
The following function may be used to update an existing Org-mode
buffer to the new syntax.
(defun update-org-buffer ()
"Update an Org-mode buffer to the new data, code block and call line syntax."
(interactive)
(save-excursion
(flet ((to-re (lst) (concat "^[ \t]*#\\+" (regexp-opt lst t)
"\\(\\[\\([[:alnum:]]+\\)\\]\\)?\\:[ \t]*"))
(update (re new)
(goto-char (point-min))
(while (re-search-forward re nil t)
(replace-match new nil nil nil 1))))
(let ((old-re (to-re '("RESULTS" "DATA" "SRCNAME" "SOURCE")))
(lob-re (to-re '("LOB")))
(case-fold-search t))
(update old-re "name")
(update lob-re "call")))))
Note: If an old version of Org-mode (e.g., the one shipped with Emacs)
is installed on your system many of the important variables will
be pre-defined with a defvar and *will not* have their values
automatically updated, these include the following.
- org-babel-data-names
- org-babel-result-regexp
- org-babel-src-block-regexp
- org-babel-src-name-regexp
- org-babel-src-name-w-name-regexp
It may be necessary to either remove the source code of older
versions of Org-mode, or to explicitly evaluate the ob.el file.
* lisp/ob-exp.el (org-exp-res/src-name-cleanup): Updated
Documentation.
* lisp/ob-lob.el (org-babel-block-lob-one-liner-regexp): Updated
regular expression.
(org-babel-inline-lob-one-liner-regexp): Updated regular expression.
* lisp/ob-ref.el (org-babel-ref-resolve): Notice when something that
looks like a data results may actually be a code block.
* lisp/ob-table.el: Updated documentation.
* lisp/ob.el (org-babel-src-name-regexp): Simplified regexp.
(org-babel-get-src-block-info): Updated match strings.
(org-babel-data-names): Simplified acceptable names.
(org-babel-find-named-block): Indentation.
(org-babel-find-named-result): Updated to not return a code block as
a result.
* lisp/org.el (org-fontify-meta-lines-and-blocks-1): Removing
references to old syntactic elements.
(org-additional-option-like-keywords): Removing references to old
syntactic elements.
* contrib/babel/library-of-babel.org: Updated to make use of the new
syntax.
* testing/examples/babel-dangerous.org: Updated to make use of the new
syntax.
* testing/examples/babel.org: Updated to make use of the new syntax.
* testing/examples/ob-awk-test.org: Updated to make use of the new
syntax.
* testing/examples/ob-fortran-test.org: Updated to make use of the new
syntax.
* testing/lisp/test-ob.el: Removed two bad tests which tested the
literal values of old regular expressions rather than their
behavior.
2011-10-28 19:52:48 -04:00
|
|
|
#+name: double
|
2011-06-27 14:34:00 -04:00
|
|
|
#+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.
|
|
|
|
|
2011-06-28 13:14:58 -04:00
|
|
|
The following 2*5=call_double(5) should export even when prefixed by
|
|
|
|
an = sign.
|
|
|
|
|
2011-08-29 18:13:46 -04:00
|
|
|
* 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.
|
|
|
|
|
2012-03-19 16:38:12 -04:00
|
|
|
* mixed blocks with exports both
|
2012-03-17 11:28:46 -04:00
|
|
|
:PROPERTIES:
|
|
|
|
:ID: 5daa4d03-e3ea-46b7-b093-62c1b7632df3
|
|
|
|
:END:
|
2012-03-19 16:38:12 -04:00
|
|
|
|
Standardized code block keywords
Nick Dokos <nicholas.dokos@hp.com> writes:
> Eric Schulte <schulte.eric@gmail.com> wrote:
>
>> The attached updated patch fixes a bug in the original.
>>
>
> Minor problem in applying:
>
> ,----
> | $ git apply ~/Mail/inbox/724
> | /home/nick/Mail/inbox/724:671: trailing whitespace.
> | #+name:
> | /home/nick/Mail/inbox/724:599: new blank line at EOF.
> | +
> | warning: 2 lines add whitespace errors.
> `----
The attached version fixes these issues, Thanks -- Eric
>From 0e43d59ee8d46a63f86780a502de726271bc39de Mon Sep 17 00:00:00 2001
From: Eric Schulte <schulte.eric@gmail.com>
Date: Fri, 28 Oct 2011 10:44:21 -0600
Subject: [PATCH] removing code block, results and call-line synonyms -- BREAKING CHANGE
Following a round of on-list discussion many code block synonyms have
been removed, moving forward the following syntax is valid.
- call lines are specified with #+call:
- code blocks are named with #+name:
- results are named with #+name:, however results generated by a code
block may still be labeled with #+results:, and tables named with
#+tblname: will be considered to be named results
The following function may be used to update an existing Org-mode
buffer to the new syntax.
(defun update-org-buffer ()
"Update an Org-mode buffer to the new data, code block and call line syntax."
(interactive)
(save-excursion
(flet ((to-re (lst) (concat "^[ \t]*#\\+" (regexp-opt lst t)
"\\(\\[\\([[:alnum:]]+\\)\\]\\)?\\:[ \t]*"))
(update (re new)
(goto-char (point-min))
(while (re-search-forward re nil t)
(replace-match new nil nil nil 1))))
(let ((old-re (to-re '("RESULTS" "DATA" "SRCNAME" "SOURCE")))
(lob-re (to-re '("LOB")))
(case-fold-search t))
(update old-re "name")
(update lob-re "call")))))
Note: If an old version of Org-mode (e.g., the one shipped with Emacs)
is installed on your system many of the important variables will
be pre-defined with a defvar and *will not* have their values
automatically updated, these include the following.
- org-babel-data-names
- org-babel-result-regexp
- org-babel-src-block-regexp
- org-babel-src-name-regexp
- org-babel-src-name-w-name-regexp
It may be necessary to either remove the source code of older
versions of Org-mode, or to explicitly evaluate the ob.el file.
* lisp/ob-exp.el (org-exp-res/src-name-cleanup): Updated
Documentation.
* lisp/ob-lob.el (org-babel-block-lob-one-liner-regexp): Updated
regular expression.
(org-babel-inline-lob-one-liner-regexp): Updated regular expression.
* lisp/ob-ref.el (org-babel-ref-resolve): Notice when something that
looks like a data results may actually be a code block.
* lisp/ob-table.el: Updated documentation.
* lisp/ob.el (org-babel-src-name-regexp): Simplified regexp.
(org-babel-get-src-block-info): Updated match strings.
(org-babel-data-names): Simplified acceptable names.
(org-babel-find-named-block): Indentation.
(org-babel-find-named-result): Updated to not return a code block as
a result.
* lisp/org.el (org-fontify-meta-lines-and-blocks-1): Removing
references to old syntactic elements.
(org-additional-option-like-keywords): Removing references to old
syntactic elements.
* contrib/babel/library-of-babel.org: Updated to make use of the new
syntax.
* testing/examples/babel-dangerous.org: Updated to make use of the new
syntax.
* testing/examples/babel.org: Updated to make use of the new syntax.
* testing/examples/ob-awk-test.org: Updated to make use of the new
syntax.
* testing/examples/ob-fortran-test.org: Updated to make use of the new
syntax.
* testing/lisp/test-ob.el: Removed two bad tests which tested the
literal values of old regular expressions rather than their
behavior.
2011-10-28 19:52:48 -04:00
|
|
|
#+name: a-list
|
2010-12-13 14:41:55 -05:00
|
|
|
- a
|
|
|
|
- b
|
|
|
|
- c
|
|
|
|
|
2012-03-19 16:38:12 -04:00
|
|
|
#+begin_src emacs-lisp :exports both
|
2010-12-13 14:41:55 -05:00
|
|
|
"code block results"
|
|
|
|
#+end_src
|
2012-03-19 16:38:12 -04:00
|
|
|
|
|
|
|
#+begin_src emacs-lisp :var lst=a-list :results list :exports both
|
2010-12-13 14:41:55 -05:00
|
|
|
(reverse lst)
|
|
|
|
#+end_src
|
2012-03-19 16:38:12 -04:00
|
|
|
|
2011-06-16 00:27:58 -04:00
|
|
|
* using the =:noweb-ref= header argument
|
|
|
|
:PROPERTIES:
|
|
|
|
:ID: 54d68d4b-1544-4745-85ab-4f03b3cbd8a0
|
2012-01-24 02:02:33 -05:00
|
|
|
:noweb-sep: ""
|
2011-06-16 00:27:58 -04:00
|
|
|
:END:
|
|
|
|
|
2013-06-08 16:06:57 -04:00
|
|
|
#+begin_src sh :tangle yes :noweb yes :shebang "#!/bin/sh"
|
2011-06-16 00:27:58 -04:00
|
|
|
<<fullest-disk>>
|
|
|
|
#+end_src
|
|
|
|
|
|
|
|
** query all mounted disks
|
|
|
|
#+begin_src sh :noweb-ref fullest-disk
|
2011-07-15 11:31:36 -04:00
|
|
|
df
|
2011-06-16 00:27:58 -04:00
|
|
|
#+end_src
|
|
|
|
|
|
|
|
** strip the header row
|
|
|
|
#+begin_src sh :noweb-ref fullest-disk
|
2011-07-15 11:31:36 -04:00
|
|
|
|sed '1d'
|
2011-06-16 00:27:58 -04:00
|
|
|
#+end_src
|
|
|
|
|
|
|
|
** sort by the percent full
|
|
|
|
#+begin_src sh :noweb-ref fullest-disk
|
2011-07-15 11:31:36 -04:00
|
|
|
|awk '{print $5 " " $6}'|sort -n |tail -1
|
2011-06-16 00:27:58 -04:00
|
|
|
#+end_src
|
|
|
|
|
|
|
|
** extract the mount point
|
|
|
|
#+begin_src sh :noweb-ref fullest-disk
|
|
|
|
|awk '{print $2}'
|
|
|
|
#+end_src
|
2011-06-28 16:02:16 -04:00
|
|
|
* 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
|
2011-09-06 04:00:24 -04:00
|
|
|
|
2011-09-05 17:53:07 -04:00
|
|
|
* org-babel-get-inline-src-block-matches
|
2012-03-19 16:38:12 -04:00
|
|
|
:PROPERTIES:
|
2011-09-05 17:53:07 -04:00
|
|
|
:results: silent
|
|
|
|
:ID: 0D0983D4-DE33-400A-8A05-A225A567BC74
|
|
|
|
:END:
|
|
|
|
src_sh{echo "One"} block at start of line
|
2012-03-19 16:38:12 -04:00
|
|
|
One spaced block in src_sh{ echo "middle" } of line
|
2011-09-05 17:53:07 -04:00
|
|
|
src_sh{echo 2} blocks on the src_emacs-lisp{"same"} line
|
|
|
|
Inline block with src_sh[:results silent]{ echo "parameters" }.
|
2012-03-19 16:38:12 -04:00
|
|
|
* exporting a code block with a name
|
2012-01-14 14:28:00 -05:00
|
|
|
:PROPERTIES:
|
2012-03-19 16:38:12 -04:00
|
|
|
:ID: b02ddd8a-eeb8-42ab-8664-8a759e6f43d9
|
2012-01-14 14:28:00 -05:00
|
|
|
:END:
|
|
|
|
|
2012-03-19 16:38:12 -04:00
|
|
|
exporting a code block with a name
|
|
|
|
#+name: qux
|
|
|
|
#+begin_src sh :foo "baz"
|
|
|
|
echo bar
|
2012-01-14 14:28:00 -05:00
|
|
|
#+end_src
|
2012-03-19 16:38:12 -04:00
|
|
|
* noweb no-export and exports both
|
|
|
|
:PROPERTIES:
|
|
|
|
:ID: 8a820f6c-7980-43db-8a24-0710d33729c9
|
|
|
|
:END:
|
|
|
|
Weird interaction.
|
2012-01-16 22:39:12 -05:00
|
|
|
|
2012-03-19 16:38:12 -04:00
|
|
|
here is one block
|
2012-01-16 22:39:12 -05:00
|
|
|
|
2012-03-19 16:38:12 -04:00
|
|
|
#+name: noweb-no-export-and-exports-both-1
|
|
|
|
#+BEGIN_SRC sh :exports none
|
|
|
|
echo 1
|
|
|
|
#+END_SRC
|
2012-03-17 10:52:24 -04:00
|
|
|
|
2012-03-19 16:38:12 -04:00
|
|
|
and another
|
|
|
|
|
|
|
|
#+BEGIN_SRC sh :noweb no-export :exports both
|
|
|
|
# I am inside the code block
|
|
|
|
<<noweb-no-export-and-exports-both-1>>
|
|
|
|
#+END_SRC
|
2011-09-16 06:07:19 -04:00
|
|
|
|
2012-01-23 12:33:12 -05:00
|
|
|
* in order evaluation on export
|
|
|
|
:PROPERTIES:
|
|
|
|
:exports: results
|
|
|
|
:ID: 96cc7073-97ec-4556-87cf-1f9bffafd317
|
|
|
|
:END:
|
|
|
|
|
|
|
|
First.
|
|
|
|
#+name: foo-for-order-of-evaluation
|
|
|
|
#+begin_src emacs-lisp :var it=1
|
|
|
|
(push it *evaluation-collector*)
|
|
|
|
#+end_src
|
|
|
|
|
|
|
|
Second
|
|
|
|
#+begin_src emacs-lisp
|
|
|
|
(push 2 *evaluation-collector*)
|
|
|
|
#+end_src
|
|
|
|
|
|
|
|
Third src_emacs-lisp{(push 3 *evaluation-collector*)}
|
|
|
|
|
|
|
|
Fourth
|
|
|
|
#+call: foo-for-order-of-evaluation(4)
|
|
|
|
|
|
|
|
Fifth
|
|
|
|
#+begin_src emacs-lisp
|
|
|
|
(push 5 *evaluation-collector*)
|
|
|
|
#+end_src
|
2012-03-19 16:38:12 -04:00
|
|
|
* exporting more than just results from a call line
|
|
|
|
:PROPERTIES:
|
|
|
|
:ID: bec63a04-491e-4caa-97f5-108f3020365c
|
|
|
|
:END:
|
|
|
|
Here is a call line with more than just the results exported.
|
|
|
|
#+call: double(8)
|
|
|
|
* strip noweb references on export
|
|
|
|
:PROPERTIES:
|
|
|
|
:ID: 8e7bd234-99b2-4b14-8cd6-53945e409775
|
|
|
|
:END:
|
|
|
|
|
|
|
|
#+name: strip-export-1
|
|
|
|
#+BEGIN_SRC sh :exports none
|
|
|
|
i="10"
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
#+BEGIN_SRC sh :noweb strip-export :exports code :results silent
|
|
|
|
<<strip-export-1>>
|
|
|
|
echo "1$i"
|
|
|
|
#+END_SRC
|
2013-06-19 05:36:36 -04:00
|
|
|
|
|
|
|
* use case of reading entry properties
|
|
|
|
:PROPERTIES:
|
|
|
|
:ID: cc5fbc20-bca5-437a-a7b8-2b4d7a03f820
|
|
|
|
:END:
|
|
|
|
|
2013-07-01 09:50:15 -04:00
|
|
|
Use case checked and documented with this test: During their
|
|
|
|
evaluation the source blocks read values from properties from the
|
|
|
|
entry where the call has been made unless the value is overridden with
|
|
|
|
the optional argument of the caller.
|
2013-06-19 05:36:36 -04:00
|
|
|
|
|
|
|
** section
|
|
|
|
:PROPERTIES:
|
|
|
|
:a: 1
|
|
|
|
:c: 3
|
|
|
|
:END:
|
|
|
|
|
|
|
|
Note: Just export of a property can be done with a macro: {{{property(a)}}}.
|
|
|
|
|
2013-07-01 09:50:15 -04:00
|
|
|
#+NAME: src_block_location_shell sect call
|
|
|
|
#+CALL: src_block_location_shell()
|
|
|
|
|
|
|
|
#+NAME: src_block_location_elisp sect call
|
|
|
|
#+CALL: src_block_location_elisp()
|
|
|
|
|
|
|
|
- sect inline call_src_block_location_shell()
|
|
|
|
- sect inline call_src_block_location_elisp()
|
2013-06-19 05:36:36 -04:00
|
|
|
|
|
|
|
*** subsection
|
|
|
|
:PROPERTIES:
|
|
|
|
:b: 2
|
|
|
|
:c: 4
|
|
|
|
:END:
|
|
|
|
|
2013-07-01 09:50:15 -04:00
|
|
|
#+NAME: src_block_location_shell sub0 call
|
|
|
|
#+CALL: src_block_location_shell()
|
|
|
|
|
|
|
|
#+NAME: src_block_location_elisp sub0 call
|
|
|
|
#+CALL: src_block_location_elisp()
|
|
|
|
|
|
|
|
- sub0 inline call_src_block_location_shell()
|
|
|
|
- sub0 inline call_src_block_location_elisp()
|
|
|
|
|
|
|
|
#+NAME: src_block_location_shell sub1 call
|
|
|
|
#+CALL: src_block_location_shell(c=5, e=6)
|
|
|
|
|
|
|
|
#+NAME: src_block_location_elisp sub1 call
|
|
|
|
#+CALL: src_block_location_elisp(c=5, e=6)
|
2013-06-19 05:36:36 -04:00
|
|
|
|
2013-07-01 09:50:15 -04:00
|
|
|
- sub1 inline call_src_block_location_shell(c=5, e=6)
|
|
|
|
- sub1 inline call_src_block_location_elisp(c=5, e=6)
|
2013-06-19 05:36:36 -04:00
|
|
|
|
|
|
|
**** function definition
|
|
|
|
|
2013-11-15 13:20:25 -05:00
|
|
|
comments for ":var":
|
|
|
|
- The "or" is to deal with a property not present.
|
|
|
|
- The t is to get property inheritance.
|
2013-06-19 05:36:36 -04:00
|
|
|
#+NAME: src_block_location_shell
|
|
|
|
#+HEADER: :var a=(or (org-entry-get org-babel-current-src-block-location "a" t) "0")
|
|
|
|
#+HEADER: :var b=(or (org-entry-get org-babel-current-src-block-location "b" t) "0")
|
|
|
|
#+HEADER: :var c=(or (org-entry-get org-babel-current-src-block-location "c" t) "0")
|
|
|
|
#+HEADER: :var d=(or (org-entry-get org-babel-current-src-block-location "d" t) "0")
|
|
|
|
#+HEADER: :var e=(or (org-entry-get org-babel-current-src-block-location "e" t) "0")
|
|
|
|
#+BEGIN_SRC sh :shebang #!/bin/sh :exports results :results verbatim
|
|
|
|
printf "shell a:$a, b:$b, c:$c, d:$d, e:$e"
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
#+RESULTS: src_block_location_shell
|
|
|
|
|
|
|
|
#+NAME: src_block_location_elisp
|
|
|
|
#+HEADER: :var a='nil
|
|
|
|
#+HEADER: :var b='nil
|
|
|
|
#+HEADER: :var c='nil
|
|
|
|
#+HEADER: :var d='nil
|
|
|
|
#+HEADER: :var e='nil
|
|
|
|
#+BEGIN_SRC emacs-lisp :exports results
|
|
|
|
(setq
|
2013-11-15 13:20:25 -05:00
|
|
|
;; - The first `or' together with ":var <var>='nil" is to check for
|
|
|
|
;; a value bound from an optional call argument, in the examples
|
|
|
|
;; here: c=5, e=6
|
|
|
|
;; - The second `or' is to deal with a property not present
|
|
|
|
;; - The t is to get property inheritance
|
2013-06-19 05:36:36 -04:00
|
|
|
a (or a (string-to-number
|
|
|
|
(or (org-entry-get org-babel-current-src-block-location "a" t)
|
|
|
|
"0")))
|
|
|
|
b (or b (string-to-number
|
|
|
|
(or (org-entry-get org-babel-current-src-block-location "b" t)
|
|
|
|
"0")))
|
|
|
|
c (or c (string-to-number
|
|
|
|
(or (org-entry-get org-babel-current-src-block-location "c" t)
|
|
|
|
"0")))
|
|
|
|
d (or d (string-to-number
|
|
|
|
(or (org-entry-get org-babel-current-src-block-location "e" t)
|
|
|
|
"0")))
|
|
|
|
e (or e (string-to-number
|
|
|
|
(or (org-entry-get org-babel-current-src-block-location "d" t)
|
|
|
|
"0"))))
|
|
|
|
(format "elisp a:%d, b:%d, c:%d, d:%d, e:%d" a b c d e)
|
|
|
|
#+END_SRC
|
2014-04-22 15:13:48 -04:00
|
|
|
|
|
|
|
* =:file-ext= and =:output-dir= header args
|
|
|
|
:PROPERTIES:
|
|
|
|
:ID: 93573e1d-6486-442e-b6d0-3fedbdc37c9b
|
|
|
|
:END:
|
|
|
|
#+name: file-ext-basic
|
|
|
|
#+BEGIN_SRC emacs-lisp :file-ext txt
|
|
|
|
nil
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
#+name: file-ext-dir-relative
|
|
|
|
#+BEGIN_SRC emacs-lisp :file-ext txt :output-dir foo
|
|
|
|
nil
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
#+name: file-ext-dir-relative-slash
|
|
|
|
#+BEGIN_SRC emacs-lisp :file-ext txt :output-dir foo/
|
|
|
|
nil
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
#+name: file-ext-dir-absolute
|
|
|
|
#+BEGIN_SRC emacs-lisp :file-ext txt :output-dir /tmp
|
|
|
|
nil
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
#+name: file-ext-file-wins
|
|
|
|
#+BEGIN_SRC emacs-lisp :file-ext txt :file foo.bar
|
|
|
|
nil
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
#+name: output-dir-and-file
|
|
|
|
#+BEGIN_SRC emacs-lisp :output-dir xxx :file foo.bar
|
|
|
|
nil
|
|
|
|
#+END_SRC
|