From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Ender" Newsgroups: gmane.emacs.help Subject: Re: How can I be notified whenever point of a buffer changed? Date: 12 Apr 2007 19:21:40 -0700 Organization: http://groups.google.com Message-ID: <1176430900.460559.246910@o5g2000hsb.googlegroups.com> References: <1176350448.277558.178010@q75g2000hsh.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: sea.gmane.org 1176431776 31880 80.91.229.12 (13 Apr 2007 02:36:16 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 13 Apr 2007 02:36:16 +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 04:36:12 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 1HcBe0-00006r-GD for geh-help-gnu-emacs@m.gmane.org; Fri, 13 Apr 2007 04:36:12 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HcBiE-0006Xe-3a for geh-help-gnu-emacs@m.gmane.org; Thu, 12 Apr 2007 22:40:34 -0400 Original-Path: shelby.stanford.edu!newshub.stanford.edu!postnews.google.com!o5g2000hsb.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 40 Original-NNTP-Posting-Host: 222.68.182.212 Original-X-Trace: posting.google.com 1176430901 3715 127.0.0.1 (13 Apr 2007 02:21:41 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Fri, 13 Apr 2007 02:21:41 +0000 (UTC) In-Reply-To: User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.3) Gecko/20060601 Firefox/2.0.0.3 (Ubuntu-edgy),gzip(gfe),gzip(gfe) X-HTTP-Via: 1.1 SHPROXY Complaints-To: groups-abuse@google.com Injection-Info: o5g2000hsb.googlegroups.com; posting-host=222.68.182.212; posting-account=6C-vRw0AAAAZJwEQEIgtFDLzbspLF35g Original-Xref: shelby.stanford.edu gnu.emacs.help:147027 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:42631 Archived-At: On Apr 12, 4:09 pm, Kai Grossjohann 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. :-)