mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-25 20:38:08 +01:00
emacs: help: remove duplicate bindings
If the user (or a mode) overrides a keybinding from the common keymap in one of the modes then both help lines appear in the help screen even though only one of them is applicable. Fix this by checking if we already have that key binding. We do this by constructing an list of (key . docstring) pairs so it is easy to check if we have already had that binding. Then the actual print help routine changes these pairs into strings "key \t docstring"
This commit is contained in:
parent
6f616bd733
commit
9d0174b11c
1 changed files with 24 additions and 17 deletions
|
@ -237,11 +237,12 @@ This is basically just `format-kbd-macro' but we also convert ESC to M-."
|
||||||
(concat desc " "))))
|
(concat desc " "))))
|
||||||
|
|
||||||
(defun notmuch-describe-keymap (keymap ua-keys &optional prefix tail)
|
(defun notmuch-describe-keymap (keymap ua-keys &optional prefix tail)
|
||||||
"Return a list of strings, each describing one binding in KEYMAP.
|
"Return a list of cons cells, each describing one binding in KEYMAP.
|
||||||
|
|
||||||
Each string gives a human-readable description of the key and a
|
Each cons cell consists of a string giving a human-readable
|
||||||
one-line description of the bound function. See `notmuch-help'
|
description of the key, and a one-line description of the bound
|
||||||
for an overview of how this documentation is extracted.
|
function. See `notmuch-help' for an overview of how this
|
||||||
|
documentation is extracted.
|
||||||
|
|
||||||
UA-KEYS should be a key sequence bound to `universal-argument'.
|
UA-KEYS should be a key sequence bound to `universal-argument'.
|
||||||
It will be used to describe bindings of commands that support a
|
It will be used to describe bindings of commands that support a
|
||||||
|
@ -254,18 +255,23 @@ prefix argument. PREFIX and TAIL are used internally."
|
||||||
(notmuch-describe-keymap
|
(notmuch-describe-keymap
|
||||||
binding ua-keys (notmuch-prefix-key-description key) tail)))
|
binding ua-keys (notmuch-prefix-key-description key) tail)))
|
||||||
(binding
|
(binding
|
||||||
(when (and ua-keys (symbolp binding)
|
(let ((key-string (concat prefix (format-kbd-macro (vector key)))))
|
||||||
(get binding 'notmuch-prefix-doc))
|
;; We don't include documentation if the key-binding is
|
||||||
;; Documentation for prefixed command
|
;; over-ridden. Note, over-riding a binding
|
||||||
(let ((ua-desc (key-description ua-keys)))
|
;; automatically hides the prefixed version too.
|
||||||
(push (concat ua-desc " " prefix (format-kbd-macro (vector key))
|
(unless (assoc key-string tail)
|
||||||
"\t" (get binding 'notmuch-prefix-doc))
|
(when (and ua-keys (symbolp binding)
|
||||||
tail)))
|
(get binding 'notmuch-prefix-doc))
|
||||||
;; Documentation for command
|
;; Documentation for prefixed command
|
||||||
(push (concat prefix (format-kbd-macro (vector key)) "\t"
|
(let ((ua-desc (key-description ua-keys)))
|
||||||
(or (and (symbolp binding) (get binding 'notmuch-doc))
|
(push (cons (concat ua-desc " " prefix (format-kbd-macro (vector key)))
|
||||||
(notmuch-documentation-first-line binding)))
|
(get binding 'notmuch-prefix-doc))
|
||||||
tail))))
|
tail)))
|
||||||
|
;; Documentation for command
|
||||||
|
(push (cons key-string
|
||||||
|
(or (and (symbolp binding) (get binding 'notmuch-doc))
|
||||||
|
(notmuch-documentation-first-line binding)))
|
||||||
|
tail))))))
|
||||||
keymap)
|
keymap)
|
||||||
tail)
|
tail)
|
||||||
|
|
||||||
|
@ -278,7 +284,8 @@ prefix argument. PREFIX and TAIL are used internally."
|
||||||
(let* ((keymap-name (substring doc (match-beginning 1) (match-end 1)))
|
(let* ((keymap-name (substring doc (match-beginning 1) (match-end 1)))
|
||||||
(keymap (symbol-value (intern keymap-name)))
|
(keymap (symbol-value (intern keymap-name)))
|
||||||
(ua-keys (where-is-internal 'universal-argument keymap t))
|
(ua-keys (where-is-internal 'universal-argument keymap t))
|
||||||
(desc-list (notmuch-describe-keymap keymap ua-keys)))
|
(desc-alist (notmuch-describe-keymap keymap ua-keys))
|
||||||
|
(desc-list (mapcar (lambda (arg) (concat (car arg) "\t" (cdr arg))) desc-alist)))
|
||||||
(mapconcat #'identity desc-list "\n")))))
|
(mapconcat #'identity desc-list "\n")))))
|
||||||
(setq doc (replace-match desc 1 1 doc)))
|
(setq doc (replace-match desc 1 1 doc)))
|
||||||
(setq beg (match-end 0)))
|
(setq beg (match-end 0)))
|
||||||
|
|
Loading…
Reference in a new issue