From: Mark Oteiza Date: Mon, 18 Sep 2017 13:00:45 +0000 (-0400) Subject: Fix gensym X-Git-Tag: emacs-26.0.90~138 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=331d0e520f;p=emacs.git Fix gensym * lisp/subr.el (gensym): Actually implement the default prefix. * test/lisp/subr-tests.el (subr-tests--gensym): New test. --- 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. 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)))) + (make-symbol (format "%s%d" (or prefix "g") num)))) (defun ignore (&rest _ignore) "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." (setq res (read-passwd "pass: " 'confirm (mapconcat #'string default ""))) (should (string= default res))))) +(ert-deftest subr-tests--gensym () + "Test `gensym' behavior." + (should (equal (symbol-name (let ((gensym-counter 0)) (gensym))) + "g0")) + (should (eq (string-to-char (symbol-name (gensym))) ?g)) + (should (eq (string-to-char (symbol-name (gensym "X"))) ?X))) (provide 'subr-tests) ;;; subr-tests.el ends here