Antero Mejr <ant...@mailbox.org> writes: > When publishing using org-babel-tangle-publish to the same directory > that contains the org files, copy-file will signal an error, since the > source and destination files refer to the same file. So use rename-file > instead. > > When publishing to a different directory, this change also cleans up the > old files, which matches the behavior of the other publishing functions > like org-html-publish-to-html.
Thanks for the patch! May you please submit a patch against Org mode git repository - https://git.savannah.gnu.org/cgit/emacs/org-mode.git, as described at https://orgmode.org/worg/org-contribute.html ? Also, may I know if you have an FSF copyright assignment? If not, you also need to add TINYCHANGE to the commit message - see https://orgmode.org/worg/org-contribute.html#first-patch > Fixes copy-file error when publishing to the current directory. > Don't leave behind the old tangled files when publishing. > > * lisp/org/ob-tangle.el (org-babel-tangle-publish): Use rename-file > instead of copy-file on tangled files. Please quote `rename-file' and `copy-file' like I do - it is our commit message convention (https://orgmode.org/worg/org-contribute.html#orgd7441de) > - (mapc (lambda (el) (copy-file el pub-dir t)) (org-babel-tangle-file > filename))) > + (mapc (lambda (el) (rename-file el pub-dir t)) > + (org-babel-tangle-file filename))) I think that it would be nice to add a brief comment why `rename-file' to the code as well. `copy-file' looks innocent there from a first glance. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at <https://orgmode.org/>. Support Org development at <https://liberapay.com/org-mode>, or support my work at <https://liberapay.com/yantar92>