* undoing define-key
@ 2012-12-18 17:46 jpkotta
2012-12-19 0:45 ` Stefan Monnier
[not found] ` <mailman.15643.1355877970.855.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 3+ messages in thread
From: jpkotta @ 2012-12-18 17:46 UTC (permalink / raw)
To: help-gnu-emacs
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.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: undoing define-key
2012-12-18 17:46 undoing define-key jpkotta
@ 2012-12-19 0:45 ` Stefan Monnier
[not found] ` <mailman.15643.1355877970.855.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 3+ messages in thread
From: Stefan Monnier @ 2012-12-19 0:45 UTC (permalink / raw)
To: help-gnu-emacs
> ;; 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.
And what behavior would you want instead?
Stefan
^ permalink raw reply [flat|nested] 3+ messages in thread
[parent not found: <mailman.15643.1355877970.855.help-gnu-emacs@gnu.org>]
* Re: undoing define-key
[not found] ` <mailman.15643.1355877970.855.help-gnu-emacs@gnu.org>
@ 2012-12-19 16:05 ` jpkotta
0 siblings, 0 replies; 3+ messages in thread
From: jpkotta @ 2012-12-19 16:05 UTC (permalink / raw)
To: gnu.emacs.help; +Cc: help-gnu-emacs
On Tuesday, December 18, 2012 6:45:49 PM UTC-6, Stefan Monnier wrote:
> > ;; 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.
>
>
>
> And what behavior would you want instead?
>
>
>
>
>
> Stefan
I wanted to reclaim some keys that were set in isearch-mode-map, and I wanted to do it by making sure they were undefined, so that another keymap would override them. To be clear, these keys were bound by a 3rd party library, not by default.
It appears to be something special in isearch-mode. I thought M-[ijkl] were unbound, but they're actually bound to isearch-other-meta-char. If I bind to that, then everything works as intended.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-12-19 16:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-18 17:46 undoing define-key jpkotta
2012-12-19 0:45 ` Stefan Monnier
[not found] ` <mailman.15643.1355877970.855.help-gnu-emacs@gnu.org>
2012-12-19 16:05 ` jpkotta
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).