]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/emacs-lisp/autoload.el: Improve last change
authorStefan Monnier <monnier@iro.umontreal.ca>
Tue, 5 Jan 2021 22:57:15 +0000 (17:57 -0500)
committerStefan Monnier <monnier@iro.umontreal.ca>
Tue, 5 Jan 2021 22:57:15 +0000 (17:57 -0500)
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
lisp/emacs-lisp/autoload.el
lisp/info.el
lisp/mail/rmail.el

index dfa8539c44f34746cc2b1b117a268663ed025f48..d9d0898dcb77afc189ef01107425bc6418f58d4b 100644 (file)
@@ -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))
index 77de05a6f680affb6fd97ddc0c3c137a07e67883..ec7492dd4b10085c4d19bf74c08051e1981cf0a8 100644 (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)
index ef94aa945f28887cc452bfdc3b20e0e1b2720474..62d7b583ff20efedf08f16e2619ec814d58ea958 100644 (file)
@@ -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.
index 69797837cd29785550caf8b53109a123e078c602..29460cc20f5d2061c4d5d98f8a57e5c0d9b2ec8c 100644 (file)
@@ -160,13 +160,6 @@ its character representation and its display representation.")
   :group 'rmail
   :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
@@ -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