forked from mirrors/org-mode
Allow returning empty list from post-processing block
* lisp/ob-ref.el (org-babel-ref-resolve): When the result an empty list, then treat it as a list, not as the symbol nil. * testing/lisp/test-ob.el (test-ob/post-header-arguments): Add new test. * etc/ORG-NEWS (Post-processing code blocks can return an empty list): Document change in behavior.
This commit is contained in:
parent
eece396db8
commit
9b690462a3
|
@ -425,6 +425,12 @@ The new variable name is =org-plantuml-args=. It now applies to both
|
||||||
jar PlantUML file and executable.
|
jar PlantUML file and executable.
|
||||||
|
|
||||||
** Miscellaneous
|
** Miscellaneous
|
||||||
|
*** Post-processing code blocks can return an empty list
|
||||||
|
|
||||||
|
When the result of a regular code block is nil, then that was already
|
||||||
|
treated as an empty list. Now that is also the case for code blocks
|
||||||
|
that post-process the result of another block.
|
||||||
|
|
||||||
*** Styles are customizable in ~biblatex~ citation processor
|
*** Styles are customizable in ~biblatex~ citation processor
|
||||||
|
|
||||||
It is now possible to add new styles or modify old ones in ~biblatex~
|
It is now possible to add new styles or modify old ones in ~biblatex~
|
||||||
|
|
|
@ -199,7 +199,7 @@ Emacs Lisp representation of the value of the variable."
|
||||||
(org-babel-execute-src-block nil info params))))
|
(org-babel-execute-src-block nil info params))))
|
||||||
(error "Reference `%s' not found in this buffer" ref))))
|
(error "Reference `%s' not found in this buffer" ref))))
|
||||||
(cond
|
(cond
|
||||||
((symbolp result) (format "%S" result))
|
((and result (symbolp result)) (format "%S" result))
|
||||||
((and index (listp result))
|
((and index (listp result))
|
||||||
(org-babel-ref-index-list index result))
|
(org-babel-ref-index-list index result))
|
||||||
(t result)))))))))
|
(t result)))))))))
|
||||||
|
|
|
@ -136,6 +136,30 @@ should still return the link."
|
||||||
(let ((info (org-babel-get-src-block-info)))
|
(let ((info (org-babel-get-src-block-info)))
|
||||||
(should (string= "no" (cdr (assq :tangle (nth 2 info))))))))
|
(should (string= "no" (cdr (assq :tangle (nth 2 info))))))))
|
||||||
|
|
||||||
|
(ert-deftest test-ob/post-header-arguments ()
|
||||||
|
"When the result of a post-processing source block is an empty
|
||||||
|
list, then it should be treated as such; not as the symbol nil."
|
||||||
|
(should
|
||||||
|
(let ((default-directory temporary-file-directory))
|
||||||
|
(org-test-with-temp-text
|
||||||
|
"
|
||||||
|
#+name: addheader
|
||||||
|
#+header: :var rows=\"\"
|
||||||
|
#+begin_src elisp :hlines yes
|
||||||
|
'()
|
||||||
|
#+end_src
|
||||||
|
#+header: :post addheader(*this*)
|
||||||
|
#+<point>begin_src emacs-lisp :results table
|
||||||
|
#+end_src
|
||||||
|
#+RESULTS:
|
||||||
|
: nil"
|
||||||
|
(org-babel-execute-src-block)
|
||||||
|
(goto-char (1- (point-max)))
|
||||||
|
(equal (buffer-substring-no-properties
|
||||||
|
(line-beginning-position)
|
||||||
|
(line-end-position))
|
||||||
|
"#+RESULTS:")))))
|
||||||
|
|
||||||
(ert-deftest test-ob/elisp-in-header-arguments ()
|
(ert-deftest test-ob/elisp-in-header-arguments ()
|
||||||
"Test execution of elisp forms in header arguments."
|
"Test execution of elisp forms in header arguments."
|
||||||
(org-test-with-temp-text-in-file "
|
(org-test-with-temp-text-in-file "
|
||||||
|
|
Loading…
Reference in New Issue