forked from mirrors/org-mode
Merge branch 'maint'
This commit is contained in:
commit
55d807f348
|
@ -89,6 +89,8 @@ NOTE: By default, string variable names are interpreted as
|
||||||
references to source-code blocks, to force interpretation of a
|
references to source-code blocks, to force interpretation of a
|
||||||
cell's value as a string, prefix the identifier a \"$\" (e.g.,
|
cell's value as a string, prefix the identifier a \"$\" (e.g.,
|
||||||
\"$$2\" instead of \"$2\" or \"$@2$2\" instead of \"@2$2\").
|
\"$$2\" instead of \"$2\" or \"$@2$2\" instead of \"@2$2\").
|
||||||
|
This will not work with a range; instead, pass it as a list,
|
||||||
|
e.g. (org-sbe fun (r (list $1..$2))).
|
||||||
|
|
||||||
NOTE: It is also possible to pass header arguments to the code
|
NOTE: It is also possible to pass header arguments to the code
|
||||||
block. In this case a table cell should hold the string value of
|
block. In this case a table cell should hold the string value of
|
||||||
|
@ -112,7 +114,7 @@ as shown in the example below.
|
||||||
(prog1 nil (setq quote t))
|
(prog1 nil (setq quote t))
|
||||||
(prog1
|
(prog1
|
||||||
(cond
|
(cond
|
||||||
(quote (format "\"%s\"" el))
|
(quote (format "%S" el))
|
||||||
((stringp el) (org-no-properties el))
|
((stringp el) (org-no-properties el))
|
||||||
(t el))
|
(t el))
|
||||||
(setq quote nil))))
|
(setq quote nil))))
|
||||||
|
@ -132,12 +134,17 @@ as shown in the example below.
|
||||||
"("
|
"("
|
||||||
(mapconcat
|
(mapconcat
|
||||||
(lambda (var-spec)
|
(lambda (var-spec)
|
||||||
(if (> (length (cdr var-spec)) 1)
|
(cond
|
||||||
|
((> (length (cdr var-spec)) 1)
|
||||||
(format "%S='%S"
|
(format "%S='%S"
|
||||||
(car var-spec)
|
(car var-spec)
|
||||||
(mapcar #'read (cdr var-spec)))
|
(mapcar #'read (cdr var-spec))))
|
||||||
|
((stringp (cadr var-spec))
|
||||||
(format "%S=%s"
|
(format "%S=%s"
|
||||||
(car var-spec) (cadr var-spec))))
|
(car var-spec) (cadr var-spec)))
|
||||||
|
(t
|
||||||
|
(format "%S=%S"
|
||||||
|
(car var-spec) (cadr var-spec)))))
|
||||||
',variables ", ")
|
',variables ", ")
|
||||||
")")))))
|
")")))))
|
||||||
(org-babel-execute-src-block
|
(org-babel-execute-src-block
|
||||||
|
|
|
@ -30,6 +30,51 @@
|
||||||
;; (org-test-at-id "6d2ff4ce-4489-4e2a-9c65-e3f71f77d975"
|
;; (org-test-at-id "6d2ff4ce-4489-4e2a-9c65-e3f71f77d975"
|
||||||
;; (should (= 2 (sbe take-sqrt (n "4"))))))
|
;; (should (= 2 (sbe take-sqrt (n "4"))))))
|
||||||
|
|
||||||
|
(ert-deftest test-ob-table/sbe-quote ()
|
||||||
|
"Test that `org-sbe' can correctly handle cell values containing quotes."
|
||||||
|
(org-test-table-target-expect
|
||||||
|
"
|
||||||
|
#+name: identity
|
||||||
|
#+begin_src emacs-lisp :eval yes
|
||||||
|
x
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
| a\"b\"c | replace |
|
||||||
|
"
|
||||||
|
"
|
||||||
|
#+name: identity
|
||||||
|
#+begin_src emacs-lisp :eval yes
|
||||||
|
x
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
| a\"b\"c | a\"b\"c |
|
||||||
|
"
|
||||||
|
1
|
||||||
|
"#+TBLFM: $2 = '(org-sbe identity (x $$1))"))
|
||||||
|
|
||||||
|
(ert-deftest test-ob-table/sbe-list ()
|
||||||
|
"Test that `org-sbe' can correctly handle ranges as lists."
|
||||||
|
(org-test-table-target-expect
|
||||||
|
"
|
||||||
|
#+name: concat
|
||||||
|
#+begin_src emacs-lisp :eval yes
|
||||||
|
(mapconcat #'identity x \"\")
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
| foo | bar | replace |
|
||||||
|
"
|
||||||
|
"
|
||||||
|
#+name: concat
|
||||||
|
#+begin_src emacs-lisp :eval yes
|
||||||
|
(mapconcat #'identity x \"\")
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
| foo | bar | foobar |
|
||||||
|
"
|
||||||
|
1
|
||||||
|
"#+TBLFM: $3 = '(org-sbe concat (x (list $1..$2)))"
|
||||||
|
"#+TBLFM: $3 = '(org-sbe concat (x $ (list $1..$2)))"))
|
||||||
|
|
||||||
(provide 'test-ob-table)
|
(provide 'test-ob-table)
|
||||||
|
|
||||||
;;; test-ob-table.el ends here
|
;;; test-ob-table.el ends here
|
||||||
|
|
Loading…
Reference in a new issue