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

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

Re: Looking for the "best" notation for key-binding


From: Stefan Monnier
Subject: Re: Looking for the "best" notation for key-binding
Date: Fri, 21 Sep 2012 09:29:21 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (gnu/linux)

> I think the vector notation is a good choice:
>       (global-set-key [C-∫]           'backward-sexp) ; A-C-b

This likely won't work.  You need

    (global-set-key [?\C-∫] 'backward-sexp) ; A-C-b

instead.  Yes, it's an annoyance.  You have to understand the
distinction between keys that emit characters and other keys (that emit
symbols).

>       (global-set-key [M-S-return]    'other-window)
>       (global-set-key [f1 f5]         'apropos-variable)
>       (global-set-key [f3]            'compare-windows)
>       (global-set-key [A-f1]          'replace-string)

These look just fine, yes.

> Trying to bind the Lisp comment character ";" to anything can become tricky…
> In my Emacsen (23.4, 24.2.50) this works:
>       (global-set-key [67108923] 'comment-indent)

Now that's very intuitive.  A better choice (maybe still not totally
obvious to come across, but at least a bit more obvious to understand
when you read it):

    (global-set-key [?\C-\;] 'comment-indent)
        
> The number value can be found by typing, for example in *scratch* buffer,
> C-q C-;. This produces a record in the *Messages* buffer you can use.

If you type C-x C-e twice in a row, with point right after the magical
number, you'll see alternative ways to write this number, one of them
being the one I used above.


        Stefan


reply via email to

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