all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Problems binding odd C- & M-keys in Elisp
@ 2006-03-09  1:25 Joe Fineman
  2006-03-09  2:15 ` Katsumi Yamaoka
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Joe Fineman @ 2006-03-09  1:25 UTC (permalink / raw)


I can bind commands to the following odd combinations using M-x
global-set-key, but I cannot figure out how to express the same
bindings in Elisp for inclusion in .emacs:

C-; ("\C-\;" gives "Invalid modifier in string")
C-<tab> ("\C-\t" gives the same)
M-<left>
M-<up>

What am I missing?
-- 
---  Joe Fineman    joe_f@verizon.net

||:  Vulgarity is the garlic in the salad of taste.  :||

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Problems binding odd C- & M-keys in Elisp
  2006-03-09  1:25 Problems binding odd C- & M-keys in Elisp Joe Fineman
@ 2006-03-09  2:15 ` Katsumi Yamaoka
  2006-03-09  8:08 ` Alan Mackenzie
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Katsumi Yamaoka @ 2006-03-09  2:15 UTC (permalink / raw)


>>>>> In <ufylsif3h.fsf@verizon.net> Joe Fineman wrote:

> I can bind commands to the following odd combinations using M-x
> global-set-key, but I cannot figure out how to express the same
> bindings in Elisp for inclusion in .emacs:

> C-; ("\C-\;" gives "Invalid modifier in string")
> C-<tab> ("\C-\t" gives the same)
> M-<left>
> M-<up>

You can use:

(global-set-key [(control ?\;)] 'COMMAND)
(global-set-key [(control tab)] 'COMMAND)
(global-set-key [(meta left)] 'COMMAND)
(global-set-key [(meta up)] 'COMMAND)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Problems binding odd C- & M-keys in Elisp
  2006-03-09  1:25 Problems binding odd C- & M-keys in Elisp Joe Fineman
  2006-03-09  2:15 ` Katsumi Yamaoka
@ 2006-03-09  8:08 ` Alan Mackenzie
  2006-03-09 10:30 ` Peter Dyballa
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Alan Mackenzie @ 2006-03-09  8:08 UTC (permalink / raw)


Joe Fineman <joe_f@verizon.net> wrote on Thu, 09 Mar 2006 01:25:36 GMT:
> I can bind commands to the following odd combinations using M-x
> global-set-key, but I cannot figure out how to express the same
> bindings in Elisp for inclusion in .emacs:

> C-; ("\C-\;" gives "Invalid modifier in string")
> C-<tab> ("\C-\t" gives the same)
> M-<left>
> M-<up>

> What am I missing?

Probably comprehensive and clear documentation.  However, as a
workaround, do M-x global-set-key, then C-x <esc> <esc>.  This will give
you a working Lisp form to stick into your .emacs.

> ---  Joe Fineman

-- 
Alan Mackenzie (Munich, Germany)
Email: aacm@muuc.dee; to decode, wherever there is a repeated letter
(like "aa"), remove half of them (leaving, say, "a").

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Problems binding odd C- & M-keys in Elisp
  2006-03-09  1:25 Problems binding odd C- & M-keys in Elisp Joe Fineman
  2006-03-09  2:15 ` Katsumi Yamaoka
  2006-03-09  8:08 ` Alan Mackenzie
@ 2006-03-09 10:30 ` Peter Dyballa
  2006-03-09 17:52 ` Kevin Rodgers
  2006-03-10  1:36 ` Joe Fineman
  4 siblings, 0 replies; 7+ messages in thread
From: Peter Dyballa @ 2006-03-09 10:30 UTC (permalink / raw)
  Cc: help-gnu-emacs


Am 09.03.2006 um 01:25 schrieb Joe Fineman:

> What am I missing?

Practise.

Bind your key interactively. Then repeat this last command without  
executing it but writing it into .emacs:

	C-x Esc Esc C-a C-k C-g C-x f ~/.emacs RET C-y RET C-x C-s


Since I know this procedure already by heart: couldn't someone put a  
function 'put-last-interactive-key-binding-into-dot-emacs' into the  
GNU Emacs code?! It could reduce traffic on this list by 1%.

--
Greetings

   Pete

The most exciting phrase to hear in science, the one that heralds new  
discoveries, is not "Eureka!" (I found it!) but "That's  
funny..." [Isaac Asimov]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Problems binding odd C- & M-keys in Elisp
  2006-03-09  1:25 Problems binding odd C- & M-keys in Elisp Joe Fineman
                   ` (2 preceding siblings ...)
  2006-03-09 10:30 ` Peter Dyballa
@ 2006-03-09 17:52 ` Kevin Rodgers
  2006-03-10 21:55   ` Kevin Rodgers
  2006-03-10  1:36 ` Joe Fineman
  4 siblings, 1 reply; 7+ messages in thread
