From 7d7bfbf0346114b116e14a4338ea235d12674f13 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Tue, 5 Jan 2021 17:57:15 -0500 Subject: * lisp/emacs-lisp/autoload.el: Improve last change It turns out there were other places that used `custom-initialize-delay` on autoloaded variables and used various hacks to make it work with `autoload.el`. The new code makes those hacks unneeded. Also, there's no point trying to "optimize" those rare cases anyway, so I simplified the `autoload.el` code for those cases. (make-autoload): For non-trivial cases, just include the whole `defcustom` instead of trying to mimic it. * lisp/mail/rmail.el (rmail-spool-directory): Remove hacks. * lisp/info.el (Info-default-directory-list): Remove `progn` hack. * lisp/custom.el (custom-declare-variable) (custom-handle-all-keywords): Don't use pseudo-group `nil`. --- lisp/emacs-lisp/autoload.el | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'lisp/emacs-lisp/autoload.el') diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el index 77de05a6f68..ec7492dd4b1 100644 --- a/lisp/emacs-lisp/autoload.el +++ b/lisp/emacs-lisp/autoload.el @@ -220,22 +220,27 @@ expression, in which case we want to handle forms differently." ;; Convert defcustom to less space-consuming data. ((eq car 'defcustom) - (let ((varname (car-safe (cdr-safe form))) - (initializer (plist-get (nthcdr 4 form) :initialize)) - (init (car-safe (cdr-safe (cdr-safe form)))) - (doc (car-safe (cdr-safe (cdr-safe (cdr-safe form))))) - ;; (rest (cdr-safe (cdr-safe (cdr-safe (cdr-safe form))))) - ) + (let* ((varname (car-safe (cdr-safe form))) + (props (nthcdr 4 form)) + (initializer (plist-get props :initialize)) + (init (car-safe (cdr-safe (cdr-safe form)))) + (doc (car-safe (cdr-safe (cdr-safe (cdr-safe form))))) + ;; (rest (cdr-safe (cdr-safe (cdr-safe (cdr-safe form))))) + ) `(progn - ,(if (null initializer) - `(defvar ,varname ,init ,doc) - `(progn (defvar ,varname nil ,doc) - (let ((exp ',init)) - (put ',varname 'standard-value (list exp)) - (,(eval initializer t) ',varname exp)))) + ,(if (not (member initializer '(nil 'custom-initialize-default + #'custom-initialize-default + 'custom-initialize-reset + #'custom-initialize-reset))) + form + `(defvar ,varname ,init ,doc)) + ;; When we include the complete `form', this `custom-autoload' + ;; is not indispensable, but it still helps in case the `defcustom' + ;; doesn't specify its group explicitly, and probably in a few other + ;; corner cases. (custom-autoload ',varname ,file ,(condition-case nil - (null (cadr (memq :set form))) + (null (plist-get props :set)) (error nil)))))) ((eq car 'defgroup) -- cgit v1.2.1