diff --git a/doc/misc/cl.texi b/doc/misc/cl.texi index 862b8f4a1c4..b4c1f29f47f 100644 --- a/doc/misc/cl.texi +++ b/doc/misc/cl.texi @@ -1370,7 +1370,7 @@ expansion of another macro: @example (cl-defmacro my-dolist ((x list) &rest body) - (let ((var (cl-gensym))) + (cl-with-gensyms (var) (list 'cl-loop 'for var 'on list 'do (cl-list* 'cl-symbol-macrolet (list (list x (list 'car var))) diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index e7ccbbf12c7..6ad00f63971 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -953,7 +953,7 @@ Points to the next slot to be filled.") Restore the original value afterwards." (declare (debug (form body)) (indent defun)) - (let ((sym (gensym))) + (cl-with-gensyms (sym) `(let ((,sym (comp--sp))) (setf (comp--sp) ,sp) (progn ,@body) diff --git a/lisp/emacs-lisp/subr-x.el b/lisp/emacs-lisp/subr-x.el index 27e039eff9b..4ce7bd00f31 100644 --- a/lisp/emacs-lisp/subr-x.el +++ b/lisp/emacs-lisp/subr-x.el @@ -551,8 +551,7 @@ as changes in text properties, `buffer-file-coding-system', buffer multibyteness, etc. -- will not be noticed, and the buffer will still be marked unmodified, effectively ignoring those changes." (declare (debug t) (indent 0)) - (let ((hash (gensym)) - (buffer (gensym))) + (cl-with-gensyms (hash buffer) `(let ((,hash (and (not (buffer-modified-p)) (buffer-hash))) (,buffer (current-buffer))) diff --git a/lisp/eshell/em-extpipe.el b/lisp/eshell/em-extpipe.el index 6a061dad89e..c5170fed830 100644 --- a/lisp/eshell/em-extpipe.el +++ b/lisp/eshell/em-extpipe.el @@ -69,7 +69,7 @@ again." If `eshell-incomplete' is thrown during the evaluation of a disjunct, that disjunct yields nil." - (let ((result (gensym))) + (cl-with-gensyms (result) `(let (,result) (or ,@(cl-loop for disjunct in disjuncts collect `(if (catch 'eshell-incomplete diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el index 991fa589782..8b373ec11a5 100644 --- a/lisp/international/mule-cmds.el +++ b/lisp/international/mule-cmds.el @@ -2668,7 +2668,7 @@ but this macro does not by itself perform redisplay. If BODY needs to display something with LOCALE-NAME's settings, include a call to `redraw-frame' in BODY." (declare (indent 1) (debug (sexp def-body))) - (let ((current (gensym))) + (cl-with-gensyms (current) `(let ((,current current-locale-environment)) (unwind-protect (progn diff --git a/lisp/kmacro.el b/lisp/kmacro.el index 5092429afa3..43d0bfa23aa 100644 --- a/lisp/kmacro.el +++ b/lisp/kmacro.el @@ -1678,7 +1678,7 @@ line after applying FUNCTION." (defun kmacro-menu--marks-exist-p () "Return non-nil if markers exist for any table entries." - (let ((tag (gensym))) + (cl-with-gensyms (tag) (catch tag (kmacro-menu--map-ids (lambda (id) (when (alist-get (kmacro-menu--id-position id) diff --git a/test/lisp/emacs-lisp/cl-extra-tests.el b/test/lisp/emacs-lisp/cl-extra-tests.el index 41753194c1b..20d1e532a6f 100644 --- a/test/lisp/emacs-lisp/cl-extra-tests.el +++ b/test/lisp/emacs-lisp/cl-extra-tests.el @@ -23,7 +23,7 @@ (require 'ert) (ert-deftest cl-lib-test-remprop () - (let ((x (cl-gensym))) + (cl-with-gensyms (x) (should (equal (symbol-plist x) '())) ;; Remove nonexistent property on empty plist. (cl-remprop x 'b) diff --git a/test/lisp/emacs-lisp/edebug-tests.el b/test/lisp/emacs-lisp/edebug-tests.el index 02eadd34c8d..7daacea7925 100644 --- a/test/lisp/emacs-lisp/edebug-tests.el +++ b/test/lisp/emacs-lisp/edebug-tests.el @@ -321,8 +321,7 @@ NAME should be a string and NAMES-AND-NUMBERS an alist which can be used by this macro to retain state. If NAME for example is \"symbol\" then the first and subsequent uses of this macro will evaluate to \"symbol\", \"symbol-1\", \"symbol-2\", etc." - (let ((g-name (gensym)) - (g-duplicate (gensym))) + (cl-with-gensyms (g-name g-duplicate) `(let* ((,g-name ,name) (,g-duplicate (assoc ,g-name ,names-and-numbers))) (if (null ,g-duplicate) diff --git a/test/lisp/emacs-lisp/ert-tests.el b/test/lisp/emacs-lisp/ert-tests.el index d4370366b39..aec2c92ba81 100644 --- a/test/lisp/emacs-lisp/ert-tests.el +++ b/test/lisp/emacs-lisp/ert-tests.el @@ -617,7 +617,7 @@ This macro is used to test if macroexpansion in `should' works." (should (ert--special-operator-p 'if)) (should-not (ert--special-operator-p 'car)) (should-not (ert--special-operator-p 'ert--special-operator-p)) - (let ((b (cl-gensym))) + (cl-with-gensyms (b) (should-not (ert--special-operator-p b)) (fset b 'if) (should (ert--special-operator-p b)))) diff --git a/test/lisp/kmacro-tests.el b/test/lisp/kmacro-tests.el index e4641cfc4e5..86adcbf3a30 100644 --- a/test/lisp/kmacro-tests.el +++ b/test/lisp/kmacro-tests.el @@ -24,6 +24,7 @@ ;;; Code: (require 'kmacro) +(require 'cl-lib) (require 'seq) (require 'ert) (require 'ert-x) @@ -157,8 +158,7 @@ Execute BODY, then check that the string VALUE was inserted into the current buffer at point." (declare (debug (stringp body)) (indent 1)) - (let ((g-p (cl-gensym)) - (g-bsize (cl-gensym))) + (cl-with-gensyms (g-p g-bsize) `(let ((,g-p (point)) (,g-bsize (buffer-size))) ,@body @@ -172,7 +172,7 @@ VALUE and any text written to *Messages* during the execution, cause the current test to fail." (declare (debug (form body)) (indent 1)) - (let ((g-captured-messages (cl-gensym))) + (cl-with-gensyms (g-captured-messages) `(ert-with-message-capture ,g-captured-messages ,@body (should (string-match-p ,value ,g-captured-messages))))) diff --git a/test/lisp/replace-tests.el b/test/lisp/replace-tests.el index 51f7ddb25f0..fd3ecda2b72 100644 --- a/test/lisp/replace-tests.el +++ b/test/lisp/replace-tests.el @@ -528,8 +528,7 @@ then replace 3 matches of FROM with TO, and undo the last replacement. Return the last evalled form in BODY." (declare (indent 5) (debug (stringp stringp stringp form characterp body))) - (let ((text (gensym "text")) - (count (gensym "count"))) + (cl-with-gensyms (text count) `(let* ((,text ,input) (,count 0) (inhibit-message t))