emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to avoid put-text-property setting buffer modified flag, and mes


From: Ehud Karni
Subject: Re: How to avoid put-text-property setting buffer modified flag, and messing with the undo history?
Date: Thu, 9 Jun 2011 17:15:23 +0300

On Tue, 07 Jun 2011 00:12:36 +0100, Wojciech Meyer wrote:
>
> I'm trying to dynamically color the buffer using text properties. It
> works as follows:
>
       [snip]
>
> 6. For coloring I use text properties, but they change buffer marking it
> as modified and altering undo information, and I don't want that.

Here is a snippet that i use for exactly the same purpose.
I don't know if it is the best solution, but it works.

   (let ((sbul buffer-undo-list)           ;; undo list for selected buffer
         (bmp (buffer-modified-p))         ;; modify state
         (buffer-read-only nil))           ;; allow change!
       (put-text-property P1 P2 'face FACE);; change face (color)
       (set-buffer-modified-p bmp)         ;; restore modify state
       (setq buffer-undo-list sbul))       ;; restore undo

Ehud.


--
 Ehud Karni           Tel: +972-3-7966-561  /"\
 Mivtach - Simon      Fax: +972-3-7976-561  \ /  ASCII Ribbon Campaign
 Insurance agencies   (USA) voice mail and   X   Against   HTML   Mail
 http://www.mvs.co.il  FAX:  1-815-5509341  / \
 GnuPG: 98EA398D <http://www.keyserver.net/>    Better Safe Than Sorry



reply via email to

[Prev in Thread] Current Thread [Next in Thread]