From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kai Grossjohann Newsgroups: gmane.emacs.help Subject: Re: How can I be notified whenever point of a buffer changed? Date: Fri, 13 Apr 2007 12:25:23 +0200 Message-ID: <86hcrka7vw.fsf@ketchup.de.uu.net> References: <1176350448.277558.178010@q75g2000hsh.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1176460230 21874 80.91.229.12 (13 Apr 2007 10:30:30 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 13 Apr 2007 10:30:30 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Apr 13 12:30:28 2007 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1HcJ2y-0007LY-0N for geh-help-gnu-emacs@m.gmane.org; Fri, 13 Apr 2007 12:30:28 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HcJ7D-0006GE-Q9 for geh-help-gnu-emacs@m.gmane.org; Fri, 13 Apr 2007 06:34:51 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HcJ6z-0006G0-V8 for help-gnu-emacs@gnu.org; Fri, 13 Apr 2007 06:34:37 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HcJ6z-0006Fg-GK for help-gnu-emacs@gnu.org; Fri, 13 Apr 2007 06:34:37 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HcJ6z-0006Fd-Cx for help-gnu-emacs@gnu.org; Fri, 13 Apr 2007 06:34:37 -0400 Original-Received: from main.gmane.org ([80.91.229.2] helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1HcJ2i-0002ob-KU for help-gnu-emacs@gnu.org; Fri, 13 Apr 2007 06:30:12 -0400 Original-Received: from root by ciao.gmane.org with local (Exim 4.43) id 1HcJ2Y-0001Ak-12 for help-gnu-emacs@gnu.org; Fri, 13 Apr 2007 12:30:09 +0200 Original-Received: from de-lt-054776l.eu.frd.uu.net ([62.191.185.105]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 13 Apr 2007 12:30:02 +0200 Original-Received: from kai by de-lt-054776l.eu.frd.uu.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 13 Apr 2007 12:30:02 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 24 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: de-lt-054776l.eu.frd.uu.net User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.97 (gnu/linux) Cancel-Lock: sha1:xnpPfj1lUvLMYY+J0n22r8fY5B8= X-detected-kernel: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:42638 Archived-At: "Ender" 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