From 048f32d075c88459b22e59cb36cdc15b77016710 Mon Sep 17 00:00:00 2001 From: David Maus Date: Tue, 11 Jan 2011 22:07:33 +0100 Subject: [PATCH 1/4] Provide tests for table formular format conversion * test-org-table.el (test-org-table/org-table-convert-refs-to-rc/3) (test-org-table/org-table-convert-refs-to-rc/2) (test-org-table/org-table-convert-refs-to-rc/1) (test-org-table/org-table-convert-refs-to-an/3) (test-org-table/org-table-convert-refs-to-an/2) (test-org-table/org-table-convert-refs-to-an/1): Provide tests for table formular format conversion. --- testing/lisp/test-org-table.el | 56 ++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 testing/lisp/test-org-table.el diff --git a/testing/lisp/test-org-table.el b/testing/lisp/test-org-table.el new file mode 100644 index 000000000..e2501b3e7 --- /dev/null +++ b/testing/lisp/test-org-table.el @@ -0,0 +1,56 @@ +;;; test-org-table.el + +;; Copyright (c) ߛ David Maus +;; Authors: David Maus + +;; Released under the GNU General Public License version 3 +;; see: http://www.gnu.org/licenses/gpl-3.0.html + +;;;; Comments: + +;; Template test file for Org-mode tests + + +;;; Code: +(let ((load-path (cons (expand-file-name + ".." (file-name-directory + (or load-file-name buffer-file-name))) + load-path))) + (require 'org-test) + (require 'org-test-ob-consts)) + + +;;; Tests +(ert-deftest test-org-table/org-table-convert-refs-to-an/1 () + "Simple reference @1$1." + (should + (string= "A1" (org-table-convert-refs-to-an "@1$1")))) + +(ert-deftest test-org-table/org-table-convert-refs-to-an/2 () + "Self reference @1$1." + (should + (string= "A1 = $0" (org-table-convert-refs-to-an "@1$1 = $0")))) + +(ert-deftest test-org-table/org-table-convert-refs-to-an/3 () + "Remote reference." + (should + (string= "C& = remote(FOO, @@#B&)" (org-table-convert-refs-to-an "$3 = remote(FOO, @@#$2)")))) + +(ert-deftest test-org-table/org-table-convert-refs-to-rc/1 () + "Simple reference @1$1." + (should + (string= "@1$1" (org-table-convert-refs-to-rc "A1")))) + +(ert-deftest test-org-table/org-table-convert-refs-to-rc/2 () + "Self reference $0." + (should + (string= "@1$1 = $0" (org-table-convert-refs-to-rc "A1 = $0")))) + +(ert-deftest test-org-table/org-table-convert-refs-to-rc/3 () + "Remote reference." + (should + (string= "$3 = remote(FOO, @@#$2)" (org-table-convert-refs-to-rc "C& = remote(FOO, @@#B&)")))) + +(provide 'test-org-table) + +;;; test-org-table.el ends here From b092d31d68add1b599813fb3cfef7524c41280a7 Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Tue, 11 Jan 2011 17:32:51 -0700 Subject: [PATCH 2/4] doc: passing variables to #+call: lines * doc/org.texi (Evaluating code blocks): More explicit about how to pass variables to #+call lines. --- doc/org.texi | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/doc/org.texi b/doc/org.texi index e7bf07806..409f94f34 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -11376,6 +11376,18 @@ blocks located in the current Org-mode buffer or in the ``Library of Babel'' #+lob: ()
@end example +All variable (@code{:var}) header arguments can be placed in the +@code{} section using normal function call syntax. For example: + +@example +#+source: double +#+begin_src emacs-lisp :var n=2 + (* n 2) +#+end_src + +#+call: double(n=3) +@end example + @table @code @item The name of the code block to be evaluated. From ca0e61d7848e7ec1f49f2076e4a120c3e7722147 Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Tue, 11 Jan 2011 17:47:08 -0700 Subject: [PATCH 3/4] doc: improved documentation of optional #+call: line header arguments * doc/org.texi (Evaluating code blocks): Expanded discussion of #+call: line syntax. (Header arguments in function calls): Expanded discussion of #+call: line syntax. --- doc/org.texi | 46 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/doc/org.texi b/doc/org.texi index 409f94f34..4d696ae7a 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -11376,28 +11376,36 @@ blocks located in the current Org-mode buffer or in the ``Library of Babel'' #+lob: ()
@end example -All variable (@code{:var}) header arguments can be placed in the -@code{} section using normal function call syntax. For example: - -@example -#+source: double -#+begin_src emacs-lisp :var n=2 - (* n 2) -#+end_src - -#+call: double(n=3) -@end example - @table @code @item The name of the code block to be evaluated. @item -Arguments specified in this section will be passed to the code block. +Arguments specified in this section will be passed to the code block. These +arguments should relate to @code{:var} header arguments in the called code +block expressed using standard function call syntax. For example if the +original code block named @code{double} has the header argument @code{:var +n=2}, then the call line passing the number four to that block would be +written as @code{#+call: double(n=2)}. @item
Header arguments can be placed after the function invocation. See @ref{Header arguments} for more information on header arguments. @end table +All header arguments placed in the @code{
} section +described above will be applied to the evaluation of the @code{#+call:} line, +however it is sometimes desirable to specify header arguments to be passed to +the code block being evaluated. + +This is possible through the use of the following optional extended syntax. + +@example +#+call: []()
+@end example + +Any header argument placed between the square brackets in the @code{} section will be applied to the evaluation of the named +code block. For more examples of passing header arguments to @code{#+call:} +lines see @ref{Header arguments in function calls}. @node Library of Babel, Languages, Evaluating code blocks, Working With Source Code @section Library of Babel @@ -11656,12 +11664,22 @@ Multi-line header arguments on a named code block: @subsubheading Header arguments in function calls At the most specific level, header arguments for ``Library of Babel'' or -function call lines can be set as shown below: +function call lines can be set as shown in the two examples below. For more +information on the structure of @code{#+call:} lines see @ref{Evaluating code +blocks}. +The following will apply the @code{:exports results} header argument to the +evaluation of the @code{#+call:} line. @example #+call: factorial(n=5) :exports results @end example +The following will apply the @code{:session special} header argument to the +evaluation of the @code{factorial} code block. +@example +#+call: factorial[:session special](n=5) +@end example + @node Specific header arguments, , Using header arguments, Header arguments @subsection Specific header arguments The following header arguments are defined: From f7a752f6d60e1c747dc9330c5f12631bf77f6aa3 Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Tue, 11 Jan 2011 20:40:13 -0700 Subject: [PATCH 4/4] ob-ref: Allow passing empty strings into code blocks. Thanks to Leo Alekseyev for pointing this out. * lisp/ob-ref.el (org-babel-ref-parse): Allow passing empty strings into code blocks. --- lisp/ob-ref.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/ob-ref.el b/lisp/ob-ref.el index 7995341c9..f11fcf435 100644 --- a/lisp/ob-ref.el +++ b/lisp/ob-ref.el @@ -76,7 +76,7 @@ the variable." (cons (intern var) (let ((out (org-babel-read ref))) (if (equal out ref) - (if (string-match "^\".+\"$" ref) + (if (string-match "^\".*\"$" ref) (read ref) (org-babel-ref-resolve ref)) out))))))