From: John Wiegley Date: Tue, 5 Dec 2017 00:42:56 +0000 (-0800) Subject: Some Emacsen don't have gensym X-Git-Tag: emacs-29.0.90~1306^2~15^2~146 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=afdf1c363809e721a838f8e7d0b9b791f3138b52;p=emacs.git Some Emacsen don't have gensym Fixes https://github.com/jwiegley/use-package/issues/544 --- diff --git a/lisp/use-package/use-package-core.el b/lisp/use-package/use-package-core.el index f5f1f7e6bd8..727e0d647fa 100644 --- a/lisp/use-package/use-package-core.el +++ b/lisp/use-package/use-package-core.el @@ -276,6 +276,19 @@ Must be set before loading use-package." ;;; Utility functions ;; +(defvar use-package-gensym-counter 0 + "Number used to construct the name of the next symbol created +by `use-package-gensym'.") + +(defun use-package-gensym (&optional prefix) + "Return a new uninterned symbol. +The name is made by appending `gensym-counter' to PREFIX. +PREFIX is a string, and defaults to \"g\"." + (let ((num (prog1 use-package-gensym-counter + (setq use-package-gensym-counter + (1+ use-package-gensym-counter))))) + (make-symbol (format "%s%d" (or prefix "g") num)))) + (defsubst use-package-error (msg) "Report MSG as an error, so the user knows it came from this package." (error "use-package: %s" msg)) @@ -636,9 +649,9 @@ If ALLOW-EMPTY is non-nil, it's OK for ARGS to be an empty list." (defun use-package-memoize (f arg) "Ensure the macro-expansion of F applied to ARG evaluates ARG no more than once." - (let ((loaded (gensym "use-package--loaded")) - (result (gensym "use-package--result")) - (next (gensym "use-package--next"))) + (let ((loaded (use-package-gensym "use-package--loaded")) + (result (use-package-gensym "use-package--result")) + (next (use-package-gensym "use-package--next"))) `((lexical-let (,loaded ,result) (lexical-let ((,next (lambda () (if ,loaded @@ -921,7 +934,7 @@ representing symbols (that may need to be autloaded)." use-package--hush-function))) (defun use-package-handler/:catch (name keyword arg rest state) - (let* ((context (gensym "use-package--warning"))) + (let* ((context (use-package-gensym "use-package--warning"))) (cond ((not arg) (use-package-process-keywords name rest state))