Perhaps this is simply because they are considered part of the string ... (as the docs say). Remember that Emacs is buffer-oriented, not file-oriented, so the fact that the contents are stored on disk is somewhat irrelevant (with mental buffering).
In addition, the properties are invalid and, of course, correspond to the fact that the buffer is marked as modified.
I do not know that there is a standard way to save the state modified by the buffer, but I see it in the pabbrev.el library:
(defmacro pabbrev-save-buffer-modified-p (&rest body) "Eval BODY without affected buffer modification status" `(let ((buffer-modified (buffer-modified-p)) (buffer-undo-list t)) ,@body (set-buffer-modified-p buffer-modified)))
It does not protect against non-local outputs , so perhaps you need to add an unwind-protect call, for example:
(defmacro save-buffer-modified-p (&rest body) "Eval BODY without affected buffer modification status" `(let ((buffer-modified (buffer-modified-p)) (buffer-undo-list t)) (unwind-protect ,@body (set-buffer-modified-p buffer-modified))))
Trey jackson
source share