From: Kevin Rodgers @ 2006-03-09 17:52 UTC (permalink / raw)


Joe Fineman wrote:
> I can bind commands to the following odd combinations using M-x
> global-set-key, but I cannot figure out how to express the same
> bindings in Elisp for inclusion in .emacs:
> 
> C-; ("\C-\;" gives "Invalid modifier in string")
> C-<tab> ("\C-\t" gives the same)
> M-<left>
> M-<up>
> 
> What am I missing?

The [Customizing] Key Bindings node of the Emacs manual has a subnode
called Init Rebinding (aka Rebinding Keys in Your Init File), which
explains that non-ASCII characters such as `C-;' and `C-TAB' must be
represented using the more general vector (vs. string) notation:
[?\C-;] and [?\C-\t]
[M-left] and [M-up]

Note that since <left> and <up> are function keys, not characters,
M-<left> and M-<right> are modified function keys, not characters.

The Changing Key Bindings node of the Emacs Lisp manual describes an
alternate syntax: '(control ?;) and '(control ?\t) or '(control tab)
'(meta left) and '(meta up)

Finally, there is the kbd function: (kbd "C-;") and (kbd "C-TAB")
(kbd "M-<left>") and (kbd "M-<up>")

-- 
Kevin Rodgers

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Problems binding odd C- & M-keys in Elisp
  2006-03-09  1:25 Problems binding odd C- & M-keys in Elisp Joe Fineman
                   ` (3 preceding siblings ...)
  2006-03-09 17:52 ` Kevin Rodgers
@ 2006-03-10  1:36 ` Joe Fineman
  4 siblings, 0 replies; 7+ messages in thread
From: Joe Fineman @ 2006-03-10  1:36 UTC (permalink / raw)


Thanks to all of you who informed me of various solutions.
-- 
---  Joe Fineman    joe_f@verizon.net

||:  Young fool, old foolishness.  :||

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Problems binding odd C- & M-keys in Elisp
  2006-03-09 17:52 ` Kevin Rodgers
@ 2006-03-10 21:55   ` Kevin Rodgers
  0 siblings, 0 replies; 7+ messages in thread
From: Kevin Rodgers @ 2006-03-10 21:55 UTC (permalink / raw)


My first reply could have been formatted a little more clearly, and as
Katsumi Yamaoka pointed out the semicolon should generally be escaped in
Emacs Lisp:

The [Customizing] Key Bindings node of the Emacs manual has a subnode
called Init Rebinding (aka Rebinding Keys in Your Init File), which
explains that non-ASCII characters such as `C-;' and `C-TAB' must be
represented using the more general vector (vs. string) notation:

[?\C-\;] and [?\C-\t]

Since <left> and <up> are function keys, not characters,
M-<left> and M-<right> are modified function keys (not characters):

[M-left] and [M-up]

The Changing Key Bindings node of the Emacs Lisp manual describes an
alternate syntax:

'(control ?\;) and '(control ?\t) or '(control tab)
'(meta left) and '(meta up)

Finally, there is the kbd function:

(kbd "C-\;") and (kbd "C-TAB")
(kbd "M-<left>") and (kbd "M-<up>")

-- 
Kevin Rodgers

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2006-03-10 21:55 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-09  1:25 Problems binding odd C- & M-keys in Elisp Joe Fineman
2006-03-09  2:15 ` Katsumi Yamaoka
2006-03-09  8:08 ` Alan Mackenzie
2006-03-09 10:30 ` Peter Dyballa
2006-03-09 17:52 ` Kevin Rodgers
2006-03-10 21:55   ` Kevin Rodgers
2006-03-10  1:36 ` Joe Fineman

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.