[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Semantics of autoload cookies on defcustoms
From: |
Stefan Monnier |
Subject: |
Re: Semantics of autoload cookies on defcustoms |
Date: |
Thu, 13 Jul 2006 17:13:50 -0400 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) |
>> Perhaps a good way to implement that is to write another argument into
>> the custom-autoload call. That optional argument, if non-nil, would
>> specify this new combination of behaviors that I called #3.
>> The decision could be based on the presence of :set.
> Well, there's no need for an extra arg: we just then skip the
> custom-autoload and that should be all there is to it.
> How 'bout the patch below?
> What it does is the following:
> 1 - remove the minor-mode stuff which is unnecessary anyway (since the
> custom-autoload line added just above already ensures that the package
> gets loaded (which adds the setter) before the variable is custom-set).
> 2 - only add the custom-autoload line for those defcustom that have a setter
> since it seems to be the only ones that need it.
> I guess this isn't quite right tho: the var should still cause autoloading
> if we want customize it (since it needs to go fetch the :type at the very
> least). Is that what you meant by an additional arg to custom-autoload?
Here is a patch which I believe does it better:
- Add an arg to custom-autoload to mean that the variable should only be
autoloaded for operations other than just `set'.
- Use this arg in autoload.el so that `set' only autoloads those variables
that use a setter function.
- change custom.el so as to obey this new autoload alternative.
- change cus-edit.el to deal with the fact that those variables that have
an autoload cookie but that are not autoloaded (because they don't have
a setter) are not mistakenly marked as "changed outside customize".
With this patch, my Emacs starts up noticeably faster.
Should I install it? Could some custom-theme specialist sanity-check it?
Stefan
Index: lisp/emacs-lisp/autoload.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/emacs-lisp/autoload.el,v
retrieving revision 1.116
diff -u -r1.116 autoload.el
--- lisp/emacs-lisp/autoload.el 13 Jul 2006 18:13:06 -0000 1.116
+++ lisp/emacs-lisp/autoload.el 13 Jul 2006 19:29:16 -0000
@@ -124,7 +124,10 @@
)
`(progn
(defvar ,varname ,init ,doc)
- (custom-autoload ',varname ,file))))
+ (custom-autoload ',varname ,file
+ ,(condition-case nil
+ (null (cadr (memq :set form)))
+ (error nil))))))
((eq car 'defgroup)
;; In Emacs this is normally handled separately by cus-dep.el, but for
Index: lisp/custom.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/custom.el,v
retrieving revision 1.127
diff -u -r1.127 custom.el
--- lisp/custom.el 13 May 2006 16:16:43 -0000 1.127
+++ lisp/custom.el 13 Jul 2006 19:29:16 -0000
@@ -558,9 +558,10 @@
(unless (member load loads)
(put symbol 'custom-loads (cons (purecopy load) loads)))))
-(defun custom-autoload (symbol load)
- "Mark SYMBOL as autoloaded custom variable and add dependency LOAD."
- (put symbol 'custom-autoload t)
+(defun custom-autoload (symbol load &optional noset)
+ "Mark SYMBOL as autoloaded custom variable and add dependency LOAD.
+If NOSET is non-nil, don't bother autoloading LOAD when setting the variable."
+ (put symbol 'custom-autoload (if noset 'noset t))
(custom-add-load symbol load))
;; This test is also in the C code of `user-variable-p'.
@@ -827,9 +828,6 @@
(if (and (eq prop 'theme-value)
(boundp symbol))
(let ((sv (get symbol 'standard-value)))
- (when (and (null sv) (custom-variable-p symbol))
- (custom-load-symbol symbol)
- (setq sv (get symbol 'standard-value)))
(unless (and sv
(equal (eval (car sv)) (symbol-value symbol)))
(setq old (list (list 'changed (symbol-value symbol))))))
@@ -907,6 +904,10 @@
(when requests
(put symbol 'custom-requests requests)
(mapc 'require requests))
+ (unless (or (get symbol 'standard-value)
+ (memq (get symbol 'custom-autoload) '(nil noset)))
+ ;; This symbol needs to be autoloaded, even just for a `set'.
+ (custom-load-symbol symbol))
(setq set (or (get symbol 'custom-set) 'custom-set-default))
(put symbol 'saved-value (list value))
(put symbol 'saved-variable-comment comment)
Index: lisp/cus-edit.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/cus-edit.el,v
retrieving revision 1.296
diff -u -r1.296 cus-edit.el
--- lisp/cus-edit.el 12 Jul 2006 15:56:33 -0000 1.296
+++ lisp/cus-edit.el 13 Jul 2006 19:29:16 -0000
@@ -2668,7 +2668,18 @@
(error nil))
(cond
((eq (caar tmp) 'user) 'saved)
- ((eq (caar tmp) 'changed) 'changed)
+ ((eq (caar tmp) 'changed)
+ (if (condition-case nil
+ (and (null comment)
+ (equal value
+ (eval
+ (car (get symbol
'standard-value)))))
+ (error nil))
+ ;; The value was originally set outside
+ ;; custom, but it was set to the standard
+ ;; value (probably an autoloaded defcustom).
+ 'standard
+ 'changed))
(t 'themed))
'changed))
((setq tmp (get symbol 'standard-value))
- Re: Semantics of autoload cookies on defcustoms, (continued)
- Re: Semantics of autoload cookies on defcustoms, Stefan Monnier, 2006/07/07
- Re: Semantics of autoload cookies on defcustoms, Richard Stallman, 2006/07/07
- Re: Semantics of autoload cookies on defcustoms, Stefan Monnier, 2006/07/07
- Re: Semantics of autoload cookies on defcustoms, Richard Stallman, 2006/07/08
- Re: Semantics of autoload cookies on defcustoms, Stefan Monnier, 2006/07/09
- Re: Semantics of autoload cookies on defcustoms, Richard Stallman, 2006/07/09
- Re: Semantics of autoload cookies on defcustoms, Stefan Monnier, 2006/07/10
- Re: Semantics of autoload cookies on defcustoms, Richard Stallman, 2006/07/11
- Re: Semantics of autoload cookies on defcustoms,
Stefan Monnier <=
- Re: Semantics of autoload cookies on defcustoms, Richard Stallman, 2006/07/16
- Re: Semantics of autoload cookies on defcustoms, Stefan Monnier, 2006/07/22