all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* (define-key MAP [remap COMMAND] PREFIX-KEY-MAP)
@ 2019-09-27 21:20 Drew Adams
  2019-09-27 21:25 ` Drew Adams
  0 siblings, 1 reply; 3+ messages in thread
From: Drew Adams @ 2019-09-27 21:20 UTC (permalink / raw)
  To: Emacs developers

(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
`define-prefix-command':

(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?



^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: (define-key MAP [remap COMMAND] PREFIX-KEY-MAP)
  2019-09-27 21:20 (define-key MAP [remap COMMAND] PREFIX-KEY-MAP) Drew Adams
@ 2019-09-27 21:25 ` Drew Adams
  2019-09-28  3:59   ` Drew Adams
  0 siblings, 1 reply; 3+ messages in thread
From: Drew Adams @ 2019-09-27 21:25 UTC (permalink / raw)
  To: Emacs developers

Forgot to add that the doc string of `define-key'
suggests that it IS supported:

 DEF is anything that can be a key's definition:
  ...
  a keymap (to define a prefix key)

That description of DEF is written separately from
the description of [remap COMMAND].  There is no
explicit restriction placed DEF for the [remap
COMMAND] case.

Is there a bug here, in the handling of `remap'?



^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: (define-key MAP [remap COMMAND] PREFIX-KEY-MAP)
  2019-09-27 21:25 ` Drew Adams
@ 2019-09-28  3:59   ` Drew Adams
  0 siblings, 0 replies; 3+ messages in thread
From: Drew Adams @ 2019-09-28  3:59 UTC (permalink / raw)
  To: Emacs developers

Forgot to also add that `substitute-key-definition` doesn't have this problem/limitation.

(substitute-key-definition 'next-line 'my-map global-map)

If for some reason the behavior for remapping is unavoidable or is deemed TRT, the please at least fix the doc of `define-key', which suggests (says) that it should work also for remapping.



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-09-28  3:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-09-27 21:20 (define-key MAP [remap COMMAND] PREFIX-KEY-MAP) Drew Adams
2019-09-27 21:25 ` Drew Adams
2019-09-28  3:59   ` Drew Adams

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.