From: Suvayu Ali <fatkasuvayu+linux@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: How to execute code on cursor move
Date: Sat, 13 Jul 2013 17:32:23 +0200 [thread overview]
Message-ID: <20130713153223.GD11006@kuru.dyndns-at-home.com> (raw)
In-Reply-To: <3f6cb813-23d3-4815-9408-f5dfd30453af@default>
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.
next prev parent reply other threads:[~2013-07-13 15:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <<20130713103903.GA11006@kuru.dyndns-at-home.com>
[not found] ` <<83vc4e4t8a.fsf@gnu.org>
2013-07-13 13:26 ` How to execute code on cursor move Drew Adams
2013-07-13 15:32 ` Suvayu Ali [this message]
2013-07-13 10:39 Suvayu Ali
2013-07-13 11:03 ` Eli Zaretskii
2013-07-13 13:28 ` Suvayu Ali
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130713153223.GD11006@kuru.dyndns-at-home.com \
--to=fatkasuvayu+linux@gmail.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.