[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How can I be notified whenever point of a buffer changed?
From: |
Ender |
Subject: |
Re: How can I be notified whenever point of a buffer changed? |
Date: |
12 Apr 2007 19:21:40 -0700 |
User-agent: |
G2/1.0 |
On Apr 12, 4:09 pm, Kai Grossjohann <k...@emptydomain.de> wrote:
> The following info node explains the point-left and point-entered text
> properties:
>
> (elisp)Special Properties
>
> I found it like this:
>
> M-x apropos RET point.*hook RET
>
> This mentioned a variable inhibit-point-motion-hooks. The
> documentation of this variable mentions the point-left and
> point-entered text properties.
>
> So I went to the elisp info file (Emacs Lisp Reference), hit the i key
> to search the index and entered point-left as the search string.
Thanks Kai, you are so kindhearted and your message helps me a lot.
But I still have problem. I have tried with following elisp demo code:
(defun text-entered-hook (old-point new-point)
(save-current-buffer
(set-buffer (get-buffer-create "*scratch*"))
(insert "From " (number-to-string old-point) " to " (number-to-
string new-point) "\n")))
(setq default-text-properties '(point-left nil))
(setq default-text-properties '(point-entered text-entered-hook))
After M-x eval-buffer, I found two problem with the code:
1). Not all the point change will trigger text-entered-hook and I
can't find any rule of which kind of point changing will trigger the
hook. It confused me.
2). When the hook was triggered, it will be called twice. Yes I know
why this happens (info node of point-left/point-entered explained
clearly), but how can I fix it?
Thanks for your help again Kai, you are a good man. :-)