* Cannot use "\C-!" in a string in Emacs 22?
@ 2005-09-26 18:56 Drew Adams
2005-09-26 19:44 ` Stefan Monnier
2005-09-26 20:50 ` Edward O'Connor
0 siblings, 2 replies; 4+ messages in thread
From: Drew Adams @ 2005-09-26 18:56 UTC (permalink / raw)
I'm interested in a key-binding syntax that works with Emacs 20 through 22
(for those bindings that are acceptable to all of those versions). The (kbd
...) syntax, for instance, doesn't work with earlier Emacsen, so that choice
is out, for me.
I tried (define-key my-map "\C-!" 'my-cmd), which works in Emacs 20, but
gives this error in Emacs 22: "Invalid modifier in string". Based on the
error message, which speaks of strings, not key bindings, I tried (setq foo
"\C-!"), which gives the same error - so I guess it's a string-syntax
problem, not a key-binding syntax problem.
Is it normal that this was broken in moving to Emacs 22 (or 21)? Where is
the explanation of this in the Elisp manual (I looked in section Strings and
Characters and in the keybinding discussions).
Anyway, for the key binding, I settled on (define-key my-map [C-!] 'my-cmd),
after some experimentation - it seems to work for key bindings in both
versions.
I admit that I'm confused about the various key-binding syntaxes. I've
consulted the manual, but, except for (kbd...), I don't see a universal
syntax to use for all key sequences, and (kbd...) is not usable with Emacs
20. I somehow seem to always end up with collections of "\modifier-key",
[(modifier fn-key)], and [modifier-key]. I'm probably just not reading the
doc correctly, but I'd appreciate some light on the question.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Cannot use "\C-!" in a string in Emacs 22?
2005-09-26 18:56 Cannot use "\C-!" in a string in Emacs 22? Drew Adams
@ 2005-09-26 19:44 ` Stefan Monnier
2005-09-26 20:28 ` Drew Adams
2005-09-26 20:50 ` Edward O'Connor
1 sibling, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2005-09-26 19:44 UTC (permalink / raw)
Cc: Emacs-Devel
> I tried (define-key my-map "\C-!" 'my-cmd), which works in Emacs 20, but
> gives this error in Emacs 22: "Invalid modifier in string".
It worked under Emacs-20, but returned the same as "\C-a", i.e. probably not
what you intended. In Emacs-21 this was fixed to return an error rather
than silently turning it into somwething else.
> Anyway, for the key binding, I settled on (define-key my-map [C-!] 'my-cmd),
> after some experimentation - it seems to work for key bindings in both
> versions.
I'd expect it doesn't really work. It won't signal an error, but it won't
cause my-cmd to be run when you hit control and !. You probably meant to
use (define-key my-map [?\C-!] 'my-cmd) which should work. I'd recommend
(define-key my-map [(control ?!)] 'my-cmd)
which will also work under XEmacs.
Stefan
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: Cannot use "\C-!" in a string in Emacs 22?
2005-09-26 19:44 ` Stefan Monnier
@ 2005-09-26 20:28 ` Drew Adams
0 siblings, 0 replies; 4+ messages in thread
From: Drew Adams @ 2005-09-26 20:28 UTC (permalink / raw)
> (define-key my-map "\C-!" 'my-cmd), which works in Emacs 20, but
> gives this error in Emacs 22: "Invalid modifier in string".
It worked under Emacs-20, but returned the same as "\C-a"
Thanks.
In Emacs-21 this was fixed to return an error
> I settled on (define-key my-map [C-!] 'my-cmd) - it seems to
> work for key bindings in both versions.
You probably meant to use (define-key my-map [?\C-!] 'my-cmd)
That's what I meant. Sorry for the typo.
I'd recommend (define-key my-map [(control ?!)] 'my-cmd)
OK. Thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Cannot use "\C-!" in a string in Emacs 22?
2005-09-26 18:56 Cannot use "\C-!" in a string in Emacs 22? Drew Adams
2005-09-26 19:44 ` Stefan Monnier
@ 2005-09-26 20:50 ` Edward O'Connor
1 sibling, 0 replies; 4+ messages in thread
From: Edward O'Connor @ 2005-09-26 20:50 UTC (permalink / raw)
> The (kbd ...) syntax, for instance, doesn't work with earlier
> Emacsen[...]
But it does! For many years I kept the (one-liner) defmacro of `kbd' in
my .emacs file, so that I could use `kbd' syntax under Emacs 19, and it
worked just fine.
Ted
--
Edward O'Connor
hober0@gmail.com
Ense petit placidam sub libertate quietem.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2005-09-26 20:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-26 18:56 Cannot use "\C-!" in a string in Emacs 22? Drew Adams
2005-09-26 19:44 ` Stefan Monnier
2005-09-26 20:28 ` Drew Adams
2005-09-26 20:50 ` Edward O'Connor
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.