Function: with-silent-modifications
with-silent-modifications is a macro defined in subr.el.gz.
Signature
(with-silent-modifications &rest BODY)
Documentation
Execute BODY, pretending it does not modify the buffer.
This macro is typically used around modifications of text properties that do not really affect the buffer's content. If BODY performs real modifications to the buffer's text, other than cosmetic ones, undo data may become corrupted.
This macro will run BODY normally, but doesn't count its buffer
modifications as being buffer modifications. This affects things
like buffer-modified-p, checking whether the file is locked by
someone else, running buffer modification hooks, and other things
of that nature.
Probably introduced at or before Emacs version 23.2.
Source Code
;; Defined in /usr/src/emacs/lisp/subr.el.gz
(defmacro with-silent-modifications (&rest body)
"Execute BODY, pretending it does not modify the buffer.
This macro is typically used around modifications of
text properties that do not really affect the buffer's content.
If BODY performs real modifications to the buffer's text, other
than cosmetic ones, undo data may become corrupted.
This macro will run BODY normally, but doesn't count its buffer
modifications as being buffer modifications. This affects things
like `buffer-modified-p', checking whether the file is locked by
someone else, running buffer modification hooks, and other things
of that nature."
(declare (debug t) (indent 0))
(let ((modified (make-symbol "modified")))
`(let* ((,modified (buffer-modified-p))
(buffer-undo-list t)
(inhibit-read-only t)
(inhibit-modification-hooks t))
(unwind-protect
(progn
,@body)
(unless ,modified
(restore-buffer-modified-p nil))))))