diff options
author | Mark Oteiza <mvoteiza@udel.edu> | 2017-09-13 10:38:05 -0400 |
---|---|---|
committer | Mark Oteiza <mvoteiza@udel.edu> | 2017-09-13 10:38:05 -0400 |
commit | 912826a829fc5e95d677f48b72413dccd216c6e1 (patch) | |
tree | 48c7baa2d35371064060c8c442b1aa5bebdb1aa8 | |
parent | 3d96fc15362453f43f3f04ffa288a57ee1e633c3 (diff) | |
download | emacs-912826a829fc5e95d677f48b72413dccd216c6e1.tar.gz |
Remove "baroque" use of prefix argument from gensym
'cl-gensym' was simply moved here, but let us take an opportunity to
shed some historical baggage.
* lisp/subr.el (gensym): Remove special treatment of PREFIX as a
number. Use "g" as prefix to differentiate from cl-gensym defaults.
* doc/lispref/symbols.texi (Creating Symbols): Update accordingly.
* lisp/emacs-lisp/cl-macs.el (cl--gensym-counter, cl-gensym): Restore.
-rw-r--r-- | doc/lispref/symbols.texi | 3 | ||||
-rw-r--r-- | lisp/emacs-lisp/cl-macs.el | 11 | ||||
-rw-r--r-- | lisp/subr.el | 11 |
3 files changed, 14 insertions, 11 deletions
diff --git a/doc/lispref/symbols.texi b/doc/lispref/symbols.texi index 2d9ec6fda30..cda5f1c40f6 100644 --- a/doc/lispref/symbols.texi +++ b/doc/lispref/symbols.texi @@ -276,8 +276,7 @@ distinct uninterned symbol whose name is also @samp{foo}. @defun gensym &optional prefix This function returns a symbol using @code{make-symbol}, whose name is made by appending @code{gensym-counter} to @var{prefix}. The prefix -defaults to @code{"G"}. If @var{prefix} is a number, it replaces the -value of the counter. +defaults to @code{"g"}. @end defun @defun intern name &optional obarray diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el index eee5953882d..3405c92e8d4 100644 --- a/lisp/emacs-lisp/cl-macs.el +++ b/lisp/emacs-lisp/cl-macs.el @@ -161,9 +161,16 @@ whether X is known at compile time, macroexpand it completely in ;;; Symbols. -(defvaralias 'cl--gensym-counter 'gensym-counter) +(defvar cl--gensym-counter 0) ;;;###autoload -(cl--defalias 'cl-gensym 'gensym) +(defun cl-gensym (&optional prefix) + "Generate a new uninterned symbol. +The name is made by appending a number to PREFIX, default \"G\"." + (let ((pfix (if (stringp prefix) prefix "G")) + (num (if (integerp prefix) prefix + (prog1 cl--gensym-counter + (setq cl--gensym-counter (1+ cl--gensym-counter)))))) + (make-symbol (format "%s%d" pfix num)))) (defvar cl--gentemp-counter 0) ;;;###autoload diff --git a/lisp/subr.el b/lisp/subr.el index ebb8b53b502..52d4e190e73 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -286,13 +286,10 @@ without silencing all errors." (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)))) +PREFIX is a string, and defaults to \"g\"." + (let ((num (prog1 gensym-counter + (setq gensym-counter (1+ gensym-counter))))) + (make-symbol (format "%s%d" prefix num)))) (defun ignore (&rest _ignore) "Do nothing and return nil. |