[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 7d7bfbf: * lisp/emacs-lisp/autoload.el: Improve last change
From: |
Stefan Monnier |
Subject: |
master 7d7bfbf: * lisp/emacs-lisp/autoload.el: Improve last change |
Date: |
Tue, 5 Jan 2021 17:57:51 -0500 (EST) |
branch: master
commit 7d7bfbf0346114b116e14a4338ea235d12674f13
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>
* 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/custom.el | 8 ++++++--
lisp/emacs-lisp/autoload.el | 31 ++++++++++++++++++-------------
lisp/info.el | 21 +++++++++------------
lisp/mail/rmail.el | 11 +----------
4 files changed, 34 insertions(+), 37 deletions(-)
diff --git a/lisp/custom.el b/lisp/custom.el
index dfa8539..d9d0898 100644
--- a/lisp/custom.el
+++ b/lisp/custom.el
@@ -161,7 +161,9 @@ set to nil, as the value is no longer rogue."
;; Whether automatically buffer-local.
buffer-local)
(unless (memq :group args)
- (custom-add-to-group (custom-current-group) symbol 'custom-variable))
+ (let ((cg (custom-current-group)))
+ (when cg
+ (custom-add-to-group cg symbol 'custom-variable))))
(while args
(let ((keyword (pop args)))
(unless (symbolp keyword)
@@ -525,7 +527,9 @@ If no such group is found, return nil."
"For customization option SYMBOL, handle keyword arguments ARGS.
Third argument TYPE is the custom option type."
(unless (memq :group args)
- (custom-add-to-group (custom-current-group) symbol type))
+ (let ((cg (custom-current-group)))
+ (when cg
+ (custom-add-to-group cg symbol type))))
(while args
(let ((arg (car args)))
(setq args (cdr args))
diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el
index 77de05a..ec7492d 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)
diff --git a/lisp/info.el b/lisp/info.el
index ef94aa9..62d7b58 100644
--- a/lisp/info.el
+++ b/lisp/info.el
@@ -160,17 +160,14 @@ A header-line does not scroll with the rest of the
buffer."
:version "24.4")
;; This is a defcustom largely so that we can get the benefit
-;; of custom-initialize-delay. Perhaps it would work to make it a
-;; defvar and explicitly give it a standard-value property, and
-;; call custom-initialize-delay on it.
-;; The progn forces the autoloader to include the whole thing, not
-;; just an abbreviated version. The value is initialized at startup
-;; time, when command-line calls custom-reevaluate-setting on all
-;; the defcustoms in custom-delayed-init-variables. This is
-;; somewhat sub-optimal, as ideally this should be done when Info
-;; mode is first invoked.
+;; of `custom-initialize-delay'. Perhaps it would work to make it a
+;; `defvar' and explicitly give it a `standard-value' property, and
+;; call `custom-initialize-delay' on it.
+;; The value is initialized at startup time, when command-line calls
+;; `custom-reevaluate-setting' on all the defcustoms in
+;; `custom-delayed-init-variables'. This is somewhat sub-optimal, as ideally
+;; this should be done when Info mode is first invoked.
;;;###autoload
-(progn
(defcustom Info-default-directory-list
(let* ((config-dir
(file-name-as-directory
@@ -232,8 +229,8 @@ the environment variable INFOPATH is set.
Although this is a customizable variable, that is mainly for technical
reasons. Normally, you should either set INFOPATH or customize
`Info-additional-directory-list', rather than changing this variable."
- :initialize 'custom-initialize-delay
- :type '(repeat directory)))
+ :initialize #'custom-initialize-delay
+ :type '(repeat directory))
(defvar Info-directory-list nil
"List of directories to search for Info documentation files.
diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el
index 6979783..29460cc 100644
--- a/lisp/mail/rmail.el
+++ b/lisp/mail/rmail.el
@@ -161,13 +161,6 @@ its character representation and its display
representation.")
:version "21.1")
;;;###autoload
-(put 'rmail-spool-directory 'standard-value
- '((cond ((file-exists-p "/var/mail") "/var/mail/")
- ((file-exists-p "/var/spool/mail") "/var/spool/mail/")
- ((memq system-type '(hpux usg-unix-v)) "/usr/mail/")
- (t "/usr/spool/mail/"))))
-
-;;;###autoload
(defcustom rmail-spool-directory
(purecopy
(cond ((file-exists-p "/var/mail")
@@ -181,12 +174,10 @@ its character representation and its display
representation.")
(t "/usr/spool/mail/")))
"Name of directory used by system mailer for delivering new mail.
Its name should end with a slash."
- :initialize 'custom-initialize-delay
+ :initialize #'custom-initialize-delay
:type 'directory
:group 'rmail)
-;;;###autoload(custom-initialize-delay 'rmail-spool-directory nil)
-
(defcustom rmail-movemail-program nil
"If non-nil, the file name of the `movemail' program."
:group 'rmail-retrieve
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 7d7bfbf: * lisp/emacs-lisp/autoload.el: Improve last change,
Stefan Monnier <=