From: Austin Clements <amdragon@MIT.EDU>
To: Mark Walters <markwalters1009@gmail.com>
Cc: notmuch@notmuchmail.org
Subject: Re: [PATCH v2 2/5] emacs: help: remove duplicate bindings
Date: Thu, 7 Nov 2013 22:09:28 -0500 [thread overview]
Message-ID: <20131108030928.GK29298@mit.edu> (raw)
In-Reply-To: <1383870096-14627-3-git-send-email-markwalters1009@gmail.com>
Quoth Mark Walters on Nov 08 at 12:21 am:
> 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 the is applicable.
s/the/them/
>
> 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"
> ---
> emacs/notmuch-lib.el | 41 ++++++++++++++++++++++++-----------------
> 1 files changed, 24 insertions(+), 17 deletions(-)
>
> diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
> index ec5a2cb..2195166 100644
> --- a/emacs/notmuch-lib.el
> +++ b/emacs/notmuch-lib.el
> @@ -238,11 +238,12 @@ This is basically just `format-kbd-macro' but we also convert ESC to M-."
> (concat desc " "))))
>
> (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
> -one-line description of the bound function. See `notmuch-help'
> -for an overview of how this documentation is extracted.
> +Each cons cell consists of a string giving a human-readable
> +description of the key, and a one-line description of the bound
> +function. See `notmuch-help' for an overview of how this
> +documentation is extracted.
>
> UA-KEYS should be a key sequence bound to `universal-argument'.
> It will be used to describe bindings of commands that support a
> @@ -255,18 +256,23 @@ prefix argument. PREFIX and TAIL are used internally."
> (notmuch-describe-keymap
> binding ua-keys (notmuch-prefix-key-description key) tail)))
> (binding
> - (when (and ua-keys (symbolp binding)
> - (get binding 'notmuch-prefix-doc))
> - ;; Documentation for prefixed command
> - (let ((ua-desc (key-description ua-keys)))
> - (push (concat ua-desc " " prefix (format-kbd-macro (vector key))
> - "\t" (get binding 'notmuch-prefix-doc))
> - tail)))
> - ;; Documentation for command
> - (push (concat prefix (format-kbd-macro (vector key)) "\t"
> - (or (and (symbolp binding) (get binding 'notmuch-doc))
> - (notmuch-documentation-first-line binding)))
> - tail))))
> + (let ((key-string (concat prefix (format-kbd-macro (vector key)))))
> + ;; We don't include documentation if the key-binding is
> + ;; over-ridden. Note, over-riding a binding
> + ;; automatically hides the prefixed version too.
> + (unless (assoc key-string tail)
> + (when (and ua-keys (symbolp binding)
> + (get binding 'notmuch-prefix-doc))
> + ;; Documentation for prefixed command
> + (let ((ua-desc (key-description ua-keys)))
> + (push (cons (concat ua-desc " " prefix (format-kbd-macro (vector key)))
> + (get binding 'notmuch-prefix-doc))
> + tail)))
> + ;; Documentation for command
> + (push (cons key-string
> + (or (and (symbolp binding) (get binding 'notmuch-doc))
> + (notmuch-documentation-first-line binding)))
> + tail))))))
> keymap)
> tail)
>
> @@ -277,7 +283,8 @@ prefix argument. PREFIX and TAIL are used internally."
> (let* ((keymap-name (substring doc (match-beginning 1) (match-end 1)))
> (keymap (symbol-value (intern keymap-name)))
> (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))
> (desc (mapconcat #'identity desc-list "\n")))
> (setq doc (replace-match desc 1 1 doc)))
> (setq beg (match-end 0)))
next prev parent reply other threads:[~2013-11-08 3:09 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-08 0:21 [PATCH v2 0/5] emacs: help: and remap keybindings Mark Walters
2013-11-08 0:21 ` [PATCH v2 1/5] emacs: help: check for nil key binding Mark Walters
2013-11-08 0:21 ` [PATCH v2 2/5] emacs: help: remove duplicate bindings Mark Walters
2013-11-08 3:09 ` Austin Clements [this message]
2013-11-08 0:21 ` [PATCH v2 3/5] emacs: help: split out notmuch-describe-key as a function Mark Walters
2013-11-08 3:30 ` Austin Clements
2013-11-08 0:21 ` [PATCH v2 4/5] emacs: help: add a special function to deal with remaps Mark Walters
2013-11-08 3:35 ` Austin Clements
2013-11-08 0:21 ` [PATCH v2 5/5] emacs: tree: use remap for the over-ridden global bindings Mark Walters
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20131108030928.GK29298@mit.edu \
--to=amdragon@mit.edu \
--cc=markwalters1009@gmail.com \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).