Take the 2-minute tour ×
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 7 down vote accepted

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.

share|improve this answer
    
You might want to add the warning from with-silent-modifications documentation –  Iqbal Ansari yesterday
    
Thank you, done. –  wasamasa yesterday

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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