diff lisp/subr.el @ 1130:e18597ff3c95

*** empty log message ***
author Richard M. Stallman <rms@gnu.org>
date Sun, 13 Sep 1992 20:40:20 +0000
parents 1dba066c1e0a
children 45fbb83b8160
line wrap: on
line diff
--- a/lisp/subr.el	Sun Sep 13 19:05:13 1992 +0000
+++ b/lisp/subr.el	Sun Sep 13 20:40:20 1992 +0000
@@ -146,6 +146,15 @@
 	  (setcdr (car keymap) newdef))
       (setq keymap (cdr keymap)))))
 
+(defmacro save-match-data (&rest body)
+  "Execute the BODY forms, restoring the global value of the match data."
+  (let ((original (make-symbol "match-data")))
+    (list
+     'let (list (list original '(match-data)))
+     (list 'unwind-protect
+           (cons 'progn body)
+           (list 'store-match-data original)))))
+
 ;; Avoids useless byte-compilation.
 ;; In the future, would be better to fix byte compiler
 ;; not to really compile in cases like this,