]> git.notmuchmail.org Git - notmuch/commitdiff
emacs: help: save-match-data
authorMark Walters <markwalters1009@gmail.com>
Tue, 12 Nov 2013 20:10:54 +0000 (20:10 +0000)
committerDavid Bremner <david@tethera.net>
Thu, 14 Nov 2013 01:33:14 +0000 (21:33 -0400)
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

index 4c615474dd0e012a4216e316dd4bf1f4bef6a573..623f4fad1d4df630136a79b33cc09348d0a85fd0 100644 (file)
@@ -273,11 +273,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))