1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-05 22:20:24 -08:00

Make cl-gensym obsolete in favor of built-in gensym

* lisp/emacs-lisp/cl-macs.el (cl-gensym): Declare function
obsolete in favor of gensym, added in Emacs 26.1.  The only reason
for its existence is that it allows an integer argument, but
that's not really useful, so it's better to remove this complexity.
Ref: https://lists.gnu.org/r/emacs-devel/2017-09/msg00313.html
* doc/misc/cl.texi (Symbols, Creating Symbols, Efficiency Concerns)
(Obsolete Setf Customization): Don't document above obsolete function.
* lisp/emacs-lisp/cl-macs.el (cl--parse-loop-clause):
* lisp/emacs-lisp/edebug.el (edebug-make-form-wrapper):
* lisp/obsolete/cl.el (cl--function-convert, lexical-let):
* lisp/obsolete/thumbs.el (thumbs-temp-file):
* lisp/progmodes/eglot.el (eglot--lambda)
(eglot--when-live-buffer, eglot--when-buffer-window)
(eglot--collecting-xrefs, eglot--glob-parse):
* lisp/progmodes/flymake.el (flymake--run-backend):
* test/lisp/emacs-lisp/package-tests.el (with-package-test):
* test/lisp/progmodes/eglot-tests.el (eglot--guessing-contact):
* test/lisp/progmodes/elisp-mode-tests.el
(elisp-shorthand-read-buffer, elisp-shorthand-read-from-string): Prefer
plain gensym to cl-gensym in files that can depend on Emacs 26.1.
* lisp/jsonrpc.el (jsonrpc-lambda, jsonrpc-request): Prefer gensym to
cl-gensym only when defined, as this file supports Emacs 25.1
* test/lisp/emacs-lisp/cl-macs-tests.el (cl-lib-test-gensym): Simplify
test as 'should' no longer uses cl-gensym.
This commit is contained in:
Stefan Kangas 2025-02-25 00:12:00 +01:00
parent 1a22bc0fd6
commit 60b071e224
13 changed files with 43 additions and 63 deletions

View file

@ -166,6 +166,7 @@ whether X is known at compile time, macroexpand it completely in
(defun cl-gensym (&optional prefix)
"Generate a new uninterned symbol.
The name is made by appending a number to PREFIX, default \"G\"."
(declare (obsolete gensym "31.1"))
(let ((pfix (if (stringp prefix) prefix "G"))
(num (if (integerp prefix) prefix
(prog1 cl--gensym-counter
@ -1270,10 +1271,10 @@ For more details, see Info node `(cl)Loop Facility'.
(let ((loop-for-bindings nil) (loop-for-sets nil) (loop-for-steps nil)
(ands nil))
(while
;; Use `cl-gensym' rather than `make-symbol'. It's important that
;; Use `gensym' rather than `make-symbol'. It's important that
;; (not (eq (symbol-name var1) (symbol-name var2))) because
;; these vars get added to the macro-environment.
(let ((var (or (pop cl--loop-args) (cl-gensym "--cl-var--"))))
(let ((var (or (pop cl--loop-args) (gensym "--cl-var--"))))
(setq word (pop cl--loop-args))
(if (eq word 'being) (setq word (pop cl--loop-args)))
(if (memq word '(the each)) (setq word (pop cl--loop-args)))