summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIhor Radchenko <yantar92@posteo.net>2023-12-04 13:55:05 +0100
committerIhor Radchenko <yantar92@posteo.net>2023-12-15 12:23:22 +0100
commitfbcd71e856fb6c1fbf432c63ffd1c37546aecfcd (patch)
treefa91af12ffa35a8fe76327d33fde6b3e7e74a785
parentd6924212bd3ed1b7b9def71504c714cb8aa00e8a (diff)
downloadorg-mode-fbcd71e85.tar.gz
org-babel-tangle: Do note erase the existing tangle target before overwriting
* lisp/ob-tangle.el (org-babel-tangle): Do not remove the existing tangle target file, if any. `write-region' later will overwrite it anyway, while removing may be unexpected if the existing target is a symlink. Reported-by: Cletip Cletip <clement020302@gmail.com> Link: https://list.orgmode.org/orgmode/CAPHku6O9NfVMAfmE3_ahmpJea_2Qm0mJMFX6qPpT8uiQ94KMZA@mail.gmail.com/
-rw-r--r--lisp/ob-tangle.el5
1 files changed, 2 insertions, 3 deletions
diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el
index bd77292..ef1fb5a 100644
--- a/lisp/ob-tangle.el
+++ b/lisp/ob-tangle.el
@@ -313,9 +313,8 @@ matching a regular expression."
(compare-buffer-substrings
nil nil nil
tangle-buf nil nil)))))))
- ;; erase previous file
- (when (file-exists-p file-name)
- (delete-file file-name))
+ ;; We do not erase, but overwrite previous file
+ ;; to preserve any existing symlinks.
(write-region nil nil file-name)
(mapc (lambda (mode) (set-file-modes file-name mode)) modes))
(push file-name path-collector))))))