From 15b8f60ed8fcb49d1be8a8b896beacf5c5a09663 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fel=C5=A1=C3=B6ci?= <marek.felsoci@inria.fr> Date: Wed, 25 Jan 2023 15:01:05 +0100 Subject: [PATCH] Add handy Babel execution functions --- compose-publish.el | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/compose-publish.el b/compose-publish.el index 4afbe5f..4c5c7ea 100644 --- a/compose-publish.el +++ b/compose-publish.el @@ -182,6 +182,26 @@ To solve this problem, when your code only knows the relative path of another fi (with-current-buffer "*Org PDF LaTeX Output*" (message (buffer-string)))))) +(defun org-babel-execute-file (plist filename pub-dir) + ;; A custom publishing function for executing all Babel source code blocks in + ;; the Org file `filename'. Note that the function does not actually publish + ;; anything to `pub-dir'. + (progn + (find-file filename) + (org-babel-execute-buffer) + (set-buffer-modified-p nil) + (kill-buffer))) + +(defun execute-block-in-file (block file) + ;; Executes the named source code `block' in `file' without altering the + ;; latter. + (progn + (find-file file) + (org-babel-goto-named-src-block block) + (org-babel-execute-src-block) + (set-buffer-modified-p nil) + (kill-buffer))) + ;; Use timestamp to avoid publishing (setq org-publish-use-timestamps-flag t) -- GitLab