* mouse click on an overlay, using overlay `keymap' property
@ 2008-03-16 23:21 Drew Adams
2008-03-18 9:28 ` martin rudalics
0 siblings, 1 reply; 7+ messages in thread
From: Drew Adams @ 2008-03-16 23:21 UTC (permalink / raw)
To: 'emacs- devel'
Could someone please explain what's happening here, and why? How can I get
the overlay's keymap to be in effect over all of the visual (displayed) area
of the overlay?
(setq foo-map (make-sparse-keymap))
(define-key foo-map [mouse-2] 'bar)
(defun foo (beg end)
(interactive "r")
(let ((overlay (make-overlay beg end)))
(overlay-put
overlay 'display
(propertize "xxxxxxxxx" 'face 'font-lock-constant-face))
(overlay-put overlay 'keymap foo-map)))
(defun bar (event) (interactive "e") (message "BAR"))
Here's some text: aaaaaaaaaaaaaaaaaaaaaaa
Select one or more of the a's and do M-x foo, to apply the overlay to just
those a's.
Put point somewhere outside the displayed "xxxxxxxxx" overlay.
Click mouse-2 anywhere on the displayed "xxxxxxxxx". What happens, it seems,
is that, since point is not on the a's that have the overlay, keymap foo-map
doesn't apply. Clicking mouse-2 therefore just calls the default mouse-2
binding, e.g. mouse-yank-at-click. That sets point so that it is at the
beginning of the overlaid text, so that a second mouse-2 click on the
displayed "xxxxxxxxx" does call bar.
If that's what's happening, how can foo be defined so that a first click on
the displayed "xxxxxxxxx" calls bar?
I'm probably not understanding this well - help appreciated. I'm guessing
that the mouse click on the overlay is noted not as being a click on a
buffer position that has the overlay but on a buffer position that is under
the displayed "xxxxxxxxx" but is actually outside the text that has the
overlay.
What I'm looking for is for the click to be perceived by Emacs as happening
on the overlay, and for the overlay's keymap to apply over the full extent
of the overlay, not just at its beginning, causing the overlay's keymap
binding to take effect.
[Note that I'm specifically asking about overlays here, not text properties.
I know how to create clickable text using text properties.]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: mouse click on an overlay, using overlay `keymap' property
2008-03-16 23:21 mouse click on an overlay, using overlay `keymap' property Drew Adams
@ 2008-03-18 9:28 ` martin rudalics
2008-03-18 15:08 ` Drew Adams
0 siblings, 1 reply; 7+ messages in thread
From: martin rudalics @ 2008-03-18 9:28 UTC (permalink / raw)
To: Drew Adams; +Cc: 'emacs- devel'
> If that's what's happening, how can foo be defined so that a first click on
> the displayed "xxxxxxxxx" calls bar?
How 'bout
(defun foo (beg end)
(interactive "r")
(let ((overlay (make-overlay beg end)))
(overlay-put
overlay 'display
(propertize "xxxxxxxxx" 'face 'font-lock-constant-face 'keymap foo-map))))
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: mouse click on an overlay, using overlay `keymap' property
2008-03-18 9:28 ` martin rudalics
@ 2008-03-18 15:08 ` Drew Adams
2008-03-18 18:27 ` martin rudalics
0 siblings, 1 reply; 7+ messages in thread
From: Drew Adams @ 2008-03-18 15:08 UTC (permalink / raw)
To: 'martin rudalics'; +Cc: 'emacs- devel'
> > how can foo be defined so that a first click on
> > the displayed "xxxxxxxxx" calls bar?
>
> How 'bout
> (defun foo (beg end)
> (interactive "r")
> (let ((overlay (make-overlay beg end)))
> (overlay-put
> overlay 'display
> (propertize "xxxxxxxxx" 'face 'font-lock-constant-face
> 'keymap foo-map))))
I was hoping that that would do the trick and help me understand, but it
doesn't seem to change anything. (Does it work for you?) I'm using Emacs
22.1, FWIW.
Is this a bug? Can someone please explain what's happening? Thx.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: mouse click on an overlay, using overlay `keymap' property
2008-03-18 15:08 ` Drew Adams
@ 2008-03-18 18:27 ` martin rudalics
2008-03-18 18:44 ` Drew Adams
0 siblings, 1 reply; 7+ messages in thread
From: martin rudalics @ 2008-03-18 18:27 UTC (permalink / raw)
To: Drew Adams; +Cc: 'emacs- devel'
> I was hoping that that would do the trick and help me understand, but it
> doesn't seem to change anything. (Does it work for you?) I'm using Emacs
> 22.1, FWIW.
Hmmm... My version works here in a recent Emacs 23 build but does _not_
work in an Emacs 22 I built in May 2007. Can someone have a look what's
going on? Incidentally, your original version works with Emacs 21.
> Is this a bug? Can someone please explain what's happening? Thx.
I think it should work in one way or the other.
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: mouse click on an overlay, using overlay `keymap' property
2008-03-18 18:27 ` martin rudalics
@ 2008-03-18 18:44 ` Drew Adams
2008-03-18 19:06 ` martin rudalics
0 siblings, 1 reply; 7+ messages in thread
From: Drew Adams @ 2008-03-18 18:44 UTC (permalink / raw)
To: 'martin rudalics'; +Cc: 'emacs- devel'
> > I was hoping that that would do the trick and help me
> > understand, but it doesn't seem to change anything.
> > (Does it work for you?) I'm using Emacs 22.1, FWIW.
>
> Hmmm... My version works here in a recent Emacs 23 build but
> does _not_ work in an Emacs 22 I built in May 2007. Can
> someone have a look what's going on? Incidentally, your
> original version works with Emacs 21.
>
> > Is this a bug? Can someone please explain what's happening? Thx.
>
> I think it should work in one way or the other.
Thanks for taking a look.
I guess you're also confirming that it should work as I expected, at least:
that is, clicking an overlay that has a keymap that binds that mouse click
should use that keymap, regardless of the buffer position (or lack of
position) under the overlay.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: mouse click on an overlay, using overlay `keymap' property
2008-03-18 18:44 ` Drew Adams
@ 2008-03-18 19:06 ` martin rudalics
2008-03-18 19:37 ` Drew Adams
0 siblings, 1 reply; 7+ messages in thread
From: martin rudalics @ 2008-03-18 19:06 UTC (permalink / raw)
To: Drew Adams; +Cc: 'emacs- devel'
> I guess you're also confirming that it should work as I expected, at least:
> that is, clicking an overlay that has a keymap that binds that mouse click
> should use that keymap, regardless of the buffer position (or lack of
> position) under the overlay.
I can confirm that it would be nice if it worked that way. But I'd
never ever count on overlays with display, before- and after-string
properties always DTRT. These properties are too powerful.
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: mouse click on an overlay, using overlay `keymap' property
2008-03-18 19:06 ` martin rudalics
@ 2008-03-18 19:37 ` Drew Adams
0 siblings, 0 replies; 7+ messages in thread
From: Drew Adams @ 2008-03-18 19:37 UTC (permalink / raw)
To: 'martin rudalics'; +Cc: 'emacs- devel'
> > I guess you're also confirming that it should work as I
> > expected, at least: that is, clicking an overlay that has
> > a keymap that binds that mouse click should use that keymap,
> > regardless of the buffer position (or lack of
> > position) under the overlay.
>
> I can confirm that it would be nice if it worked that way. But I'd
> never ever count on overlays with display, before- and after-string
> properties always DTRT. These properties are too powerful.
I take that as a confirmation that this is a bug.
No one has expressed another view or offered a different explanation, so
far.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2008-03-18 19:37 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-16 23:21 mouse click on an overlay, using overlay `keymap' property Drew Adams
2008-03-18 9:28 ` martin rudalics
2008-03-18 15:08 ` Drew Adams
2008-03-18 18:27 ` martin rudalics
2008-03-18 18:44 ` Drew Adams
2008-03-18 19:06 ` martin rudalics
2008-03-18 19:37 ` Drew Adams
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.