[PATCH v4 2/7] emacs: help: save-match-data

Mark Walters markwalters1009 at gmail.com
Tue Nov 12 12:10:54 PST 2013


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.
---
 emacs/notmuch-lib.el |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 5e734b3..6abc4ea 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -274,11 +274,13 @@ prefix argument.  PREFIX and TAIL are used internally."
   "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-list (notmuch-describe-keymap keymap ua-keys))
-	     (desc (mapconcat #'identity desc-list "\n")))
+      (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-list (notmuch-describe-keymap keymap ua-keys)))
+		 (mapconcat #'identity desc-list "\n")))))
 	(setq doc (replace-match desc 1 1 doc)))
       (setq beg (match-end 0)))
     doc))
-- 
1.7.9.1



More information about the notmuch mailing list