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/
This commit is contained in:
Ihor Radchenko 2023-12-04 13:55:05 +01:00
parent d6924212bd
commit fbcd71e856
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
1 changed files with 2 additions and 3 deletions

View File

@ -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))))))