From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Suvayu Ali Newsgroups: gmane.emacs.help Subject: Re: How to execute code on cursor move Date: Sat, 13 Jul 2013 17:32:23 +0200 Message-ID: <20130713153223.GD11006@kuru.dyndns-at-home.com> References: <20130713103903.GA11006@kuru.dyndns-at-home.com> <83vc4e4t8a.fsf@gnu.org> <3f6cb813-23d3-4815-9408-f5dfd30453af@default> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1373729559 25379 80.91.229.3 (13 Jul 2013 15:32:39 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 13 Jul 2013 15:32:39 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Jul 13 17:32:40 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Uy1oO-0004p8-47 for geh-help-gnu-emacs@m.gmane.org; Sat, 13 Jul 2013 17:32:40 +0200 Original-Received: from localhost ([::1]:47107 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uy1oN-0005Sq-OZ for geh-help-gnu-emacs@m.gmane.org; Sat, 13 Jul 2013 11:32:39 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34215) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uy1oE-0005Sj-P4 for help-gnu-emacs@gnu.org; Sat, 13 Jul 2013 11:32:32 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uy1oD-0000TG-Lc for help-gnu-emacs@gnu.org; Sat, 13 Jul 2013 11:32:30 -0400 Original-Received: from mail-ea0-x22f.google.com ([2a00:1450:4013:c01::22f]:55273) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uy1oD-0000T7-FM for help-gnu-emacs@gnu.org; Sat, 13 Jul 2013 11:32:29 -0400 Original-Received: by mail-ea0-f175.google.com with SMTP id z7so6908437eaf.34 for ; Sat, 13 Jul 2013 08:32:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=Hbpm8dpX0mAeLqKW6aXVHcRSFFQNH1HCcs8WXkj0Ia0=; b=WBvn99+nrNFdlWAFCVEsFI3lUn8CqMUwZ1ktkcLm4EqCiBJaFBuZ7VpkRYVUcoAEgl ZhP+DWe06xLk1YTuA16CpvUvLlXegj1IQ/laDLT5gXCePPYY2Mtjy20VszqrkZNyBnRl 1rKPH6DaULx48gUUAOH66AO28LbVNcWoVmqbiRGLhGLdvnYJ/0gdiF/TNBElnBIxhfn8 YcjmKp6zp6JjExE8tuGJ11j+qfXE0S/ddJ8oWsEju7H77MlZLHo2lj1RPYm65Mm0X2Pw p2fDfODOMWuj0UjkXNypwqArH8kc8uGcjvyFGGFgSAGQx03JaM/FzoTKL2PlyZnpmHz6 VQzQ== X-Received: by 10.15.50.132 with SMTP id l4mr50697146eew.122.1373729548261; Sat, 13 Jul 2013 08:32:28 -0700 (PDT) Original-Received: from kuru.dyndns-at-home.com (sd44012d5.adsl.online.nl. [212.64.18.213]) by mx.google.com with ESMTPSA id r54sm28671786eev.8.2013.07.13.08.32.26 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 13 Jul 2013 08:32:26 -0700 (PDT) Content-Disposition: inline In-Reply-To: <3f6cb813-23d3-4815-9408-f5dfd30453af@default> User-Agent: Mutt/1.5.21 (2012-12-30) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4013:c01::22f X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:92106 Archived-At: Hi Drew, On Sat, Jul 13, 2013 at 06:26:24AM -0700, Drew Adams wrote: > > > I want to check a text property and display in the minibuffer depending > > > on context (in my case, on an org-link). > > > > > > (add-hook 'post-command-hook > > > (lambda() > > > (if (eq (get-text-property (point) 'face) 'org-link) > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > > > Is using the post-command-hook a good idea? > > > > No, because it slows down Emacs's _every_ command. > > > > > Is there something better? > > > > There are the 'point-entered' and 'point-left' text properties. Make > > sure they cover the buffer positions where you want to display the > > message in the echo area, and the rest should be easy. > > Remember too that the `face' property can be a cons of faces or face > attributes. So you might not want to test for `org-link' using only `eq'. > IOW, you might want something like this, to check for the presence of > face `org-link': > > (let ((face (get-text-property (point) 'face))) > (or (eq 'org-link face) > (and (consp face) (memq 'org-link face)))) > I actually saw something very similar in Org mode source but didn't quite follow everything, so I "simplified" it to what you see above. :-p Thank you very much for the pointer. Now I understand :). Cheers, -- Suvayu Open source is the future. It sets us free.