Skip to content

Commit

Permalink
Do not mark buffer as modified with org-preserve-local-variables
Browse files Browse the repository at this point in the history
* lisp/org-macs.el (org-preserve-local-variables): Do not mark buffer
as modified or alter `buffer-undo-list' when body does not actually
modify the buffer.

This commit fixes a bug with `org-copy-subtree', which marked the
buffer as modified and added an entry to the undo list when the visited
file had local variables.
  • Loading branch information
igmacs authored and yantar92 committed Jun 14, 2022
1 parent f9ea6c6 commit aa789b8
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lisp/org-macs.el
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,19 @@
(and (re-search-backward "^[ \t]*# +Local Variables:"
(max (- (point) 3000) 1)
t)
(delete-and-extract-region (point) (point-max)))))))
(let ((buffer-undo-list t))
(delete-and-extract-region (point) (point-max)))))))
(tick-counter-before (buffer-modified-tick)))
(unwind-protect (progn ,@body)
(when local-variables
(org-with-wide-buffer
(goto-char (point-max))
(unless (bolp) (insert "\n"))
(insert local-variables))))))
(let ((modified (< tick-counter-before (buffer-modified-tick)))
(buffer-undo-list t))
(insert local-variables)
(unless modified
(restore-buffer-modified-p nil))))))))

(defmacro org-no-popups (&rest body)
"Suppress popup windows and evaluate BODY."
Expand Down

0 comments on commit aa789b8

Please sign in to comment.