* Re: How to bind the same function to different keys with different behaviours?
2016-01-13 12:55 How to bind the same function to different keys with different behaviours? sokobania.01
@ 2016-01-13 12:53 ` tomas
[not found] ` <mailman.2277.1452691703.843.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 3+ messages in thread
From: tomas @ 2016-01-13 12:53 UTC (permalink / raw)
To: help-gnu-emacs
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Wed, Jan 13, 2016 at 04:55:40AM -0800, sokobania.01@gmail.com wrote:
> In the basic modemap, the ascii keys are bound to `self-insert-command'.
> As it is not an emacs-lisp function, I cannot "copy" its code.
>
> I want to bind the keys [A-Z] to `my-self-insert-command' with something like:
> (for key from ?A to ?Z do
> (bind-key my-mode-map key 'my-self-insert-command))
>
> This function kind of inserts the current key pressed under some conditions.
>
> So far, I don't know how to get acces to the current key pressed from within `my-self-insert-command'.
>
> Is this possible?
>
>
> If it is not possible, I'll do something like:
>
> (for key from ?A to ?Z do
> (bind-key my-mode-map key (lambda () (my-self-insert-command key))))
self-insert-command can do it -- so can you, then :-)
To find out (it helps to have the Emacs sources around, you do `C-h f'
self-insert-command, and Emacs tells you:
"self-insert-command is an interactive built-in function in `C source
code'.
It is bound to many ordinary text characters.
[...]"
The `C source code' above is a link, and if you have the Emacs sources
around, it'll take you to the relevant C function. There you see that
it references some variable `last_command_event'.
Lo and behold, Elisp has a corresponding variable `last-command-event'
where you can look up what triggered you `my-self-insert-command'
Hope this gives you a pointer to play with.
Regards
- -- t
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
iEYEARECAAYFAlaWSM4ACgkQBcgs9XrR2kYE9ACfXJjyH/ywu6THAYaXF660c7fd
+2AAmgMHhyXb5LuE9hgGGMOlbiUS2XwO
=X/1y
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 3+ messages in thread
* How to bind the same function to different keys with different behaviours?
@ 2016-01-13 12:55 sokobania.01
2016-01-13 12:53 ` tomas
[not found] ` <mailman.2277.1452691703.843.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 3+ messages in thread
From: sokobania.01 @ 2016-01-13 12:55 UTC (permalink / raw)
To: help-gnu-emacs
In the basic modemap, the ascii keys are bound to `self-insert-command'.
As it is not an emacs-lisp function, I cannot "copy" its code.
I want to bind the keys [A-Z] to `my-self-insert-command' with something like:
(for key from ?A to ?Z do
(bind-key my-mode-map key 'my-self-insert-command))
This function kind of inserts the current key pressed under some conditions.
So far, I don't know how to get acces to the current key pressed from within `my-self-insert-command'.
Is this possible?
If it is not possible, I'll do something like:
(for key from ?A to ?Z do
(bind-key my-mode-map key (lambda () (my-self-insert-command key))))
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: How to bind the same function to different keys with different behaviours?
[not found] ` <mailman.2277.1452691703.843.help-gnu-emacs@gnu.org>
@ 2016-01-13 14:01 ` sokobania.01
0 siblings, 0 replies; 3+ messages in thread
From: sokobania.01 @ 2016-01-13 14:01 UTC (permalink / raw)
To: help-gnu-emacs
Le mercredi 13 janvier 2016 14:28:27 UTC+1, to...@tuxteam.de a écrit :
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On Wed, Jan 13, 2016 at 04:55:40AM -0800, I wrote:
> > In the basic modemap, the ascii keys are bound to `self-insert-command'.
> > As it is not an emacs-lisp function, I cannot "copy" its code.
> >
> > I want to bind the keys [A-Z] to `my-self-insert-command' with something like:
> > (for key from ?A to ?Z do
> > (bind-key my-mode-map key 'my-self-insert-command))
> >
> > This function kind of inserts the current key pressed under some conditions.
> >
> > So far, I don't know how to get acces to the current key pressed from within `my-self-insert-command'.
> >
> > Is this possible?
> >
> >
> > If it is not possible, I'll do something like:
> >
> > (for key from ?A to ?Z do
> > (bind-key my-mode-map key (lambda () (my-self-insert-command key))))
>
> self-insert-command can do it -- so can you, then :-)
>
> To find out (it helps to have the Emacs sources around, you do `C-h f'
> self-insert-command, and Emacs tells you:
>
> "self-insert-command is an interactive built-in function in `C source
> code'.
>
> It is bound to many ordinary text characters.
> [...]"
>
> The `C source code' above is a link, and if you have the Emacs sources
> around, it'll take you to the relevant C function. There you see that
> it references some variable `last_command_event'.
>
> Lo and behold, Elisp has a corresponding variable `last-command-event'
> where you can look up what triggered you `my-self-insert-command'
Exactly what I was looking for!
As I rarely download emacs sources, I would not have found it!
Thanks a lot!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-01-13 14:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-13 12:55 How to bind the same function to different keys with different behaviours? sokobania.01
2016-01-13 12:53 ` tomas
[not found] ` <mailman.2277.1452691703.843.help-gnu-emacs@gnu.org>
2016-01-13 14:01 ` sokobania.01
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.