* supporting mouse-entered, mouse-left
@ 2009-07-31 7:13 Steve Yegge
2009-07-31 15:38 ` Drew Adams
2009-07-31 19:16 ` Stefan Monnier
0 siblings, 2 replies; 15+ messages in thread
From: Steve Yegge @ 2009-07-31 7:13 UTC (permalink / raw)
To: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 592 bytes --]
I would like to highlight certain identifiers (such as all uses
of a particular local variable in a function) simultaneously
when the mouse enters any of them.
I've scoured the documentation, and I don't see a way to
accomplish this feat.
Would it be reasonable to add mouse-entered and mouse-left
properties analogous to point-entered and point-left?
Alternately (or in addition), it might be nice to have text
properties analogous to the mouseenter, mouseleave and
possibly mouseover standard browser events, which would
fire at the granularity of pixels rather than characters.
-steve
[-- Attachment #2: Type: text/html, Size: 654 bytes --]
^ permalink raw reply [flat|nested] 15+ messages in thread
* RE: supporting mouse-entered, mouse-left
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 19:16 ` Stefan Monnier
1 sibling, 2 replies; 15+ messages in thread
From: Drew Adams @ 2009-07-31 15:38 UTC (permalink / raw)
To: 'Steve Yegge', emacs-devel
I would like to highlight certain identifiers (such as all uses
of a particular local variable in a function) simultaneously
when the mouse enters any of them.
I've scoured the documentation, and I don't see a way to
accomplish this feat.
Would it be reasonable to add mouse-entered and mouse-left
properties analogous to point-entered and point-left?
Alternately (or in addition), it might be nice to have text
properties analogous to the mouseenter, mouseleave and
possibly mouseover standard browser events, which would
fire at the granularity of pixels rather than characters.
Maybe I'm misunderstanding, but if you mean highlight the text whenever the
mouse is over it, you can do that using text property `mouse-face'. (That has
character granularity however.)
To have the mouseover highlight appear for certain words etc., you would need to
apply property `mouse-face' to those words.
AFAIK, font-lock cannot be used for this, since it always uses the `face' text
property. (But maybe I'm wrong about that.) It might be an interesting feature
for font-lock to let you specify a different text property to use.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: supporting mouse-entered, mouse-left
2009-07-31 15:38 ` Drew Adams
@ 2009-07-31 15:48 ` Steve Yegge
2009-07-31 16:48 ` Stephen J. Turnbull
1 sibling, 0 replies; 15+ messages in thread
From: Steve Yegge @ 2009-07-31 15:48 UTC (permalink / raw)
To: Drew Adams; +Cc: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 1682 bytes --]
On Fri, Jul 31, 2009 at 8:38 AM, Drew Adams <drew.adams@oracle.com> wrote:
> I would like to highlight certain identifiers (such as all uses
> of a particular local variable in a function) simultaneously
> when the mouse enters any of them.
>
> I've scoured the documentation, and I don't see a way to
> accomplish this feat.
>
> Would it be reasonable to add mouse-entered and mouse-left
> properties analogous to point-entered and point-left?
>
> Alternately (or in addition), it might be nice to have text
> properties analogous to the mouseenter, mouseleave and
> possibly mouseover standard browser events, which would
> fire at the granularity of pixels rather than characters.
>
> Maybe I'm misunderstanding, but if you mean highlight the text whenever the
> mouse is over it, you can do that using text property `mouse-face'. (That
> has
> character granularity however.)
>
> To have the mouseover highlight appear for certain words etc., you would
> need to
> apply property `mouse-face' to those words.
>
> AFAIK, font-lock cannot be used for this, since it always uses the `face'
> text
> property. (But maybe I'm wrong about that.) It might be an interesting
> feature
> for font-lock to let you specify a different text property to use.
>
>
I'm sorry if I was unclear. Let me give an example. In this sentence:
"One flew east, one flew west, and one flew over the cuckoo's nest."
I would like to arrange things in advance so that whenever the mouse is
over any instance of the word "flew", ALL of the instances highlight.
`mouse-face' is not powerful enough to accomplish this.
-steve
[-- Attachment #2: Type: text/html, Size: 2237 bytes --]
^ permalink raw reply [flat|nested] 15+ messages in thread
* RE: supporting mouse-entered, mouse-left
2009-07-31 16:48 ` Stephen J. Turnbull
@ 2009-07-31 16:42 ` Drew Adams
2009-07-31 20:23 ` Drew Adams
0 siblings, 1 reply; 15+ messages in thread
From: Drew Adams @ 2009-07-31 16:42 UTC (permalink / raw)
To: 'Stephen J. Turnbull'; +Cc: emacs-devel, 'Steve Yegge'
> I think you are misunderstanding. It wasn't entirely clear to me, but
> I think he wants *all* instances of a word to flash if the mouse is
> over *one* of them (as with `isearch-highlight-all-matches'), and for
> the highlighted word to change as the mouse moves.
Yes, I got it, from your and his clarifications. Thx.
I think it would be a good feature. Until then, isearch.
^ permalink raw reply [flat|nested] 15+ messages in thread
* RE: supporting mouse-entered, mouse-left
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
1 sibling, 1 reply; 15+ messages in thread
From: Stephen J. Turnbull @ 2009-07-31 16:48 UTC (permalink / raw)
To: Drew Adams; +Cc: emacs-devel, 'Steve Yegge'
Drew Adams writes:
> Maybe I'm misunderstanding, but if you mean highlight the text whenever the
> mouse is over it, you can do that using text property `mouse-face'. (That has
> character granularity however.)
I think you are misunderstanding. It wasn't entirely clear to me, but
I think he wants *all* instances of a word to flash if the mouse is
over *one* of them (as with `isearch-highlight-all-matches'), and for
the highlighted word to change as the mouse moves.
Anybody who has ever tried to track a particular message through the
sendmail logs will immediately understand the utility of this. Just
point at the sendmail message identifier, and voilà!, they're all
highlighted. But (grr) of course sendmail will change those
identifiers more often than Michael Jackson changed costume in a
concert. But now we're ready for that ... just a flick of the mouse
and we've got the next series of logs. Spam fighting gives "point and
shoot" a certain attraction to even the most confirmed pacifist....
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: supporting mouse-entered, mouse-left
2009-07-31 7:13 supporting mouse-entered, mouse-left Steve Yegge
2009-07-31 15:38 ` Drew Adams
@ 2009-07-31 19:16 ` Stefan Monnier
2009-07-31 22:05 ` Johan Bockgård
1 sibling, 1 reply; 15+ messages in thread
From: Stefan Monnier @ 2009-07-31 19:16 UTC (permalink / raw)
To: Steve Yegge; +Cc: emacs-devel
> I would like to highlight certain identifiers (such as all uses
> of a particular local variable in a function) simultaneously
> when the mouse enters any of them.
> I've scoured the documentation, and I don't see a way to
> accomplish this feat.
You can probably do it via track-mouse, but it's likely not going to
satisfy your needs quite like you want to.
> Would it be reasonable to add mouse-entered and mouse-left
> properties analogous to point-entered and point-left?
That sounds reasonable, yes.
> Alternately (or in addition), it might be nice to have text
> properties analogous to the mouseenter, mouseleave and
> possibly mouseover standard browser events, which would
> fire at the granularity of pixels rather than characters.
For text, I'm not sure it's worth the trouble. For images, I believe we
do have something that goes in this direction (tho not for mouse
movement).
Another way might be to check for a `mouse-movement' binding on the
keymap under the mouse cursor.
Stefan
^ permalink raw reply [flat|nested] 15+ messages in thread
* RE: supporting mouse-entered, mouse-left
2009-07-31 16:42 ` Drew Adams
@ 2009-07-31 20:23 ` Drew Adams
2009-07-31 20:57 ` Steve Yegge
0 siblings, 1 reply; 15+ messages in thread
From: Drew Adams @ 2009-07-31 20:23 UTC (permalink / raw)
To: 'Stephen J. Turnbull'; +Cc: 'Steve Yegge', emacs-devel
FWIW, you can use command `hlt-highlight-regexp-region' with a prefix arg to put
`mouse-face' on all regexp matches (in the region or buffer). It can use either
overlays or text properties. The command is here:
http://www.emacswiki.org/emacs/highlight.el.
What's still missing for the requested feature is the ability to show _all_
`mouse-face' text whenever you mouse-over any such text.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: supporting mouse-entered, mouse-left
2009-07-31 20:23 ` Drew Adams
@ 2009-07-31 20:57 ` Steve Yegge
2009-08-01 0:56 ` Drew Adams
2009-08-01 4:07 ` Stephen J. Turnbull
0 siblings, 2 replies; 15+ messages in thread
From: Steve Yegge @ 2009-07-31 20:57 UTC (permalink / raw)
To: Drew Adams; +Cc: Stephen J. Turnbull, emacs-devel
[-- Attachment #1: Type: text/plain, Size: 1694 bytes --]
On Fri, Jul 31, 2009 at 1:23 PM, Drew Adams <drew.adams@oracle.com> wrote:
> FWIW, you can use command `hlt-highlight-regexp-region' with a prefix arg
> to put
> `mouse-face' on all regexp matches (in the region or buffer). It can use
> either
> overlays or text properties. The command is here:
> http://www.emacswiki.org/emacs/highlight.el.
>
> What's still missing for the requested feature is the ability to show _all_
> `mouse-face' text whenever you mouse-over any such text.
>
Thanks, but I'm not looking for a one-off command to run, and
regular expressions are not sufficient for my needs here.
This is intended to be a feature of js2-mode, which I checked in
to the repository a few days ago. It is a major mode for editing
JavaScript code. It generates a full parse tree for the buffer, so
it knows exactly where all local variables and function parameters
are declared and referenced.
The mode decorates the source with various text properties to
facilitate navigation, outlining, folding, etc. My goal is to link
together all the references to each local variable, so they light
up when you mouse over any of them.
I can't use track-mouse, or at least I don't think I can, since this
feature needs to trigger automatically as you move the mouse
(from the idle loop).
If there were a way to be notified that the mouse has started
moving, then I could use track-mouse, albeit with a huge pile of
code. But it would likely be much less work to implement this in
C and offer a higher-level interface at the lisp level.
I'll take a look at implementing it when I get some time. I just
wanted to vet the idea with the list to make sure I wouldn't be
wasting my time.
-steve
[-- Attachment #2: Type: text/html, Size: 2188 bytes --]
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: supporting mouse-entered, mouse-left
2009-07-31 19:16 ` Stefan Monnier
@ 2009-07-31 22:05 ` Johan Bockgård
0 siblings, 0 replies; 15+ messages in thread
From: Johan Bockgård @ 2009-07-31 22:05 UTC (permalink / raw)
To: emacs-devel
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> I would like to highlight certain identifiers (such as all uses
>> of a particular local variable in a function) simultaneously
>> when the mouse enters any of them.
>
>> I've scoured the documentation, and I don't see a way to
>> accomplish this feat.
>
> You can probably do it via track-mouse, but it's likely not going to
> satisfy your needs quite like you want to.
The help-echo property + show-help-function can do it too, kind of.
(help-echo alone gives you `mouse-entered').
^ permalink raw reply [flat|nested] 15+ messages in thread
* RE: supporting mouse-entered, mouse-left
2009-07-31 20:57 ` Steve Yegge
@ 2009-08-01 0:56 ` Drew Adams
2009-08-01 5:52 ` Steve Yegge
2009-08-01 4:07 ` Stephen J. Turnbull
1 sibling, 1 reply; 15+ messages in thread
From: Drew Adams @ 2009-08-01 0:56 UTC (permalink / raw)
To: 'Steve Yegge'; +Cc: 'Stephen J. Turnbull', emacs-devel
The mode decorates the source with various text properties to
facilitate navigation, outlining, folding, etc. My goal is to link
together all the references to each local variable, so they light
up when you mouse over any of them.
Sounds like you need two things:
1. A way to highlight all text that has some property with a given value.
2. A way to know when the mouse is over any such text.
For #2 I dunno. Maybe you can put something on `post-command-hook' (or you might
need to do mouse-tracking). 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. That could be costly, but
it might get you started.
For #1, I just added a command to highlight.el that does that. It should give
you something that works while you look for something more appropriate, if it
isn't exactly what you want.
The new command is `hlt-highlight-property-with-value'. You give it the property
and value to highlight. You can give it a list of possible values - if the
property has any of them, then the text is highlighted.
You can also give it start and end limits, the highlighting face, the
highlighting type (overlay or text property or both), and whether the
highlighting should be with property `face' or `mouse-face'. All of these args
are optional.
To test the command:
1. Add a property to some text. For a quick test, you could add property
`mouse-face' with value `highlight' (e.g. just as a test) using `C-u M-x
hlt-highlight-regexp-region'.
2. Highlight all text that has a given property value. `M-x
hlt-highlight-property-with-value'. You are prompted for the property and the
value. E.g., enter `mouse-face' for the property and `highlight' for its value.
All text (in the region or buffer) that has property `mouse-face' with value
`highlight' is highlighted. (See the file for how to unhighlight etc.)
http://www.emacswiki.org/emacs/highlight.el
HTH.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: supporting mouse-entered, mouse-left
2009-07-31 20:57 ` Steve Yegge
2009-08-01 0:56 ` Drew Adams
@ 2009-08-01 4:07 ` Stephen J. Turnbull
2009-08-01 6:04 ` Steve Yegge
1 sibling, 1 reply; 15+ messages in thread
From: Stephen J. Turnbull @ 2009-08-01 4:07 UTC (permalink / raw)
To: Steve Yegge; +Cc: Drew Adams, emacs-devel
Steve Yegge writes:
> The mode decorates the source with various text properties to
> facilitate navigation, outlining, folding, etc. My goal is to link
> together all the references to each local variable,
Are you being imprecise here? Surely you have already done this
"linking" for other reasons?
> so they light up when you mouse over any of them.
Ie, the only problem you are asking about here is to get the motion
event, and run a hook on that?
> I can't use track-mouse,
*sigh*
> or at least I don't think I can, since this feature needs to
> trigger automatically as you move the mouse (from the idle loop).
Well, even if track-mouse doesn't do exactly what you want, it's not
clear to me that it's unusable. I can think of two interfaces that
might serve:
(1) a minor mode where a click toggles the highlighting corresponding
to the js2-mode text properties at the point of the click (no
motion tracking needed), and
(2) a minor mode which is activated by a click (or popup menu
selection), after which you can explicitly use track-mouse until
the next non-motion event or something like that. I don't think
this kind of mouse-tracking would require huge amounts of code for
what you've described, although there are few enough mouse clicks
that you may already be using them all.
I think you do want some kind of activation, otherwise if any mouse
motion enables the effect we'd have to coin a term "apoplectic fruit
salad".
If you want to test the "any motion" interface now, XEmacs has
`mode-motion-hook' which handles all mouse motion events. Eg,
(defvar sjt/counter 0)
(add-hook 'mode-motion-hook
(lambda (ignored)
(message "got one! (%d)")
(incf sjt/counter)))
immediately starts counting of motion events. Unfortunately, your
mode may not work in XEmacs without a fair amount of extra work due to
a lot of divergence in the last couple of years, but you could hack up
a test buffer with appropriate extents and stuff and see whether the
flashing is attractive or distractive.
`mode-motion-hook' is a variable declared in Lisp.
-- loaded from "/playpen/src/XEmacs/xemacs/+optimized/lisp/mode-motion.elc"
Value: nil
Setting it would make its value buffer-local.
Documentation:
Function or functions which are called whenever the mouse moves.
Each function must take a single argument of the motion event.
You should normally use this rather than `mouse-motion-handler', which
does some additional window-system-dependent things. This hook is local
to every buffer, and should normally be set up by major-modes which want
to use special highlighting. Every time the mouse moves over a window,
the mode-motion-hook of the buffer of that window is run.
> I'll take a look at implementing it when I get some time. I just
> wanted to vet the idea with the list to make sure I wouldn't be
> wasting my time.
It's been used in Lucid Emacs and XEmacs for over ten and probably
more than 15 years with success. I see no reason why it shouldn't
be adopted in Emacs as well.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: supporting mouse-entered, mouse-left
2009-08-01 0:56 ` Drew Adams
@ 2009-08-01 5:52 ` Steve Yegge
2009-08-01 7:26 ` Drew Adams
0 siblings, 1 reply; 15+ messages in thread
From: Steve Yegge @ 2009-08-01 5:52 UTC (permalink / raw)
To: Drew Adams; +Cc: Stephen J. Turnbull, emacs-devel
[-- Attachment #1: Type: text/plain, Size: 3113 bytes --]
No, I do not need #1. This is not a question about highlighting.
I most sincerely regret ever using the word "highlight", because
it has sent you off chasing a massive red herring.
Let's just pretend I never said I wanted them to highlight.
I want them to squeak audibly, like mice. OK? I will figure out
how to make that happen. By myself.
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. This is what is called, in the vulgar parlance, a Catch-22.
Stefan already understands my question and has given me a
very satisfactory answer, which is, in short: go ahead and implement
it. That is what I was hoping to hear.
Before I start, I need to go poke fun at Stephen for acting like
a user on a Mac OS X forum and telling me in great detail that I
don't really want to do what I specifically said I want to do.
-steve
On Fri, Jul 31, 2009 at 5:56 PM, Drew Adams <drew.adams@oracle.com> wrote:
> The mode decorates the source with various text properties to
> facilitate navigation, outlining, folding, etc. My goal is to link
> together all the references to each local variable, so they light
> up when you mouse over any of them.
>
> Sounds like you need two things:
>
> 1. A way to highlight all text that has some property with a given value.
> 2. A way to know when the mouse is over any such text.
>
> For #2 I dunno. Maybe you can put something on `post-command-hook' (or you
> might
> need to do mouse-tracking). 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. That could be costly,
> but
> it might get you started.
>
> For #1, I just added a command to highlight.el that does that. It should
> give
> you something that works while you look for something more appropriate, if
> it
> isn't exactly what you want.
>
> The new command is `hlt-highlight-property-with-value'. You give it the
> property
> and value to highlight. You can give it a list of possible values - if the
> property has any of them, then the text is highlighted.
>
> You can also give it start and end limits, the highlighting face, the
> highlighting type (overlay or text property or both), and whether the
> highlighting should be with property `face' or `mouse-face'. All of these
> args
> are optional.
>
> To test the command:
>
> 1. Add a property to some text. For a quick test, you could add property
> `mouse-face' with value `highlight' (e.g. just as a test) using `C-u M-x
> hlt-highlight-regexp-region'.
>
> 2. Highlight all text that has a given property value. `M-x
> hlt-highlight-property-with-value'. You are prompted for the property and
> the
> value. E.g., enter `mouse-face' for the property and `highlight' for its
> value.
> All text (in the region or buffer) that has property `mouse-face' with
> value
> `highlight' is highlighted. (See the file for how to unhighlight etc.)
>
> http://www.emacswiki.org/emacs/highlight.el
>
> HTH.
>
>
[-- Attachment #2: Type: text/html, Size: 3763 bytes --]
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: supporting mouse-entered, mouse-left
2009-08-01 4:07 ` Stephen J. Turnbull
@ 2009-08-01 6:04 ` Steve Yegge
2009-08-01 7:18 ` Stephen J. Turnbull
0 siblings, 1 reply; 15+ messages in thread
From: Steve Yegge @ 2009-08-01 6:04 UTC (permalink / raw)
To: Stephen J. Turnbull; +Cc: Drew Adams, emacs-devel
[-- Attachment #1: Type: text/plain, Size: 3048 bytes --]
On Fri, Jul 31, 2009 at 9:07 PM, Stephen J. Turnbull <stephen@xemacs.org>wrote:
> Steve Yegge writes:
>
> > The mode decorates the source with various text properties to
> > facilitate navigation, outlining, folding, etc. My goal is to link
> > together all the references to each local variable,
>
> Are you being imprecise here? Surely you have already done this
> "linking" for other reasons?
>
I appear to have inadvertently omitted the word "visually". I meant:
"My goal is to link together _visually_ all the references to each local
variable,"
But you knew *exactly* what I meant already, based on your first
reply. You're just being coy, and it's charming, but it's not fooling us.
>
> > so they light up when you mouse over any of them.
>
> Ie, the only problem you are asking about here is to get the motion
> event, and run a hook on that?
>
Aye.
>
> > I can't use track-mouse,
>
> *sigh*
>
+1
>
> > or at least I don't think I can, since this feature needs to
> > trigger automatically as you move the mouse (from the idle loop).
>
> Well, even if track-mouse doesn't do exactly what you want, it's not
> clear to me that it's unusable. I can think of two interfaces that
> might serve:
>
> (1) a minor mode where a click toggles the highlighting corresponding
> to the js2-mode text properties at the point of the click (no
> motion tracking needed), and
>
> (2) a minor mode which is activated by a click (or popup menu
> selection), after which you can explicitly use track-mouse until
> the next non-motion event or something like that. I don't think
> this kind of mouse-tracking would require huge amounts of code for
> what you've described, although there are few enough mouse clicks
> that you may already be using them all.
>
No clicks. It's gotta work in unselected windows. Clicks are a
deal-breaker. Hell, I've already got it working when point enters
an identifier. So clicking the mouse *already works*.
No clicks!
>
> I think you do want some kind of activation, otherwise if any mouse
> motion enables the effect we'd have to coin a term "apoplectic fruit
> salad".
>
I'm fine with that term. We can even name the hook after it, for
all I care. But this isn't about what I want. It's my users. They *love*
this feature in my browser-based code navigation tool. They drool
over it. They demand it in Emacs... and who am I to deny them?
I'm afraid I don't have that kind of authority. My hands are tied here.
So we're just gonna have to implement it.
>
> If you want to test the "any motion" interface now, XEmacs has
> `mode-motion-hook'
XEmacs... that's that VIM clone, isn't it? Or was it SlickEdit?
In all seriousness, I'd love to go look, but if I'm going to implement
this feature in Emacs, I worry that I don't understand any of the
legal ramifications of not clean-rooming it.
If someone with the initials "rms" OKs it, then I'll look. Otherwise,
I'll just take your word for it. At least you've validated the idea
that it's useful.
-steve
[-- Attachment #2: Type: text/html, Size: 4681 bytes --]
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: supporting mouse-entered, mouse-left
2009-08-01 6:04 ` Steve Yegge
@ 2009-08-01 7:18 ` Stephen J. Turnbull
0 siblings, 0 replies; 15+ messages in thread
From: Stephen J. Turnbull @ 2009-08-01 7:18 UTC (permalink / raw)
To: Steve Yegge; +Cc: emacs-devel
Steve Yegge writes:
> You're just being coy,
Nope. I know *what* you requested, but not why, and with very little
context floundered and asked an inaccurate question. You're right, in
hindsight, I didn't need to ask it. But I learned a lot about you in
the process, so it wasn't a total loss.
> So we're just gonna have to implement it.
Yes, *you* will. I already have a proven implementation. I'll be
happy to describe it to you in legally acceptable levels of detail,
since evidently I don't qualify for hands-on work in clean-room
conditions.
^ permalink raw reply [flat|nested] 15+ messages in thread
* RE: supporting mouse-entered, mouse-left
2009-08-01 5:52 ` Steve Yegge
@ 2009-08-01 7:26 ` Drew Adams
0 siblings, 0 replies; 15+ messages in thread
From: Drew Adams @ 2009-08-01 7:26 UTC (permalink / raw)
To: 'Steve Yegge'; +Cc: 'Stephen J. Turnbull', emacs-devel
>> 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.
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2009-08-01 7:26 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
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.