summaryrefslogtreecommitdiff
path: root/lisp/subr.el
diff options
context:
space:
mode:
authorMark Oteiza <mvoteiza@udel.edu>2017-09-12 11:08:00 -0400
committerMark Oteiza <mvoteiza@udel.edu>2017-09-12 11:08:00 -0400
commit35c893ddaf21b93677850a69709b59630bb0feb7 (patch)
tree4b4a6f9755609940a542acbe639aefa295beb8d9 /lisp/subr.el
parent2ae46b4c0dabfea80883a294dff16e0eb7182d30 (diff)
downloademacs-35c893ddaf21b93677850a69709b59630bb0feb7.tar.gz
Move gensym to core Elisp
* doc/lispref/symbols.texi (Creating Symbols): Mention gensym right after make-symbol. * etc/NEWS: Mention. * lisp/emacs-lisp/cl-macs.el (cl--gensym-counter): Alias to gensym-counter. (cl-gensym): Alias to gensym. * lisp/emacs-lisp/cl.el: Remove gensym from list of aliases. * lisp/emacs-lisp/edebug.el (edebug-make-enter-wrapper): * lisp/emacs-lisp/ert-x.el (ert-with-message-capture): (ert--expand-should-1, ert--expand-should): (ert--should-error-handle-error): * lisp/emacs-lisp/generator.el (cps--gensym): * lisp/emacs-lisp/gv.el (setf): * lisp/emacs-lisp/inline.el (inline--do-letlisteval): * lisp/emacs-lisp/pcase.el (pcase--make-docstring, pcase-dolist): (pcase--funcall, pcase--u1): Use gensym. * lisp/subr.el (gensym-counter): New variable. (gensym): New function, assimilated from cl-lib.
Diffstat (limited to 'lisp/subr.el')
-rw-r--r--lisp/subr.el14
1 files changed, 14 insertions, 0 deletions
diff --git a/lisp/subr.el b/lisp/subr.el
index 2ad52f6a638..ebb8b53b502 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -280,6 +280,20 @@ without silencing all errors."
;;;; Basic Lisp functions.
+(defvar gensym-counter 0
+ "Number used to construct the name of the next symbol created by `gensym'.")
+
+(defun gensym (&optional prefix)
+ "Return a new uninterned symbol.
+The name is made by appending `gensym-counter' to PREFIX.
+PREFIX can be a string, and defaults to \"G\".
+If PREFIX is a number, it replaces the value of `gensym-counter'."
+ (let ((pfix (if (stringp prefix) prefix "G"))
+ (num (if (integerp prefix) prefix
+ (prog1 gensym-counter
+ (setq gensym-counter (1+ gensym-counter))))))
+ (make-symbol (format "%s%d" pfix num))))
+
(defun ignore (&rest _ignore)
"Do nothing and return nil.
This function accepts any number of arguments, but ignores them."