changeset 104961:0ea87b098bb0

* custom.el (custom-delayed-init-variables): New var. (custom-initialize-delay): New function. * startup.el (command-line): "Re"evaluate all vars in custom-delayed-init-variables. Don't reevaluate abbrev-file-name explicitly any more. * abbrev.el (abbrev-file-name): Use custom-initialize-delay to avoid creating a ~/.emacs.d at build-time (bug#4347).
author Stefan Monnier <monnier@iro.umontreal.ca>
date Fri, 11 Sep 2009 21:25:44 +0000
parents ddca2477302b
children 7913b528a7e3
files lisp/ChangeLog lisp/abbrev.el lisp/custom.el lisp/startup.el
diffstat 4 files changed, 30 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Fri Sep 11 21:07:02 2009 +0000
+++ b/lisp/ChangeLog	Fri Sep 11 21:25:44 2009 +0000
@@ -1,6 +1,14 @@
 2009-09-11  Stefan Monnier  <monnier@iro.umontreal.ca>
 
-	* proced.el (proced-mode-map): Prefer "m" for proced-mark.
+	* custom.el (custom-delayed-init-variables): New var.
+	(custom-initialize-delay): New function.
+	* startup.el (command-line): "Re"evaluate all vars in
+	custom-delayed-init-variables.  Don't reevaluate abbrev-file-name
+	explicitly any more.
+	* abbrev.el (abbrev-file-name): Use custom-initialize-delay
+	to avoid creating a ~/.emacs.d at build-time (bug#4347).
+
+	* proced.el (proced-mode-map): Prefer "m" for proced-mark (bug#4362).
 
 2009-09-11  Nick Roberts  <nickrob@snap.net.nz>
 
--- a/lisp/abbrev.el	Fri Sep 11 21:07:02 2009 +0000
+++ b/lisp/abbrev.el	Fri Sep 11 21:25:44 2009 +0000
@@ -40,7 +40,8 @@
 
 (defcustom abbrev-file-name
   (locate-user-emacs-file "abbrev_defs" ".abbrev_defs")
-  "Default name of file to read abbrevs from."
+  "Default name of file from which to read abbrevs."
+  :initialize 'custom-initialize-delay
   :type 'file)
 
 (defcustom only-global-abbrevs nil
--- a/lisp/custom.el	Fri Sep 11 21:07:02 2009 +0000
+++ b/lisp/custom.el	Fri Sep 11 21:25:44 2009 +0000
@@ -130,6 +130,17 @@
 	(t
 	 (set-default symbol (eval value)))))
 
+(defvar custom-delayed-init-variables nil
+  "List of variables whose initialization is pending.")
+
+(defun custom-initialize-delay (symbol value)
+  "Delay initialization of SYMBOL to the next Emacs start.
+This is used in files that are preloaded, so that the initialization is
+done in the run-time context rather than the build-time context.
+This also has the side-effect that the (delayed) initialization is performed
+with the :setter."
+  (push symbol custom-delayed-init-variables))
+
 (defun custom-declare-variable (symbol default doc &rest args)
   "Like `defcustom', but SYMBOL and DEFAULT are evaluated as normal arguments.
 DEFAULT should be an expression to evaluate to compute the default value,
--- a/lisp/startup.el	Fri Sep 11 21:07:02 2009 +0000
+++ b/lisp/startup.el	Fri Sep 11 21:25:44 2009 +0000
@@ -703,7 +703,6 @@
   (custom-reevaluate-setting 'temporary-file-directory)
   (custom-reevaluate-setting 'small-temporary-file-directory)
   (custom-reevaluate-setting 'auto-save-file-name-transforms)
-  (custom-reevaluate-setting 'abbrev-file-name)
   ;; Force recomputation, in case it was computed during the dump.
   (setq abbreviated-home-dir nil)
 
@@ -909,6 +908,14 @@
       ;; Otherwise, enable tool-bar-mode.
       (tool-bar-mode 1)))
 
+  ;; Re-evaluate predefined variables whose initial value depends on
+  ;; the runtime context.
+  (mapc 'custom-reevaluate-setting
+        ;; Initialize them in the same order they were loaded, in case there
+        ;; are dependencies between them.
+        (prog1 (nreverse custom-delayed-init-variables)
+          (setq custom-delayed-init-variables nil)))
+  
   ;; Can't do this init in defcustom because the relevant variables
   ;; are not set.
   (custom-reevaluate-setting 'blink-cursor-mode)