Ignacio Casso <ignacioca...@hotmail.com> writes: > What would you think about a change like the following in the definition of > `org-preserve-local-variables' to solve the issue? > > + (let ((modified-before-p) (buffer-modified-p)) > ;; current code that deletes local variables > + (unless modified-before-p (set-buffer-modified-p nil)) > ;; current code that executes body > + (let ((modified-after-p (buffer-modified-p))) > ;; current code that restores local variables > + (unless modified-after-p (set-buffer-modified-p nil)))) > > Could the current code or my proposed change have any more unintended > consequences, for example in the undo tree or mark ring? Sometimes when > I undo or jump to the mark, the point moves to the last visible, usually > folded headline of the file, even if I had not edited it recently, and I > have always assumed that it's because it wants to go to the end of the > buffer for some reason I've never been able to come up with or > debug. Could that have something to do with this?
buffer-modified-p is not the only parameter affected by juggling around the local variables. There will be undo history, buffer-chars-modified-tick, before/after-change-hooks triggered by `org-preserve-local-variables', etc. However, I do not see any obvious way how your proposed change can negatively affect all the above. Feel free to propose a patch. Best, Ihor