help-gnu-emacs
[Top][All Lists]
Advanced

[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: Kai Grossjohann
Subject: Re: How can I be notified whenever point of a buffer changed?
Date: Fri, 13 Apr 2007 12:25:23 +0200
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.97 (gnu/linux)

"Ender" <oldcode@gmail.com> writes:

> I want a user defined function be called whenever point of a desired
> buffer was changed, how can I do this stuff? Any help will be
> appreciated.

Perhaps you have to go for post-command-hook (or pre-command-hook).
The function would record the last seen value of point, look whether
point has changed, and do its thing if so.  (Obviously, you would also
have to update the last seen value of point.)

(defvar kai-last-point nil)
(make-variable-buffer-local 'kai-last-point)

(defun kai-motion-hook ()
  (unless (equal (point) kai-last-point)
    (setq kai-last-point (point))
    ... do stuff here ...))

(add-hook 'post-command-hook 'kai-motion-hook)

This is untested.

Kai





reply via email to

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