From ae721d089854e3b6b2d71ab6829b0cace25f0968 Mon Sep 17 00:00:00 2001 From: Matt Huszagh Date: Tue, 28 Sep 2021 18:26:04 -0700 Subject: [PATCH] etc/ORG-NEWS: Add news item about org-babel-default-header-args accepting closures --- etc/ORG-NEWS | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index b0a893946..db6df83f2 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -151,7 +151,7 @@ enable Calc units simplification mode. *** Support fontification of inline export snippets -Inline +Inline See [[msg:87im57fh8j.fsf@gmail.com][this thread]]. @@ -443,6 +443,33 @@ See [[msg:875z8njaol.fsf@protesilaos.com][this thread]]. attachment directory at calls of ~org-attach-sync~. There is Never delete, Always delete and Query the user (default). +*** ~org-babel-default-header-args~ can now be specified as closures or strings + +~org-babel-default-header-args~ now also accepts closures that +evaluate to a string. Previously, only direct strings were +supported. These closures are evaluated when point is at the source +block, which allows them to make use of contextual information at the +relevant source block. One example that illustrates the usefulness of +this addition (also given in the documentation for +~org-babel-default-header-args~) is: + +#+begin_src elisp +(defun org-src-sha () + (let ((elem (org-element-at-point))) + (concat (sha1 (org-element-property :value elem)) \".svg\"))) + +(setq org-babel-default-header-args:latex + `((:results . \"file link replace\") + (:file . (lambda () (org-src-sha))))) +#+end_src + +This will set the ~:file~ header argument to the sha1 checksum of the +contents of the current latex source block. + +Finally, the closures are only evaluated if they're not overridden for +a source block. This improves efficiency in cases where the result of +a compute-expensive closure would otherwise be discarded. + ** Miscellaneous *** =org-bibtex= includes =doi= and =url= entries when exporting to BiBTeX =doi= and =url= entries have been made optional for some publication -- 2.31.1