* Button widget keymap conflicting with major mode.
@ 2010-02-21 4:07 Óscar Fuentes
2010-02-21 5:54 ` Drew Adams
0 siblings, 1 reply; 5+ messages in thread
From: Óscar Fuentes @ 2010-02-21 4:07 UTC (permalink / raw)
To: help-gnu-emacs
A read-only buffer has a major mode which defines bindings for RET and
other keys which are also used by button widgets created by
(widget-create 'push-button ...
The bindings for the major mode override the button bindings (it is not
possible to user RET when the point is on the button for invoking
it). I can make the button work with (use-local-map widget-keymap), but
then the bindings for the major mode are gone.
Is there a way for RET invoking the button when the point is over it and
invoke the major mode binding otherwise?
Using Emacs 23.1.
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: Button widget keymap conflicting with major mode.
2010-02-21 4:07 Button widget keymap conflicting with major mode Óscar Fuentes
@ 2010-02-21 5:54 ` Drew Adams
2010-02-24 4:29 ` Kevin Rodgers
0 siblings, 1 reply; 5+ messages in thread
From: Drew Adams @ 2010-02-21 5:54 UTC (permalink / raw)
To: 'Óscar Fuentes', help-gnu-emacs
> A read-only buffer has a major mode which defines bindings for RET and
> other keys which are also used by button widgets created by
>
> (widget-create 'push-button ...
>
> The bindings for the major mode override the button bindings
> (it is not possible to user RET when the point is on the
> button for invoking it). I can make the button work with
> (use-local-map widget-keymap), but then the bindings for
> the major mode are gone.
>
> Is there a way for RET invoking the button when the point is
> over it and invoke the major mode binding otherwise?
>
> Using Emacs 23.1.
`keymap' text property would be one way.
See node `Special Properties' of the Elisp manual.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Button widget keymap conflicting with major mode.
2010-02-21 5:54 ` Drew Adams
@ 2010-02-24 4:29 ` Kevin Rodgers
2010-02-24 5:18 ` Drew Adams
0 siblings, 1 reply; 5+ messages in thread
From: Kevin Rodgers @ 2010-02-24 4:29 UTC (permalink / raw)
To: help-gnu-emacs
Drew Adams wrote:
>> A read-only buffer has a major mode which defines bindings for RET and
>> other keys which are also used by button widgets created by
>>
>> (widget-create 'push-button ...
>>
>> The bindings for the major mode override the button bindings
>> (it is not possible to user RET when the point is on the
>> button for invoking it). I can make the button work with
>> (use-local-map widget-keymap), but then the bindings for
>> the major mode are gone.
>>
>> Is there a way for RET invoking the button when the point is
>> over it and invoke the major mode binding otherwise?
>>
>> Using Emacs 23.1.
>
> `keymap' text property would be one way.
>
> See node `Special Properties' of the Elisp manual.
WIBNI widget-create took a :keymap keyword so you could specify
widget-keymap as its value?
Otherwise, I guess you have to do something like:
(let* ((push-button (widget-create 'push-button ...))
(button-overlay (widget-get push-button :button-overlay)))
(overlay-put button-overlay 'keymap widget-keymap))
Or maybe local-map would be the appropriate property for this purpose.
--
Kevin Rodgers
Denver, Colorado, USA
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: Button widget keymap conflicting with major mode.
2010-02-24 4:29 ` Kevin Rodgers
@ 2010-02-24 5:18 ` Drew Adams
2010-02-26 7:41 ` Kevin Rodgers
0 siblings, 1 reply; 5+ messages in thread
From: Drew Adams @ 2010-02-24 5:18 UTC (permalink / raw)
To: 'Kevin Rodgers', help-gnu-emacs
> WIBNI widget-create took a :keymap keyword so you could specify
> widget-keymap as its value?
It does, doesn't it? You can pass any keyword args to it.
Not sure I understand what you're saying.
(widget-create 'push-button :keymap widget-keymap) `C-x C-e'
=>
(push-button
:keymap
(keymap
(13 . widget-button-press)
(down-mouse-1 . widget-button-click)
(down-mouse-2 . widget-button-click)
(backtab . widget-backward)
(S-tab . widget-backward)
(27 keymap (9 . widget-backward))
(9 . widget-forward))
:button-overlay #<overlay from 242 to 244 in *scratch*> :from #<marker
(moves after insertion)
at 242 in *scratch*> :to #<marker at 244 in *scratch*>)
`C-u C-x =' on the button (e.g. position 243) shows:
There is an overlay here:
From 242 to 244
button push-button (widget)Top
evaporate t
face widget-button
follow-link nil
help-echo nil
keymap [Show]
mouse-face (highlight)
pointer hand
Clicking [Show] or hitting RET there shows the same keymap as above.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Button widget keymap conflicting with major mode.
2010-02-24 5:18 ` Drew Adams
@ 2010-02-26 7:41 ` Kevin Rodgers
0 siblings, 0 replies; 5+ messages in thread
From: Kevin Rodgers @ 2010-02-26 7:41 UTC (permalink / raw)
To: help-gnu-emacs
Drew Adams wrote:
>> WIBNI widget-create took a :keymap keyword so you could specify
>> widget-keymap as its value?
>
> It does, doesn't it? You can pass any keyword args to it.
Excellent, I didn't try...
> Not sure I understand what you're saying.
... because the Widget info manual doesn't say that the push-button
widget is/like an editable-field or text widget, which are the only
types that support the :keymap property.
> (widget-create 'push-button :keymap widget-keymap) `C-x C-e'
>
> =>
>
> (push-button
> :keymap
> (keymap
> (13 . widget-button-press)
> (down-mouse-1 . widget-button-click)
> (down-mouse-2 . widget-button-click)
> (backtab . widget-backward)
> (S-tab . widget-backward)
> (27 keymap (9 . widget-backward))
> (9 . widget-forward))
> :button-overlay #<overlay from 242 to 244 in *scratch*> :from #<marker
> (moves after insertion)
> at 242 in *scratch*> :to #<marker at 244 in *scratch*>)
>
> `C-u C-x =' on the button (e.g. position 243) shows:
>
> There is an overlay here:
> From 242 to 244
> button push-button (widget)Top
> evaporate t
> face widget-button
> follow-link nil
> help-echo nil
> keymap [Show]
> mouse-face (highlight)
> pointer hand
>
> Clicking [Show] or hitting RET there shows the same keymap as above.
Well, that's the clincher: the keymap was actually installed on the keymap
property of the overlay (not just included in the widget's list representation).
--
Kevin Rodgers
Denver, Colorado, USA
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-02-26 7:41 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-21 4:07 Button widget keymap conflicting with major mode Óscar Fuentes
2010-02-21 5:54 ` Drew Adams
2010-02-24 4:29 ` Kevin Rodgers
2010-02-24 5:18 ` Drew Adams
2010-02-26 7:41 ` Kevin Rodgers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).