use-package icon indicating copy to clipboard operation
use-package copied to clipboard

Local keymaps, small visual bug?

Open rchar01 opened this issue 7 years ago • 3 comments

Should M-n (the last keybinding declared) be in the Personal Keybindings buffer's title?
When describing keyboard shortcuts using use-package, for term for example:

(use-package term
  :bind (:map term-raw-map
              ("M-o" . other-window)
              ("M-p" . term-send-up)
              ("M-n" . term-send-down)))

in the Personal Keybindings buffer (M-x describe-personal-keybindings) such shortcuts are described as:

term-raw-map: M-n
-------------------------------------------------------------------------------

M-n               `term-send-down'                        was `term-send-raw-meta'
M-o               `other-window'                          was `term-send-raw-meta'
M-p               `term-send-up'                          was `term-send-raw-meta'

rchar01 avatar Feb 25 '18 17:02 rchar01

What is your opinion on this subject? Is this a bug? Should the table have M-n in the header?

rchar01 avatar Aug 19 '18 11:08 rchar01

I can confirm the same observation. The section headings for different mode maps always include the first binding in that section.

Info-mode-map: C-c m l
-------------------------------------------------------------------------------

C-c m l           `ace-link-info'


emacs-lisp-mode-map: C-c m x
-------------------------------------------------------------------------------

C-c m x           `macrostep-expand'


flyspell-mouse-map: <down-mouse-2>
-------------------------------------------------------------------------------

<down-mouse-2>    `nil'

<mouse-2>         `nil'                                   was `flyspell-correct-word'


help-mode-map: C-c m l
-------------------------------------------------------------------------------

C-c m l           `ace-link-help'


lisp-interaction-mode-map: C-c m x
-------------------------------------------------------------------------------

C-c m x           `macrostep-expand'


minibuffer-local-map: M-A
-------------------------------------------------------------------------------

M-A               `marginalia-cycle'


org-agenda-mode-map: N
-------------------------------------------------------------------------------

N                 `my-org-gtd-narrow-to-subtree'          was `org-agenda-next-item'
P                 `my-org-gtd-narrow-to-project'          was `org-agenda-previous-item'
U                 `my-org-gtd-narrow-to-parent'           was `org-agenda-bulk-unmark-all'
W                 `my-org-gtd-widen'


org-mode-map: C-c i a
-------------------------------------------------------------------------------

C-c i a           `my-org-gtd-insert-new-action-item'

C-x n t           `my-org-gtd-narrow-to-top-heading'


smartparens-strict-mode-map: M-q
-------------------------------------------------------------------------------

M-q               `sp-indent-defun'

Seems like a bug to me.

doolio avatar Nov 14 '22 21:11 doolio

I'm seeing the same thing. Confirmed it by running Emacs without a configuration and evaluating the following in my *scratch* buffer.

(bind-key "C-c l" 'next-line)
(bind-key "z" 'customize-group mode-specific-map)
(bind-key "p" 'previous-line mode-specific-map)
(bind-keys
 :map mode-specific-map
 :prefix "t"
 :prefix-map my-test-map
 ("n" . next-line)
 ("p" . previous-line))

After doing this, running "M-x describe-personal-keybindings RET" creates a buffer with this text:

Key name          Command                                 Comments
----------------- --------------------------------------- ---------------------
C-c l             `next-line'


mode-specific-map: p
-------------------------------------------------------------------------------

p                 `previous-line'
t                 `my-test-map'
z                 `customize-group'


my-test-map: n
-------------------------------------------------------------------------------

n                 `next-line'
p                 `previous-line'

So the bindings in global-map are presented as expected, but the other keymap sections display a colon and a key at the end of each section header (which corresponds to the most recent personal keybinding created in that map).

It would make sense if the key were a prefix key for that map, but that's not the case.

I ended up doing this to remove it.

(advice-add
   'describe-personal-keybindings :after
   (defun my-clean-up-personal-keybindings-display ()
     "Remove the extraneous text in `describe-personal-keybindings' headers."
     (with-current-buffer "*Personal Keybindings*"
       (let ((inhibit-read-only t))
         (replace-regexp-in-region
          ": .+\n-----" "\n-----" (point-min) (point-max))))))

mmarshall540 avatar Dec 19 '23 20:12 mmarshall540