From: "Drew Adams" <drew.adams@oracle.com>
To: "'Steve Yegge'" <stevey@google.com>
Cc: "'Stephen J. Turnbull'" <stephen@xemacs.org>, emacs-devel@gnu.org
Subject: RE: supporting mouse-entered, mouse-left
Date: Sat, 1 Aug 2009 00:26:46 -0700 [thread overview]
Message-ID: <7AECD8D943404149AC60780F52B5B28F@us.oracle.com> (raw)
In-Reply-To: <9c768dc60907312252k7bf800b8t453669b2ca2a6067@mail.gmail.com>
>> 2. A way to know when the mouse is over any such text.
>> ...
>> A function on `post-command-hook' could perhaps check whether
>> the last event was a mouse event, and if so get the mouse position
>> and then the value of the property at that position.
>
> My question is #2, and your solution does not work. Emacs does
> not send any notifications when the mouse moves unless track-mouse
> is on.
Right, for a mouseover you would need to use tracking (or write some C code, as
you mentioned). You seemed to say you could not use tracking (or perhaps did not
want to use it).
Using `post-command-hook' as I suggested is quite sufficient if you are willing
to click the spot to check instead of just mousing over it. This simple code
highlights all occurrences of the property when any such occurrence is clicked,
and unhighlights them all when you click anywhere else:
(defun foo (prop value &optional start end face type)
(unless face (setq face 'highlight))
(unless type (setq type 'overlay))
(when (string-match
"mouse"
(format "%S" (event-basic-type last-command-event)))
(let* ((estart (event-start last-command-event))
(pos (posn-point estart)))
(when (integer-or-marker-p pos)
(save-excursion
(with-current-buffer (window-buffer (posn-window estart))
(if (eq (get-char-property pos prop) value)
(hlt-highlight-property-with-value
prop (list value) start end face type)
(hlt-unhighlight-region-for-face face start end))))))))
(defun foobar () (foo 'mouse-face 'highlight))
(add-hook 'post-command-hook 'foobar)
Try it in *Help* or Dired, for instance, to show/hide all links at once.
But if, as you now added, you do not really want to, as you said before, "light
up" all such occurrences, then just substitute your code to "squeak audibly,
like mice" for the hook function. Or tomorrow, if you want to send up balloons
instead, put your balloon machine on the hook. Or not.
next prev parent reply other threads:[~2009-08-01 7:26 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-31 7:13 supporting mouse-entered, mouse-left Steve Yegge
2009-07-31 15:38 ` Drew Adams
2009-07-31 15:48 ` Steve Yegge
2009-07-31 16:48 ` Stephen J. Turnbull
2009-07-31 16:42 ` Drew Adams
2009-07-31 20:23 ` Drew Adams
2009-07-31 20:57 ` Steve Yegge
2009-08-01 0:56 ` Drew Adams
2009-08-01 5:52 ` Steve Yegge
2009-08-01 7:26 ` Drew Adams [this message]
2009-08-01 4:07 ` Stephen J. Turnbull
2009-08-01 6:04 ` Steve Yegge
2009-08-01 7:18 ` Stephen J. Turnbull
2009-07-31 19:16 ` Stefan Monnier
2009-07-31 22:05 ` Johan Bockgård
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=7AECD8D943404149AC60780F52B5B28F@us.oracle.com \
--to=drew.adams@oracle.com \
--cc=emacs-devel@gnu.org \
--cc=stephen@xemacs.org \
--cc=stevey@google.com \
/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.