GNU bug report logs -
#43617
27.1; Define-minor-mode keybindings not get precedence over global keymap
Previous Next
Reported by: dalanicolai <at> gmail.com
Date: Fri, 25 Sep 2020 18:11:02 UTC
Severity: normal
Tags: notabug
Found in version 27.1
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
Message #18 received at 43617 <at> debbugs.gnu.org (full text, mbox):
> Ah, it just works for "j" by accident -- define-minor-mode does not
> evaluate anything in the keymap form.
It should. According to its doc string.
> So there's no bug here in define-minor-mode, but the
> here is wrong. It should be:
>
> (define-minor-mode pdf-continuous-scroll-mode-5
> "Emulate continuous scroll with two synchronized buffers"
> nil
> " Continuous"
> `((,(kbd "j") . (lambda () (interactive) (print "pushed j")))
> (,(kbd "C-n") . (lambda () (interactive)(print "pushed C-n"))))
> (print "toggled minor mode"))
>
> So I'm closing this bug report.
I don't agree that there's no bug (IIUC).
I think there's either a doc bug (if you think
the current behavior is what we want - I don't)
or a behavior bug (if you think the doc's
described behavior is what we want - I do).
The doc string says that KEYMAP can be:
an expression that returns either a keymap or
a list of (KEY . BINDING) pairs where KEY and
BINDING are suitable for `define-key'
The cons ((kbd "C-n") . 'foo) is exactly such a
(KEY . BINDING) pair - both KEY and BINDING are
suitable arguments for `define-key'.
Yes, it's true that the _result of evaluating_
(kbd ...) is ALSO an acceptable arg for
`define-key'. But `define-key' doesn't _require_
its KEY arg to be, say, a string or vector.
`define-key' evaluates its arg. And a list
(kbd ...) is an acceptable arg for `define-key'.
You can write
(define-key map (kbd "C-n") 'foo)
Or you can write
(define-key map "
" 'foo)
where that string with char ?\n (Control-J) is
the result of evaluating the sexp (kbd "C-n").
Or you can write
(define-key map "\n" 'foo)
`define-minor-mode' should accept any expression
that `define-key' accepts for KEY. In the case
of `C-n' that means (kbd "C-n"), "\n", and "
".
This bug report was last modified 4 years and 289 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.