Move files when using `org-babel-tangle-publish'

* lisp/ob-tangle.el (org-babel-tangle-publish): Use `rename-file'
instead of `copy-file' on tangled files.

Fixes `copy-file' error when publishing to the current directory.
Don't leave behind the old tangled files when publishing.

Link: https://orgmode.org/list/87v898mgx4.fsf@mailbox.org
This commit is contained in:
Antero Mejr 2023-11-17 16:06:53 +00:00 committed by Ihor Radchenko
parent 3280f2f8bd
commit 478576749d
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
1 changed files with 4 additions and 1 deletions

View File

@ -219,7 +219,10 @@ 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 ./
;; `copy-file' would throw an error when copying file to self.
(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)