From: jpkotta <jpkotta@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: undoing define-key
Date: Tue, 18 Dec 2012 09:46:41 -0800 (PST) [thread overview]
Message-ID: <6461229b-84bb-4d42-a075-5ab5ffe11e4a@googlegroups.com> (raw)
How can I unbind a key in a keymap such that it acts like it was never defined? The docs make it sound like binding to nil, e.g. (define-key map (kbd "<key>") nil), will do what I want, but it doesn't.
Example (works with emacs -q):
(define-minor-mode foo-mode
:global t
:keymap (let ((map (make-sparse-keymap)))
(define-key map (kbd "M-j") 'left-char)
(define-key map (kbd "M-k") 'next-line)
(define-key map (kbd "M-l") 'right-char)
(define-key map (kbd "M-i") 'previous-line)
map)
)
(foo-mode 1)
;; Now M-[ijkl] act like the arrow keys
;; I can do an isearch and they will exit the search just like the arrows
(define-key isearch-mode-map (kbd "M-j") nil)
;; Now M-j does not exit isearch, and it behaves like whatever it was bound to outside of foo-mode. M-j still does left-char outside of isearch-mode.
next reply other threads:[~2012-12-18 17:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-18 17:46 jpkotta [this message]
2012-12-19 0:45 ` undoing define-key Stefan Monnier
[not found] ` <mailman.15643.1355877970.855.help-gnu-emacs@gnu.org>
2012-12-19 16:05 ` jpkotta
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=6461229b-84bb-4d42-a075-5ab5ffe11e4a@googlegroups.com \
--to=jpkotta@gmail.com \
--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.