emacs: help: save-match-data

The routines that construct the help page in notmuch-lib rely on
match-data being preserved across some fairly complicated code. This
is currently valid but will not be when this series is finished. Thus
place everything between the string-match and replace-match inside a
save-match-data.
This commit is contained in:
Mark Walters 2013-11-12 20:10:54 +00:00 committed by David Bremner
parent a5ecdf390e
commit 6f616bd733

View file

@ -273,11 +273,13 @@ prefix argument. PREFIX and TAIL are used internally."
"Like `substitute-command-keys' but with documentation, not function names." "Like `substitute-command-keys' but with documentation, not function names."
(let ((beg 0)) (let ((beg 0))
(while (string-match "\\\\{\\([^}[:space:]]*\\)}" doc beg) (while (string-match "\\\\{\\([^}[:space:]]*\\)}" doc beg)
(let ((desc
(save-match-data
(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-list (notmuch-describe-keymap keymap ua-keys)))
(desc (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)))
doc)) doc))