* identifying meta-key bound functions from last-command-char?
@ 2008-02-26 0:30 Ken Manheimer
2008-02-26 2:07 ` Stefan Monnier
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: Ken Manheimer @ 2008-02-26 0:30 UTC (permalink / raw)
To: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 1223 bytes --]
in a recent emacs build a technique i've been using to deliberately fetch
key bindings according to the last-command-char is failing for meta-modified
keys. the problem is that, for meta-modified keys,
(characterp last-command-char) => nil
this breaks an approach like:
(key-binding (char-to-string last-command-char))
i need some way to fetch bindings according to last-command-char for a
special key handler that i use in overlays and, (for example) in
allout.elallout-hotspot-key-handler, a pre-command-hook function.
though probably
overly complicated, it has worked through the released emacs 22. in the
recent cvs build (23.0.60), i get an error:
wrong-type-argument characterp 134217760
(that's for "\M- " meta space, but the same things happens for other meta
keys.) i'm failing to figure out how to translate the meta-modified key to
something that i can use for key-binding, and presume i'm missing something
obvious. can someone steer me in the right direction?
(incidentally, i've been unable to build todays HEAD checkout throughout
the day:
doc-view.el:770:43:Error: Wrong number of arguments: #[nil "\300\207"
[(image-mode-window-get (quote page))] 1], 1
)
--
ken
http://myriadicity.net
[-- Attachment #2: Type: text/html, Size: 1439 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: identifying meta-key bound functions from last-command-char?
2008-02-26 0:30 identifying meta-key bound functions from last-command-char? Ken Manheimer
@ 2008-02-26 2:07 ` Stefan Monnier
2008-02-26 2:21 ` Kenichi Handa
2008-02-26 6:08 ` Miles Bader
2 siblings, 0 replies; 11+ messages in thread
From: Stefan Monnier @ 2008-02-26 2:07 UTC (permalink / raw)
To: Ken Manheimer; +Cc: emacs-devel
> this breaks an approach like:
> (key-binding (char-to-string last-command-char))
Try (key-binding (vector last-command-char))
Stefan
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: identifying meta-key bound functions from last-command-char?
2008-02-26 0:30 identifying meta-key bound functions from last-command-char? Ken Manheimer
2008-02-26 2:07 ` Stefan Monnier
@ 2008-02-26 2:21 ` Kenichi Handa
2008-02-26 2:33 ` Stefan Monnier
2008-02-26 6:08 ` Miles Bader
2 siblings, 1 reply; 11+ messages in thread
From: Kenichi Handa @ 2008-02-26 2:21 UTC (permalink / raw)
To: Ken Manheimer; +Cc: emacs-devel
In article <2cd46e7f0802251630h2cc2ae5di1d77ed3b87611416@mail.gmail.com>, "Ken Manheimer" <ken.manheimer@gmail.com> writes:
> [1 <text/plain; ISO-8859-1 (7bit)>]
> in a recent emacs build a technique i've been using to deliberately fetch
> key bindings according to the last-command-char is failing for meta-modified
> keys. the problem is that, for meta-modified keys,
> (characterp last-command-char) => nil
> this breaks an approach like:
> (key-binding (char-to-string last-command-char))
> i need some way to fetch bindings according to last-command-char for a
> special key handler that i use in overlays and, (for example) in
> allout.elallout-hotspot-key-handler, a pre-command-hook function.
> though probably
> overly complicated, it has worked through the released emacs 22. in the
> recent cvs build (23.0.60), i get an error:
> wrong-type-argument characterp 134217760
> (that's for "\M- " meta space, but the same things happens for other meta
> keys.) i'm failing to figure out how to translate the meta-modified key to
> something that i can use for key-binding, and presume i'm missing something
> obvious. can someone steer me in the right direction?
Unfortunately, I think Emacs doesn't have a clear view about
how to handle an integer which contains a character code and
meta-modifier masks. Is it a character or not?
I think it's not a character but an event object, so the
above code should be:
(key-binding (vector last-command-char))
The related problem is when to change, for instance, (' ' |
CTRL_MASK) to '\0'. Now Emacs signals an error when we type
C-q C-SPC.
---
Kenichi Handa
handa@ni.aist.go.jp
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: identifying meta-key bound functions from last-command-char?
2008-02-26 2:21 ` Kenichi Handa
@ 2008-02-26 2:33 ` Stefan Monnier
2008-02-26 3:59 ` Kenichi Handa
0 siblings, 1 reply; 11+ messages in thread
From: Stefan Monnier @ 2008-02-26 2:33 UTC (permalink / raw)
To: Kenichi Handa; +Cc: Ken Manheimer, emacs-devel
> The related problem is when to change, for instance, (' ' |
> CTRL_MASK) to '\0'.
Traditionally Emacs has mapped CTRL_MASK + CHAR to the corresponding
ASCII control char, if it exists. Looks like this mapping is now
missing somewhere.
It's not like this mapping is clear: e.g. the distinction between C-a
and C-A.
Stefan
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: identifying meta-key bound functions from last-command-char?
2008-02-26 2:33 ` Stefan Monnier
@ 2008-02-26 3:59 ` Kenichi Handa
2008-02-26 4:46 ` Stefan Monnier
0 siblings, 1 reply; 11+ messages in thread
From: Kenichi Handa @ 2008-02-26 3:59 UTC (permalink / raw)
To: Stefan Monnier; +Cc: ken.manheimer, emacs-devel
In article <jwvhcfwih53.fsf-monnier+emacs@gnu.org>, Stefan Monnier <monnier@iro.umontreal.ca> writes:
> > The related problem is when to change, for instance, (' ' |
> > CTRL_MASK) to '\0'.
> Traditionally Emacs has mapped CTRL_MASK + CHAR to the corresponding
> ASCII control char, if it exists. Looks like this mapping is now
> missing somewhere.
The routine doing that mapping still exists; char_string().
But, before reaching that function, the macro
CHECK_CHARACTER rejects such an integer value.
Should we implement something like
CHECK_CHARACTER_RESOLVE_MODIFER and use it instead of
CHECK_CHARACTER at proper places?
---
Kenichi Handa
handa@ni.aist.go.jp
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: identifying meta-key bound functions from last-command-char?
2008-02-26 3:59 ` Kenichi Handa
@ 2008-02-26 4:46 ` Stefan Monnier
0 siblings, 0 replies; 11+ messages in thread
From: Stefan Monnier @ 2008-02-26 4:46 UTC (permalink / raw)
To: Kenichi Handa; +Cc: ken.manheimer, emacs-devel
>> > The related problem is when to change, for instance, (' ' |
>> > CTRL_MASK) to '\0'.
>> Traditionally Emacs has mapped CTRL_MASK + CHAR to the corresponding
>> ASCII control char, if it exists. Looks like this mapping is now
>> missing somewhere.
> The routine doing that mapping still exists; char_string().
The question is: where is it called from and is there a place where it
should be called but isn't (or is, but too late)?
> But, before reaching that function, the macro
> CHECK_CHARACTER rejects such an integer value.
> Should we implement something like
> CHECK_CHARACTER_RESOLVE_MODIFER and use it instead of
> CHECK_CHARACTER at proper places?
Maybe, or rather move the CHECK_CHARACTER to some later time when the
mapping has taken place.
Stefan
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: identifying meta-key bound functions from last-command-char?
2008-02-26 0:30 identifying meta-key bound functions from last-command-char? Ken Manheimer
2008-02-26 2:07 ` Stefan Monnier
2008-02-26 2:21 ` Kenichi Handa
@ 2008-02-26 6:08 ` Miles Bader
2008-02-26 6:28 ` Ken Manheimer
2 siblings, 1 reply; 11+ messages in thread
From: Miles Bader @ 2008-02-26 6:08 UTC (permalink / raw)
To: Ken Manheimer; +Cc: emacs-devel
"Ken Manheimer" <ken.manheimer@gmail.com> writes:
> the problem is that, for meta-modified keys,
>
> (characterp last-command-char) => nil
>
> this breaks an approach like:
>
> (key-binding (char-to-string last-command-char))
It wants a vector, so give it a vector:
(key-binding (vector last-command-char))
-Miles
--
Discriminate, v.i. To note the particulars in which one person or thing is,
if possible, more objectionable than another.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: identifying meta-key bound functions from last-command-char?
2008-02-26 6:08 ` Miles Bader
@ 2008-02-26 6:28 ` Ken Manheimer
2008-02-26 15:13 ` Stefan Monnier
0 siblings, 1 reply; 11+ messages in thread
From: Ken Manheimer @ 2008-02-26 6:28 UTC (permalink / raw)
To: Miles Bader; +Cc: emacs-devel
using 'vector' instead of char-to-string solved my problem - thanks, all!
--
ken
http://myriadicity.net
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: identifying meta-key bound functions from last-command-char?
2008-02-26 6:28 ` Ken Manheimer
@ 2008-02-26 15:13 ` Stefan Monnier
2008-02-26 22:57 ` Ken Manheimer
0 siblings, 1 reply; 11+ messages in thread
From: Stefan Monnier @ 2008-02-26 15:13 UTC (permalink / raw)
To: Ken Manheimer; +Cc: emacs-devel, Miles Bader
> using 'vector' instead of char-to-string solved my problem - thanks, all!
Using strings for "sequence of events" is a hack that happened to work
back in the tty days and was made obsolete (tho sadly still supported)
when X11 support was added.
Stefan
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: identifying meta-key bound functions from last-command-char?
2008-02-26 15:13 ` Stefan Monnier
@ 2008-02-26 22:57 ` Ken Manheimer
2008-02-27 2:10 ` Stefan Monnier
0 siblings, 1 reply; 11+ messages in thread
From: Ken Manheimer @ 2008-02-26 22:57 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel, Miles Bader
On 2/26/08, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
> > using 'vector' instead of char-to-string solved my problem - thanks, all!
>
> Using strings for "sequence of events" is a hack that happened to work
> back in the tty days and was made obsolete (tho sadly still supported)
> when X11 support was added.
the closest lead i found in the elisp info manual was 21.6.14 _Putting
Keyboard Events in Strings_, and it distinctly does not address my
need. i think the details are missing from the manual, and that could
be repaired.
as i see it, the purpose is not too obscure or unusual: deliberately
identifying a key binding for user-entered keys from within a handler
that's intervening in the command loop, eg, on pre-command-hook,
overlay modification-hooks, or something like that. last-command-char
/ last-command-event is the only data structure i found for getting
the input, and the only details about using that are very brief, in
21.4, _Information from the Command Loop_.
i expect that the details - using `(keyboard-binding (vector
last-command-char))' - belong somewhere in the 21.6 _Input Events_
section, perhaps in 21.6.1 _Keyboard Events_? there could then be a
footnote / link from 21.6.14 _Putting Keyboard Events in Strings_ and
the entry for last-command-char / -event in 21.4.
the text could go below what currently exists in 21.6.1. i don't have
enough grasp of input events to be complete, but here's a description
of the context i do know:
To handle command-loop input from a hook function, like a pre-command-hook
or modification-hooks entry, you can get the input event from
last-command-event
(see _Keyboard Events_). You can identify a keybinding for that input using:
``(keyboard-binding (vector last-command-event))''
can anyone help flesh this out? i would have spent a lot less time
thrashing if the info were easier to find. (it still may make sense
to repair char-to-string, though.)
--
ken
http://myriadicity.net
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: identifying meta-key bound functions from last-command-char?
2008-02-26 22:57 ` Ken Manheimer
@ 2008-02-27 2:10 ` Stefan Monnier
0 siblings, 0 replies; 11+ messages in thread
From: Stefan Monnier @ 2008-02-27 2:10 UTC (permalink / raw)
To: Ken Manheimer; +Cc: Miles Bader, emacs-devel
> as i see it, the purpose is not too obscure or unusual: deliberately
> identifying a key binding for user-entered keys from within a handler
> that's intervening in the command loop, eg, on pre-command-hook,
> overlay modification-hooks, or something like that. last-command-char
> / last-command-event is the only data structure i found for getting
> the input, and the only details about using that are very brief, in
> 21.4, _Information from the Command Loop_.
So maybe you'd rather use (key-binding (this-command-keys-vector)) so it
also works for commands bound to multi-key sequences.
Stefan
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2008-02-27 2:10 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-26 0:30 identifying meta-key bound functions from last-command-char? Ken Manheimer
2008-02-26 2:07 ` Stefan Monnier
2008-02-26 2:21 ` Kenichi Handa
2008-02-26 2:33 ` Stefan Monnier
2008-02-26 3:59 ` Kenichi Handa
2008-02-26 4:46 ` Stefan Monnier
2008-02-26 6:08 ` Miles Bader
2008-02-26 6:28 ` Ken Manheimer
2008-02-26 15:13 ` Stefan Monnier
2008-02-26 22:57 ` Ken Manheimer
2008-02-27 2:10 ` Stefan Monnier
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.