all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Ehud Karni" <ehud@unix.mvs.co.il>
To: wojciech.meyer@googlemail.com
Cc: emacs-devel@gnu.org
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	[thread overview]
Message-ID: <201106091415.p59EFNcQ003457@beta.mvs.co.il> (raw)
In-Reply-To: <871uz6h7vf.fsf@gmail.com> (message from Wojciech Meyer on Tue, 07 Jun 2011 00:12:36 +0100)

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



  parent reply	other threads:[~2011-06-09 14:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-06 23:12 How to avoid put-text-property setting buffer modified flag, and messing with the undo history? Wojciech Meyer
2011-06-06 23:18 ` Lennart Borgman
2011-06-09 14:15 ` Ehud Karni [this message]
2011-06-09 15:33   ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201106091415.p59EFNcQ003457@beta.mvs.co.il \
    --to=ehud@unix.mvs.co.il \
    --cc=emacs-devel@gnu.org \
    --cc=wojciech.meyer@googlemail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.