aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Oteiza2017-09-18 09:00:45 -0400
committerMark Oteiza2017-09-18 09:00:45 -0400
commit331d0e520ff5a3599cc9958108a6b6b8cb277ce3 (patch)
treecdb5a3789c3959eb66103b76e12e5446fce52eeb
parent466df76f7df06a03760545fe03d71bc0dc7fe98f (diff)
downloademacs-331d0e520ff5a3599cc9958108a6b6b8cb277ce3.tar.gz
emacs-331d0e520ff5a3599cc9958108a6b6b8cb277ce3.zip
Fix gensym
* lisp/subr.el (gensym): Actually implement the default prefix. * test/lisp/subr-tests.el (subr-tests--gensym): New test.
-rw-r--r--lisp/subr.el2
-rw-r--r--test/lisp/subr-tests.el6
2 files changed, 7 insertions, 1 deletions
diff --git a/lisp/subr.el b/lisp/subr.el
index 79ae1f4830d..96b1ac19b4b 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -289,7 +289,7 @@ The name is made by appending `gensym-counter' to PREFIX.
289PREFIX is a string, and defaults to \"g\"." 289PREFIX is a string, and defaults to \"g\"."
290 (let ((num (prog1 gensym-counter 290 (let ((num (prog1 gensym-counter
291 (setq gensym-counter (1+ gensym-counter))))) 291 (setq gensym-counter (1+ gensym-counter)))))
292 (make-symbol (format "%s%d" prefix num)))) 292 (make-symbol (format "%s%d" (or prefix "g") num))))
293 293
294(defun ignore (&rest _ignore) 294(defun ignore (&rest _ignore)
295 "Do nothing and return nil. 295 "Do nothing and return nil.
diff --git a/test/lisp/subr-tests.el b/test/lisp/subr-tests.el
index ac9e2df603c..a68688eba7a 100644
--- a/test/lisp/subr-tests.el
+++ b/test/lisp/subr-tests.el
@@ -300,6 +300,12 @@ cf. Bug#25477."
300 (setq res (read-passwd "pass: " 'confirm (mapconcat #'string default ""))) 300 (setq res (read-passwd "pass: " 'confirm (mapconcat #'string default "")))
301 (should (string= default res))))) 301 (should (string= default res)))))
302 302
303(ert-deftest subr-tests--gensym ()
304 "Test `gensym' behavior."
305 (should (equal (symbol-name (let ((gensym-counter 0)) (gensym)))
306 "g0"))
307 (should (eq (string-to-char (symbol-name (gensym))) ?g))
308 (should (eq (string-to-char (symbol-name (gensym "X"))) ?X)))
303 309
304(provide 'subr-tests) 310(provide 'subr-tests)
305;;; subr-tests.el ends here 311;;; subr-tests.el ends here