* Binding same command to two separte keys??
@ 2007-04-13 19:02 William Case
2007-04-13 19:12 ` Karl Hegbloom
0 siblings, 1 reply; 14+ messages in thread
From: William Case @ 2007-04-13 19:02 UTC (permalink / raw)
To: EMACS List
Hi;
I have set (global-set-key [(M-s)] 'shell-command) in my .emacs.
I also want to keep the M-! shell-command binding
Nothing happens when I use M-s, nor do I get an error message.
C-h k says M-s is undefined yet,
C-h w says shell-command is on <M-s>, M-!, <menu-bar> etc...
I have read < > means a symbolic key like F3. What does <M-s> mean and
what have I done wrong?
--
Regards Bill
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Binding same command to two separte keys??
2007-04-13 19:02 Binding same command to two separte keys?? William Case
@ 2007-04-13 19:12 ` Karl Hegbloom
2007-04-13 19:17 ` Matthew Flaschen
0 siblings, 1 reply; 14+ messages in thread
From: Karl Hegbloom @ 2007-04-13 19:12 UTC (permalink / raw)
To: William Case; +Cc: EMACS List
On Fri, 2007-04-13 at 15:02 -0400, William Case wrote:
> I have set (global-set-key [(M-s)] 'shell-command) in my .emacs.
> I also want to keep the M-! shell-command binding
>
> Nothing happens when I use M-s, nor do I get an error message.
I think that the syntax of the expression describing the key is
incorrect. Try looking at the documentation of the `kbd' macro (F1 f
kbd). You can use it there, like:
(global-set-key (kbd "M-s") #'shell-command)
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Binding same command to two separte keys??
2007-04-13 19:12 ` Karl Hegbloom
@ 2007-04-13 19:17 ` Matthew Flaschen
2007-04-13 20:17 ` William Case
` (3 more replies)
0 siblings, 4 replies; 14+ messages in thread
From: Matthew Flaschen @ 2007-04-13 19:17 UTC (permalink / raw)
To: emacs
Karl Hegbloom wrote:
> On Fri, 2007-04-13 at 15:02 -0400, William Case wrote:
>> I have set (global-set-key [(M-s)] 'shell-command) in my .emacs.
>> I also want to keep the M-! shell-command binding
>>
>> Nothing happens when I use M-s, nor do I get an error message.
>
> I think that the syntax of the expression describing the key is
> incorrect.
The correct syntax is:
[?\M-s]
Try looking at the documentation of the `kbd' macro (F1 f
> kbd). You can use it there, like:
>
> (global-set-key (kbd "M-s") #'shell-command)
There's no need for kbd here. It's unnecessary overhead.
Matt Flaschen
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Binding same command to two separte keys??
2007-04-13 19:17 ` Matthew Flaschen
@ 2007-04-13 20:17 ` William Case
2007-04-13 21:04 ` Matthew Flaschen
[not found] ` <mailman.2052.1176495874.7795.help-gnu-emacs@gnu.org>
` (2 subsequent siblings)
3 siblings, 1 reply; 14+ messages in thread
From: William Case @ 2007-04-13 20:17 UTC (permalink / raw)
To: Matthew Flaschen; +Cc: emacs
Ok guys, now I am really totally confused.
I have been using emacs for 2 years. I have read the Wiki, printed out
the tiny-tools site and read and re-read the info pages.
Over the last 2 years I have written about 10 keybinding functions, that
are in my .emacs, and that I use all the time. They have always been in
the form of (global-set-key [(M-s)] 'shell-command). Now 'kbd' shows
up, and '?\' to replace it. And, whats a #' for, that replaces the
single '.
I just want to get consistent. I plan to do a fair amount of work with
emacs shortly. Up to now I haven't worried much because I used my emacs
21.4 only for trivial text editing.
So ... in (global-set-key (kbd "M-s") #'shell-command)
Does ?\ = kbd ?
Does [ ] replace ( ) ?
Are the " " necessary or not necessary ?
Does the # have a special meaning or is it always used now?
Where do I find the kbd documentation that I already haven't looked at?
Do symbols like F3 still require < > ?
What syntax would work for both standard emacs functions and my own user
functions?
Emacs 22 is going to show up when I upgrade to Fedora 7. Is keybinding
going to be different again?
On Fri, 2007-04-13 at 15:17 -0400, Matthew Flaschen wrote:
> Karl Hegbloom wrote:
> > On Fri, 2007-04-13 at 15:02 -0400, William Case wrote:
> >> I have set (global-set-key [(M-s)] 'shell-command) in my .emacs.
> >> I also want to keep the M-! shell-command binding
> >>
> >> Nothing happens when I use M-s, nor do I get an error message.
> >
> > I think that the syntax of the expression describing the key is
> > incorrect.
>
> The correct syntax is:
>
> [?\M-s]
It works.
> Try looking at the documentation of the `kbd' macro (F1 f
> > kbd). You can use it there, like:
> > (global-set-key (kbd "M-s") #'shell-command)
It also works.
> There's no need for kbd here. It's unnecessary overhead.
>
I know there are several ways to do this -- but I need to know, for me,
some way that is consistent. I am partial to ?\ unless it has lots of
exceptions (i.e ?\C, ?\S, ?\s ??) -- if so, I'll use 'kbd' throughout.
Sorry if I sound a little grouchy, but right now my emacs frustration
knows no bounds and I am unable to make sense of anything that I read.
It is like day one, two years ago, all over again. I thought I had this
simple task -- binding functions to keys worked out.
> _______________________________________________
> help-gnu-emacs mailing list
> help-gnu-emacs@gnu.org
> http://lists.gnu.org/mailman/listinfo/help-gnu-emacs
--
Regards Bill
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Binding same command to two separte keys??
2007-04-13 20:17 ` William Case
@ 2007-04-13 21:04 ` Matthew Flaschen
2007-04-13 21:55 ` David Hansen
0 siblings, 1 reply; 14+ messages in thread
From: Matthew Flaschen @ 2007-04-13 21:04 UTC (permalink / raw)
To: emacs
William Case wrote:
> Over the last 2 years I have written about 10 keybinding functions, that
> are in my .emacs, and that I use all the time. They have always been in
> the form of (global-set-key [(M-s)] 'shell-command).
I don't know what to tell you. There are many different ways to write
keyboard shortcuts, but I've never heard of that one, and it doesn't
work for me.
> Now 'kbd' shows
> up, and '?\' to replace it.
?\ was here first, as far as I can tell. kbd is supposed to be an easy
method to unify all the others, but I think it's slightly (perhaps
negligibly) slower.
> So ... in (global-set-key (kbd "M-s") #'shell-command)
No, just
(global-set-key (kbd "M-s") 'shell-command)
>
> Does ?\ = kbd ?
No
> Does [ ] replace ( ) ?
Not really. As I said, there are many incompatible methods. They seem
to have little connection to each other
> Are the " " necessary or not necessary ?
It's necessary if you use kdb. It's not allowed if you use the method I
recommended.
> What syntax would work for both standard emacs functions and my own user
> functions?
I don't think this should make a difference.
> Emacs 22 is going to show up when I upgrade to Fedora 7. Is keybinding
> going to be different again?
I don't think so.
Matthew Flaschen
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Binding same command to two separte keys??
[not found] ` <mailman.2052.1176495874.7795.help-gnu-emacs@gnu.org>
@ 2007-04-13 21:41 ` Rjjd
2007-04-14 3:52 ` Matthew Flaschen
[not found] ` <mailman.2061.1176522998.7795.help-gnu-emacs@gnu.org>
2007-04-13 21:55 ` Joost Kremers
1 sibling, 2 replies; 14+ messages in thread
From: Rjjd @ 2007-04-13 21:41 UTC (permalink / raw)
To: help-gnu-emacs
I am also totally confused.
I have been using emacs for 25 years
Over the last 25 years I have written about 146 keybinding functions.
(That's what count-matches says in my emacsinit.el file. I admit there
have been others.)
Some of my keybindings look like this:
(global-set-key "\M- " 'dabbrev-expand)
Others look like this:
(global-set-key [SunF37] 'universal-argument)
And some look like this:
(global-set-key [f3 ?2] 'm2)
I don't know why; I just copy stuff that works. (I know, I know! It's
all in the manual! All right already!)
Every time I try to do something a little different, it's like day one,
25 years ago. (I've started writing an encrypter. It will take me
about 11 years to get it working. Has anyone else written one I can grab?)
Regards,
Bob DiGrazia
William Case wrote:
> Ok guys, now I am really totally confused.
...
> I have been using emacs for 2 years. ...
...
> Over the last 2 years I have written about 10 keybinding functions, ...
...
> Sorry if I sound a little grouchy, but right now my emacs frustration
> knows no bounds and I am unable to make sense of anything that I read.
> It is like day one, two years ago, all over again. I thought I had this
> simple task -- binding functions to keys worked out.
...
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Binding same command to two separte keys??
2007-04-13 21:04 ` Matthew Flaschen
@ 2007-04-13 21:55 ` David Hansen
2007-04-13 22:23 ` Matthew Flaschen
0 siblings, 1 reply; 14+ messages in thread
From: David Hansen @ 2007-04-13 21:55 UTC (permalink / raw)
To: help-gnu-emacs
On Fri, 13 Apr 2007 17:04:40 -0400 Matthew Flaschen wrote:
> kbd is supposed to be an easy method to unify all the others, but
> I think it's slightly (perhaps negligibly) slower.
In byte-compiled code it's not slower. IMHO it's the most readable
and therefore preferable way to write key bindings.
>> So ... in (global-set-key (kbd "M-s") #'shell-command)
>
> No, just
> (global-set-key (kbd "M-s") 'shell-command)
#'symbol is the same as (function symbol). It never harms to use it
when passing functions as an argument and in some cases the compiler
can use this hint for optimization.
David
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Binding same command to two separte keys??
[not found] ` <mailman.2052.1176495874.7795.help-gnu-emacs@gnu.org>
2007-04-13 21:41 ` Rjjd
@ 2007-04-13 21:55 ` Joost Kremers
1 sibling, 0 replies; 14+ messages in thread
From: Joost Kremers @ 2007-04-13 21:55 UTC (permalink / raw)
To: help-gnu-emacs
William Case wrote:
> Ok guys, now I am really totally confused.
>
> I have been using emacs for 2 years. I have read the Wiki, printed out
> the tiny-tools site and read and re-read the info pages.
>
> Over the last 2 years I have written about 10 keybinding functions, that
> are in my .emacs, and that I use all the time. They have always been in
> the form of (global-set-key [(M-s)] 'shell-command). Now 'kbd' shows
> up, and '?\' to replace it. And, whats a #' for, that replaces the
> single '.
>
> I just want to get consistent. I plan to do a fair amount of work with
> emacs shortly. Up to now I haven't worried much because I used my emacs
> 21.4 only for trivial text editing.
>
> So ... in (global-set-key (kbd "M-s") #'shell-command)
>
> Does ?\ = kbd ?
no. the question mark is a shortcut for the lisp reader: it indicates
characters. that is:
a
is the symbol `a', while
?a
is the character `a'.
the backslash is the escape character. e.g.: ?n is the character `n', while
?\n is the character newline.
kbd is a function that returns an emacs key representation.
> Does [ ] replace ( ) ?
no. () indicates lists, [] indicates a sequence.
> Are the " " necessary or not necessary ?
the double quotes indicate strings (which are a kind of sequence). key
sequences can be represented as strings.
> Does the # have a special meaning or is it always used now?
it has special meaning. the apostrophe ' is a lisp reader shortcut for the
function `quote', while #' is a shortcut for the function `function'. the
latter is preferred for quoting functions. see the documentation for quote
and function.
> Where do I find the kbd documentation that I already haven't looked at?
dunno... (not ever sure what you mean...)
> Do symbols like F3 still require < > ?
AFAIK yes.
> What syntax would work for both standard emacs functions and my own user
> functions?
emacs makes no difference between "standard emacs functions" and "your own
user functions".
> Emacs 22 is going to show up when I upgrade to Fedora 7. Is keybinding
> going to be different again?
nope. i'm running a cvs-version of emacs 22, and things are still the same.
> I know there are several ways to do this -- but I need to know, for me,
> some way that is consistent. I am partial to ?\ unless it has lots of
> exceptions (i.e ?\C, ?\S, ?\s ??) -- if so, I'll use 'kbd' throughout.
i'm not entirely sure what all the options are, myself. i use the string
syntax mostly:
"\M-s"
"\C-ce"
IIUC these are equivalent to:
[(meta s)]
[(control c) ?e]
but i've also had success with something like [C-up] for control plus
cursor up.
if you use kbd, you can use (kbd "C-s").
> Sorry if I sound a little grouchy, but right now my emacs frustration
> knows no bounds and I am unable to make sense of anything that I read.
> It is like day one, two years ago, all over again. I thought I had this
> simple task -- binding functions to keys worked out.
i've also searched a couple of times for some documentation on the subject
of writing key sequences, and have always come up empty-handed. all i know
for sure is that there are several methods and i have no idea which one is
preferred or dispreferred...
--
Joost Kremers joostkremers@yahoo.com
Selbst in die Unterwelt dringt durch Spalten Licht
EN:SiS(9)
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Binding same command to two separte keys??
2007-04-13 21:55 ` David Hansen
@ 2007-04-13 22:23 ` Matthew Flaschen
2007-04-14 0:44 ` David Hansen
0 siblings, 1 reply; 14+ messages in thread
From: Matthew Flaschen @ 2007-04-13 22:23 UTC (permalink / raw)
To: emacs
David Hansen wrote:
> On Fri, 13 Apr 2007 17:04:40 -0400 Matthew Flaschen wrote:
>
>> kbd is supposed to be an easy method to unify all the others, but
>> I think it's slightly (perhaps negligibly) slower.
>
> In byte-compiled code it's not slower. IMHO it's the most readable
> and therefore preferable way to write key bindings.
Maybe so, but he's not going to byte-compile .emacs .
>
>>> So ... in (global-set-key (kbd "M-s") #'shell-command)
>> No, just
>> (global-set-key (kbd "M-s") 'shell-command)
>
> #'symbol is the same as (function symbol). It never harms to use it
> when passing functions as an argument and in some cases the compiler
> can use this hint for optimization.
Okay, thanks.
Matthew Flaschen
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Binding same command to two separte keys??
2007-04-13 22:23 ` Matthew Flaschen
@ 2007-04-14 0:44 ` David Hansen
0 siblings, 0 replies; 14+ messages in thread
From: David Hansen @ 2007-04-14 0:44 UTC (permalink / raw)
To: help-gnu-emacs
On Fri, 13 Apr 2007 18:23:29 -0400 Matthew Flaschen wrote:
> David Hansen wrote:
>> On Fri, 13 Apr 2007 17:04:40 -0400 Matthew Flaschen wrote:
>>
>>> kbd is supposed to be an easy method to unify all the others, but
>>> I think it's slightly (perhaps negligibly) slower.
>>
>> In byte-compiled code it's not slower. IMHO it's the most readable
>> and therefore preferable way to write key bindings.
>
> Maybe so, but he's not going to byte-compile .emacs .
I do so. Can't speak for other people though...
David
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Binding same command to two separte keys??
2007-04-13 21:41 ` Rjjd
@ 2007-04-14 3:52 ` Matthew Flaschen
[not found] ` <mailman.2061.1176522998.7795.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 14+ messages in thread
From: Matthew Flaschen @ 2007-04-14 3:52 UTC (permalink / raw)
To: emacs
Rjjd wrote:
> I am also totally confused.
>
> I have been using emacs for 25 years
>
> Over the last 25 years I have written about 146 keybinding functions.
> (That's what count-matches says in my emacsinit.el file. I admit there
> have been others.)
>
> Some of my keybindings look like this:
> (global-set-key "\M- " 'dabbrev-expand)
> Others look like this:
> (global-set-key [SunF37] 'universal-argument)
> And some look like this:
> (global-set-key [f3 ?2] 'm2)
>
> I don't know why; I just copy stuff that works. (I know, I know! It's
> all in the manual! All right already!)
>
> Every time I try to do something a little different, it's like day one,
> 25 years ago. (I've started writing an encrypter. It will take me
> about 11 years to get it working. Has anyone else written one I can grab?)
Can't you use gnupg ? It should be fairly easy to integrate.
Matt Flaschen
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Binding same command to two separte keys??
2007-04-13 19:17 ` Matthew Flaschen
2007-04-13 20:17 ` William Case
[not found] ` <mailman.2052.1176495874.7795.help-gnu-emacs@gnu.org>
@ 2007-04-14 9:26 ` Reiner Steib
2007-04-16 10:17 ` Kai Grossjohann
3 siblings, 0 replies; 14+ messages in thread
From: Reiner Steib @ 2007-04-14 9:26 UTC (permalink / raw)
To: help-gnu-emacs
On Fri, Apr 13 2007, Matthew Flaschen wrote:
> The correct syntax is:
>
> [?\M-s]
[...]
>> (global-set-key (kbd "M-s") #'shell-command)
>
> There's no need for kbd here. It's unnecessary overhead.
There a different ways to do the same job. Using `kbd' offers the
striking advantage that the user can use the output of `C-h k ...' as
input without a need to think much about Emacs internal handling of
key bindings.
Bye, Reiner.
--
,,,
(o o)
---ooO-(_)-Ooo--- | PGP key available | http://rsteib.home.pages.de/
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Binding same command to two separte keys??
[not found] ` <mailman.2061.1176522998.7795.help-gnu-emacs@gnu.org>
@ 2007-04-15 3:32 ` Tim X
0 siblings, 0 replies; 14+ messages in thread
From: Tim X @ 2007-04-15 3:32 UTC (permalink / raw)
To: help-gnu-emacs
Matthew Flaschen <matthew.flaschen@gatech.edu> writes:
> Rjjd wrote:
>> I am also totally confused.
>>
>> I have been using emacs for 25 years
>>
>> Over the last 25 years I have written about 146 keybinding functions.
>> (That's what count-matches says in my emacsinit.el file. I admit there
>> have been others.)
>>
>> Some of my keybindings look like this:
>> (global-set-key "\M- " 'dabbrev-expand)
>> Others look like this:
>> (global-set-key [SunF37] 'universal-argument)
>> And some look like this:
>> (global-set-key [f3 ?2] 'm2)
>>
>> I don't know why; I just copy stuff that works. (I know, I know! It's
>> all in the manual! All right already!)
>>
>> Every time I try to do something a little different, it's like day one,
>> 25 years ago. (I've started writing an encrypter. It will take me
>> about 11 years to get it working. Has anyone else written one I can grab?)
>
> Can't you use gnupg ? It should be fairly easy to integrate.
>
or just use crypt++ and all the work is done already. Alternatively, upgrade to
emacs 22 and it has pgg, which is an interface to gnupg.
Tim
--
tcross (at) rapttech dot com dot au
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Binding same command to two separte keys??
2007-04-13 19:17 ` Matthew Flaschen
` (2 preceding siblings ...)
2007-04-14 9:26 ` Reiner Steib
@ 2007-04-16 10:17 ` Kai Grossjohann
3 siblings, 0 replies; 14+ messages in thread
From: Kai Grossjohann @ 2007-04-16 10:17 UTC (permalink / raw)
To: help-gnu-emacs
Matthew Flaschen <matthew.flaschen@gatech.edu> writes:
> There's no need for kbd here. It's unnecessary overhead.
In some places, Emacs prints keybindings. For instance, after C-h c,
C-h w, C-h l.
The main advantage of kbd is that it accepts the syntax printed by
Emacs itself. IMHO this is a big advantage.
Kai
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2007-04-16 10:17 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-13 19:02 Binding same command to two separte keys?? William Case
2007-04-13 19:12 ` Karl Hegbloom
2007-04-13 19:17 ` Matthew Flaschen
2007-04-13 20:17 ` William Case
2007-04-13 21:04 ` Matthew Flaschen
2007-04-13 21:55 ` David Hansen
2007-04-13 22:23 ` Matthew Flaschen
2007-04-14 0:44 ` David Hansen
[not found] ` <mailman.2052.1176495874.7795.help-gnu-emacs@gnu.org>
2007-04-13 21:41 ` Rjjd
2007-04-14 3:52 ` Matthew Flaschen
[not found] ` <mailman.2061.1176522998.7795.help-gnu-emacs@gnu.org>
2007-04-15 3:32 ` Tim X
2007-04-13 21:55 ` Joost Kremers
2007-04-14 9:26 ` Reiner Steib
2007-04-16 10:17 ` Kai Grossjohann
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).