From 778a29dcc64e7f400f94145adf01dca67f5588f4 Mon Sep 17 00:00:00 2001 Message-ID: <778a29dcc64e7f400f94145adf01dca67f5588f4.1734270889.git.yantar92@posteo.net> From: Ihor Radchenko Date: Sun, 15 Dec 2024 14:52:39 +0100 Subject: [PATCH] org-babel-tangle-publish: Keep the original tangled files * lisp/ob-tangle.el (org-babel-tangle-publish): When publishing tangled files, do not remove the original versions of these files. Keeping was the old behaviour that some users relied upon. Removing the tangled files may also be unexpected when they were tangled outside publishing, during normal user workflows. Update the docstring to explicitly state that the tangled files are copied. Reported-by: Gilles Marait Link: https://orgmode.org/list/878qvtkwhn.fsf@localhost --- lisp/ob-tangle.el | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el index fe143b039f..9554a3226d 100644 --- a/lisp/ob-tangle.el +++ b/lisp/ob-tangle.el @@ -227,13 +227,11 @@ (defun org-babel-tangle-file (file &optional target-file lang-re) (org-babel-tangle nil target-file lang-re))))) (defun org-babel-tangle-publish (_ filename pub-dir) - "Tangle FILENAME and place the results in PUB-DIR." - (unless (file-exists-p pub-dir) - (make-directory pub-dir t)) - (setq pub-dir (file-name-as-directory pub-dir)) - ;; Rename files to avoid copying to same file when publishing to ./ - ;; `copy-file' would throw an error when copying file to self. - (mapc (lambda (el) (rename-file el pub-dir t)) + "Tangle FILENAME and copy the tangled file to PUB-DIR." + (require 'ox-publish) + (declare-function org-publish-attachment "ox-publish" + (plist filename pub-dir)) + (mapc (lambda (el) (org-publish-attachment nil el pub-dir)) (org-babel-tangle-file filename))) ;;;###autoload -- 2.47.1