From 9cc194dcb9bf6825d68aac3118f18ae96b8642a5 Mon Sep 17 00:00:00 2001 From: Antero Mejr Date: Fri, 17 Nov 2023 16:06:53 +0000 Subject: [PATCH] Move files when using `org-babel-tangle-publish' Fixes `copy-file' error when publishing to the current directory. Don't leave behind the old tangled files when publishing. * lisp/ob-tangle.el (org-babel-tangle-publish): Use `rename-file' instead of `copy-file' on tangled files. --- lisp/ob-tangle.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el index b30fd9274..e16b9e42d 100644 --- a/lisp/ob-tangle.el +++ b/lisp/ob-tangle.el @@ -219,7 +219,9 @@ Return list of the tangled file names." (unless (file-exists-p pub-dir) (make-directory pub-dir t)) (setq pub-dir (file-name-as-directory pub-dir)) - (mapc (lambda (el) (copy-file el pub-dir t)) (org-babel-tangle-file filename))) + ;; Rename files to avoid copying to same file when publishing to ./ + (mapc (lambda (el) (rename-file el pub-dir t)) + (org-babel-tangle-file filename))) ;;;###autoload (defun org-babel-tangle (&optional arg target-file lang-re) -- 2.41.0