From: Austin Clements <amdragon@MIT.EDU>
To: Mark Walters <markwalters1009@gmail.com>, notmuch@notmuchmail.org
Subject: Re: [PATCH] emacs: help: bugfix
Date: Tue, 12 Nov 2013 13:47:36 -0500 [thread overview]
Message-ID: <87ppq54fuf.fsf@awakening.csail.mit.edu> (raw)
In-Reply-To: <1384076682-16872-1-git-send-email-markwalters1009@gmail.com>
On Sun, 10 Nov 2013, Mark Walters <markwalters1009@gmail.com> wrote:
> Hi
>
> David found a bug in the this remap/help series. He has a global
> keybinding of "C-c s" for notmuch-search and this causes help in
> tree-mode to hang.
>
> I have mostly diagnosed this: the problem comes that all the construct
> help routines are inside a string-match/replace-match pair. Somewhere
> in these routines the match-data is being stomped on (but I have to
> admit I am not sure where).
>
> In any case putting the construct help routines inside a
> save-match-data seems to fix it.
>
> This version is a bit ugly: I am not sure of the best way to deal with
> the save-match-data macro. (I think it is best to have it round
> everything that happens between finding the match and replacing the
> match to avoid anything similar in future).
>
> This applies on top of the parent series.
>
> Any comments gratefully received!
>
> Best wishes
>
> Mark
>
> ---
> emacs/notmuch-lib.el | 17 ++++++++++-------
> 1 files changed, 10 insertions(+), 7 deletions(-)
>
> diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
> index 7b8acb3..e98e073 100644
> --- a/emacs/notmuch-lib.el
> +++ b/emacs/notmuch-lib.el
> @@ -305,13 +305,16 @@ prefix argument. PREFIX and TAIL are used internally."
> (defun notmuch-substitute-command-keys (doc)
> "Like `substitute-command-keys' but with documentation, not function names."
> (let ((beg 0))
> - (while (string-match "\\\\{\\([^}[:space:]]*\\)}" doc beg)
> - (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-alist (notmuch-describe-keymap keymap ua-keys keymap))
> - (desc-list (mapcar (lambda (arg) (concat (car arg) "\t" (cdr arg))) desc-alist))
> - (desc (mapconcat #'identity desc-list "\n")))
> + (while (string-match "\\\\{\\([^}[:space:]]*\\)}" doc beg) ;; matches \{not-space}
> + (let ((desc
> + (save-match-data
> + (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-alist (notmuch-describe-keymap keymap ua-keys keymap))
> + (desc-list (mapcar (lambda (arg) (concat (car arg) "\t" (cdr arg))) desc-alist))
> + (desc (mapconcat #'identity desc-list "\n")))
> + desc))))
Oof, what an annoying place to lose the match data. My one suggestion
would be to put (mapconcat #'identity desc-list "\n") as the body of the
inner let, rather than binding `desc' and then immediately evaluating to
`desc'. That would remove some redundancy, and it's already clear from
the outer let that the result of the mapconcat is named `desc'.
> (setq doc (replace-match desc 1 1 doc)))
> (setq beg (match-end 0)))
> doc))
> --
> 1.7.9.1
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch
prev parent reply other threads:[~2013-11-12 18:47 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-08 17:40 [PATCH v3 0/7] emacs: help: remap keybindings Mark Walters
2013-11-08 17:40 ` [PATCH v3 1/7] emacs: help: check for nil key binding Mark Walters
2013-11-08 17:40 ` [PATCH v3 2/7] emacs: help: remove duplicate bindings Mark Walters
2013-11-08 17:40 ` [PATCH v3 3/7] emacs: help: split out notmuch-describe-key as a function Mark Walters
2013-11-08 17:40 ` [PATCH v3 4/7] emacs: help: add base-keymap Mark Walters
2013-11-08 17:40 ` [PATCH v3 5/7] emacs: help: add a special function to deal with remaps Mark Walters
2013-11-08 17:40 ` [PATCH v3 6/7] emacs: tree: use remap for the over-ridden global bindings Mark Walters
2013-11-08 17:40 ` [PATCH v3 7/7] emacs: help: base-keymap-test-help Mark Walters
2013-11-08 20:00 ` [PATCH v3 0/7] emacs: help: remap keybindings Austin Clements
2013-11-10 9:44 ` [PATCH] emacs: help: bugfix Mark Walters
2013-11-10 11:53 ` David Bremner
2013-11-12 18:47 ` Austin Clements [this message]
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=87ppq54fuf.fsf@awakening.csail.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).