[Top][All Lists]

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

(define-key MAP [remap COMMAND] PREFIX-KEY-MAP)

From: Drew Adams
Subject: (define-key MAP [remap COMMAND] PREFIX-KEY-MAP)
Date: Fri, 27 Sep 2019 14:20:13 -0700 (PDT)

(defvar my-map nil "...")
(define-prefix-command 'my-map)

(define-key my-map (kbd "a") 'forward-char)
(define-key my-map (kbd "b") 'backward-char)

This is OK:

(define-key global-map (kbd "C-n") 'my-map)

These are not OK:

1. (define-key global-map [remap next-line] my-map) 
2. (define-key global-map [remap next-line] 'my-map)

Using `C-n' (normally bound to `next-line') raises an
error saying that the keymap (for #1) or the keymap
variable (for #2) is not a command (`commandp').

Apparently the handling of pseudo function-key `remap'
doesn't cover this case.  Shouldn't it be able to?

Same thing if you use, say, one of these instead of

(fset 'my-map my-map)
(fset 'my-map 'my-map)

Apparently the problem isn't the definition of the
keymap for the prefix key.  And it isn't because
`define-key' can't handle a `symbol-function' value
that's a keymap or a symbol whose `symbol-value' is
a keymap (it can).

The problem seems to be only with the way the
[remap COMMAND] is handled by `define-key' (and by
`global-set-key' etc.).

Is it feasible to have this case handled too?

reply via email to

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