all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Emanuel Berg <embe8573@student.uu.se>
To: help-gnu-emacs@gnu.org
Subject: Re: confusion with defining keys
Date: Thu, 12 Jun 2014 03:39:10 +0200	[thread overview]
Message-ID: <87sina6h4x.fsf@debian.uxu> (raw)
In-Reply-To: mailman.3459.1402534627.1147.help-gnu-emacs@gnu.org

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> The reason I do "..." is simply it is easier to
>> type.  So if there is some gain switching I'll do
>> that, of course.
>
> Using [...] or (kbd "...") gains you the fact that
> these work for *any* key, whereas "..." only works in
> some cases.

It would seem there are some exceptions to that rule!

Check out the below experimentation:

(global-set-key (kbd "RET") 'newline-and-indent) ; works
(global-set-key "\r"        'newline-and-indent) ; works
(global-set-key [RET]       'newline-and-indent) ; (error "To bind the key RET, use \"\\r\", not [RET]")

(global-set-key (kbd "M-SPC") 'eat-space) ; works
(global-set-key "\M- "        'eat-space) ; works
(global-set-key [M-SPC]       'eat-space) ; (error "To bind the key M-SPC, use \"\\M- \", not [M-SPC]")

Also, with the [...], it seems you shouldn't include
the <...> for custom keys - which is good, because you
don't define them that way, so it is only confusing
having to use that later:

(define-key input-decode-map [?\u010F] [C-semi-colon])
(global-set-key         [C-semi-colon] 'string-to-cmd)
(global-unset-key (kbd "<C-semi-colon>")) ; everything works

A (minor) drawback with [...] is less readability as
the keys don't get the font-lock-string-face -
customizable, of course (but watch out I guess so not
lots of [stuff] get affected).

--
underground experts united:
http://user.it.uu.se/~embe8573


  parent reply	other threads:[~2014-06-12  1:39 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-11  5:05 confusion with defining keys lee
2014-06-11  8:21 ` kastian
2014-06-11 11:30 ` Nicolas Richard
2014-06-12  5:28   ` lee
2014-06-11 11:53 ` Stefan Monnier
2014-06-12  5:40   ` lee
     [not found] ` <mailman.3403.1402487643.1147.help-gnu-emacs@gnu.org>
2014-06-11 14:32   ` Emanuel Berg
2014-06-12  0:56     ` Stefan Monnier
     [not found]     ` <mailman.3459.1402534627.1147.help-gnu-emacs@gnu.org>
2014-06-12  1:39       ` Emanuel Berg [this message]
2014-06-12  1:49         ` Emanuel Berg
2014-06-12  2:48         ` Stefan Monnier
     [not found]         ` <mailman.3470.1402541342.1147.help-gnu-emacs@gnu.org>
2014-06-12 13:59           ` Emanuel Berg
2014-06-12 14:17           ` Emanuel Berg
2014-06-12 14:52             ` Stefan Monnier
     [not found]             ` <mailman.3498.1402584764.1147.help-gnu-emacs@gnu.org>
2014-06-12 22:57               ` Emanuel Berg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87sina6h4x.fsf@debian.uxu \
    --to=embe8573@student.uu.se \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.