emacs: How to intelligently handle buffer-modified when setting text properties?

Posted by Cheeso on Stack Overflow See other posts from Stack Overflow or by Cheeso
Published on 2010-04-23T15:34:05Z Indexed on 2010/04/23 15:53 UTC
Read the original article Hit count: 209

Filed under:

The documentation on Text Properties says:

Since text properties are considered part of the contents of the buffer (or string), and can affect how a buffer looks on the screen, any change in buffer text properties marks the buffer as modified.

First, I don't understand that policy. Can anyone explain? The text props are not actually saved in the file, when the buffer is saved. So why mark the buffer as modified? For me, buffer-modified indicates "some changes have not yet been saved." but understanding the policy is just for my own amusement.

More importantly, is there an already-established way that, in code, I can change syntax text properties on the text in a buffer, while keeping the buffer-modified flag set to whatever it was, prior to those changes? I'm thinking of something like save-excursion. It would be pretty easy to write, but this seems like a common case and I'd like to use the standard function, if possible.

For more on the scenario - I have a mode that does a full text scan and sets syntax-tabe properties on the text. After opening a buffer, the scan runs, but it results in a buffer with buffer-modified set to t .

As always, thanks.

© Stack Overflow or respective owner

Related posts about emacs