emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [BUG] org-copy-subtree in a file with local variables marks buffer as modified [9.5.3 (release_9.5.3-6-gef41f3 @ /home/ignacio/repos/emacs/lisp/org/)]
@ 2022-05-22  7:08 Ignacio Casso
  2022-06-11  7:36 ` Ihor Radchenko
  0 siblings, 1 reply; 6+ messages in thread
From: Ignacio Casso @ 2022-05-22  7:08 UTC (permalink / raw)
  To: emacs-orgmode


Copying a subtree with `org-copy-subtree' in an org file with local
variables marks the buffer as modified. This is because
`org-copy-subtree' calls `org-preserve-local-variables', which deletes
local variables, executes some body, and then inserts them again, which
results in a modified buffer even if the buffer was not modified before
and the body does not modify it either, like in the case of

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?

Best regards,


Emacs  : GNU Emacs 29.0.50 (build 53, x86_64-pc-linux-gnu, GTK+ Version 3.24.20, cairo version 1.16.0)
 of 2022-05-22
Package: Org mode version 9.5.3 (release_9.5.3-6-gef41f3 @ /home/ignacio/repos/emacs/lisp/org/)

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-06-14 14:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-22  7:08 [BUG] org-copy-subtree in a file with local variables marks buffer as modified [9.5.3 (release_9.5.3-6-gef41f3 @ /home/ignacio/repos/emacs/lisp/org/)] Ignacio Casso
2022-06-11  7:36 ` Ihor Radchenko
2022-06-12  8:53   ` Ignacio Casso
2022-06-14  4:17     ` Ihor Radchenko
2022-06-14  7:21       ` Ignacio Casso
2022-06-14 14:05         ` Ihor Radchenko

Code repositories for project(s) associated with this public inbox


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).