8

I want to add properties to text (make it read-only temporarily) and I don't want “modification-status” change. In general, how do I perform some modifying action without Emacs noticing it?

10

There is a built-in macro for this, with-silent-modifications.

Its intended usecase is for making changes to text properties of a buffer as text properties are part of the text and changes to them would otherwise be reflected in the buffer modification status and trigger the respective hooks. Despite there being rudimentary protection against more invasive changes of the text, you should ensure the body doesn't do anything weird:

If BODY performs real modifications to the buffer's text, other than cosmetic ones, undo data may become corrupted.

  • You might want to add the warning from with-silent-modifications documentation – Iqbal Ansari Sep 7 '15 at 8:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.