aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias EngdegÄrd2022-09-07 17:55:44 +0200
committerMattias EngdegÄrd2022-09-07 18:02:26 +0200
commit35b4205dee6c65e3e0fd00708eb95c84f2ca49e6 (patch)
tree882fdfd19b1b4ed109e985478047156485575a10
parente1282c8c66f228d45b03fd7109ffe6bc7ea201a9 (diff)
downloademacs-35b4205dee6c65e3e0fd00708eb95c84f2ca49e6.tar.gz
emacs-35b4205dee6c65e3e0fd00708eb95c84f2ca49e6.zip
Improve save-match-data hygiene
* lisp/subr.el (save-match-data): Use uninterned variable symbol. Remove outdated comments.
-rw-r--r--lisp/subr.el17
1 files changed, 6 insertions, 11 deletions
diff --git a/lisp/subr.el b/lisp/subr.el
index 03d678f20d7..c7b86c83e8c 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -4956,10 +4956,6 @@ If `default-directory' is already an existing directory, it's not changed."
4956 4956
4957;;; Matching and match data. 4957;;; Matching and match data.
4958 4958
4959;; We use save-match-data-internal as the local variable because
4960;; that works ok in practice (people should not use that variable elsewhere).
4961;; We used to use an uninterned symbol; the compiler handles that properly
4962;; now, but it generates slower code.
4963(defmacro save-match-data (&rest body) 4959(defmacro save-match-data (&rest body)
4964 "Execute the BODY forms, restoring the global value of the match data. 4960 "Execute the BODY forms, restoring the global value of the match data.
4965The value returned is the value of the last form in BODY. 4961The value returned is the value of the last form in BODY.
@@ -4971,13 +4967,12 @@ rather than your caller's match data."
4971 ;; because that makes a bootstrapping problem 4967 ;; because that makes a bootstrapping problem
4972 ;; if you need to recompile all the Lisp files using interpreted code. 4968 ;; if you need to recompile all the Lisp files using interpreted code.
4973 (declare (indent 0) (debug t)) 4969 (declare (indent 0) (debug t))
4974 (list 'let 4970 (let ((saved-match-data (make-symbol "saved-match-data")))
4975 '((save-match-data-internal (match-data))) 4971 (list 'let
4976 (list 'unwind-protect 4972 (list (list saved-match-data '(match-data)))
4977 (cons 'progn body) 4973 (list 'unwind-protect
4978 ;; It is safe to free (evaporate) markers immediately here, 4974 (cons 'progn body)
4979 ;; as Lisp programs should not copy from save-match-data-internal. 4975 (list 'set-match-data saved-match-data t)))))
4980 '(set-match-data save-match-data-internal 'evaporate))))
4981 4976
4982(defun match-string (num &optional string) 4977(defun match-string (num &optional string)
4983 "Return the string of text matched by the previous search or regexp operation. 4978 "Return the string of text matched by the previous search or regexp operation.