help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Binding same command to two separte keys??


From: Joost Kremers
Subject: Re: Binding same command to two separte keys??
Date: 13 Apr 2007 21:55:38 GMT
User-agent: slrn/0.9.8.1 (Linux)

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)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]