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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to execute code on cursor move


From: Suvayu Ali
Subject: Re: How to execute code on cursor move
Date: Sat, 13 Jul 2013 15:28:38 +0200
User-agent: Mutt/1.5.21 (2012-12-30)

Hi Eli,

On Sat, Jul 13, 2013 at 02:03:33PM +0300, Eli Zaretskii wrote:
> > Date: Sat, 13 Jul 2013 12:39:03 +0200
> > From: Suvayu Ali <fatkasuvayu+linux@gmail.com>
> > 
> > I want to check a text property and display in the minibuffer depending
> > on context (in my case, on an org-link).

 [...chomp...chomp...chomp...]

> > Is using the post-command-hook a good idea?
> 
> No, because it slows down Emacs's _every_ command.

Thank you, I had a feeling that is the case.

> > 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.

I have the following snippet based on what you say above:

----------8<--------------------8<----------
;; Text for testing
;; some text description some more

;; setup: add tooltip
(add-text-properties 34 45
                     '(help-echo "tooltip"))

;; test above setup: tooltip b/w 34-45
(get-text-property 40 'help-echo)

;; add special properties
(defun sa-echo-tooltip (old new)
  (display-message-or-buffer (or (get-text-property new 'help-echo) "")))

(add-text-properties
 34 45 '(point-left sa-echo-tooltip point-entered sa-echo-tooltip))
----------8<--------------------8<----------

Now to convert this to something workable I guess I would have to add
the point-left and point-entered properties to all org-links.  I'm not
sure how I can do that, but I guess asking on the Org mode list will be
best.

Thanks a lot!

-- 
Suvayu

Open source is the future. It sets us free.



reply via email to

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