* 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`.
This commit is contained in:
Stefan Monnier 2021-01-05 17:57:15 -05:00
parent 048b1aaec8
commit 7d7bfbf034
4 changed files with 34 additions and 37 deletions

View file

@ -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)