Olivier Lischer <olivier.lisc...@liolin.ch> writes: >> I suggest changing your patch, setting the default value of >> `org-babel-tangle-remove-file-before-write' to 'auto. >> This will keep the current behaviour but fall back to delete + write new >> file when the tangle target is read-only. >> That will avoid feature regression. > > I changed the path as you proposed.
Thanks, but I think that I was not clear enough explaining what I wanted you to change. > -(defcustom org-babel-tangle-uncomment-comments nil > +(defcustom org-babel-tangle-uncomment-comments 'auto I did not ask to change `org-babel-tangle-uncomment-comments'. I meant that you allow the new variable you propose (`org-babel-tangle-remove-file-before-write') to have 3 values: nil, t, and 'auto. > +(defcustom org-babel-tangle-remove-file-before-write nil ... with default being 'auto, not nil. > - ;; We do not erase, but overwrite previous file > - ;; to preserve any existing symlinks. > - (write-region nil nil file-name) > + (when (and (file-exists-p file-name) > org-babel-tangle-remove-file-before-write) > + (delete-file file-name)) > + (write-region nil nil file-name) Then, with the default value of 'auto, you only call `delete-file' when the file is read-only. It would also help to extend the comment ";; We do not erase...", not just delete it. -- 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>