From adba8116c3a918f2f091600b60ea1700c9ea7362 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Sun, 13 Sep 2009 00:52:55 +0000 Subject: [PATCH] * mail/sendmail.el (send-mail-function): * tooltip.el (tooltip-mode): * simple.el (transient-mark-mode): * rfn-eshadow.el (file-name-shadow-mode): * frame.el (blink-cursor-mode): * font-core.el (global-font-lock-mode): * files.el (temporary-file-directory) (small-temporary-file-directory, auto-save-file-name-transforms): * epa-hook.el (auto-encryption-mode): * composite.el (global-auto-composition-mode): Use custom-initialize-delay. * startup.el (command-line): Don't explicitly call custom-reevaluate-setting for all the above vars. * custom.el (custom-initialize-safe-set) (custom-initialize-safe-default): Delete. --- lisp/ChangeLog | 18 ++++++++++++++++++ lisp/composite.el | 6 ++++-- lisp/custom.el | 26 ++++---------------------- lisp/epa-hook.el | 5 +++++ lisp/files.el | 3 +++ lisp/font-core.el | 5 +++-- lisp/frame.el | 2 +- lisp/mail/sendmail.el | 1 + lisp/rfn-eshadow.el | 5 +++++ lisp/simple.el | 1 + lisp/startup.el | 16 ---------------- lisp/tooltip.el | 2 +- 12 files changed, 46 insertions(+), 44 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 22207eec8f9..0165677e7cc 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,21 @@ +2009-09-13 Stefan Monnier + + * mail/sendmail.el (send-mail-function): + * tooltip.el (tooltip-mode): + * simple.el (transient-mark-mode): + * rfn-eshadow.el (file-name-shadow-mode): + * frame.el (blink-cursor-mode): + * font-core.el (global-font-lock-mode): + * files.el (temporary-file-directory) + (small-temporary-file-directory, auto-save-file-name-transforms): + * epa-hook.el (auto-encryption-mode): + * composite.el (global-auto-composition-mode): + Use custom-initialize-delay. + * startup.el (command-line): Don't explicitly call + custom-reevaluate-setting for all the above vars. + * custom.el (custom-initialize-safe-set) + (custom-initialize-safe-default): Delete. + 2009-09-12 Stefan Monnier * term/x-win.el (x-initialize-window-system): diff --git a/lisp/composite.el b/lisp/composite.el index 77eea9cb4ec..c9f16e2f518 100644 --- a/lisp/composite.el +++ b/lisp/composite.el @@ -773,8 +773,10 @@ Auto Composition mode in all buffers (this is the default)." ;;;###autoload (define-global-minor-mode global-auto-composition-mode auto-composition-mode turn-on-auto-composition-if-enabled - :extra-args (dummy) - :initialize 'custom-initialize-safe-default + ;; This :extra-args' appears to be the result of a naive copy&paste + ;; from global-font-lock-mode. + ;; :extra-args (dummy) + :initialize 'custom-initialize-delay :init-value (not noninteractive) :group 'auto-composition :version "23.1") diff --git a/lisp/custom.el b/lisp/custom.el index c6b8f2950e4..f55cd47afc0 100644 --- a/lisp/custom.el +++ b/lisp/custom.el @@ -74,28 +74,6 @@ if any, or VALUE." (eval (car (get symbol 'saved-value))) (eval value))))) -(defun custom-initialize-safe-set (symbol value) - "Like `custom-initialize-set', but catches errors. -If an error occurs during initialization, SYMBOL is set to nil -and no error is thrown. This is meant for use in pre-loaded files -where some variables or functions used to compute VALUE may not yet -be defined. You can then re-evaluate VALUE in startup.el, for instance -using `custom-reevaluate-setting'." - (condition-case nil - (custom-initialize-set symbol value) - (error (set-default symbol nil)))) - -(defun custom-initialize-safe-default (symbol value) - "Like `custom-initialize-default', but catches errors. -If an error occurs during initialization, SYMBOL is set to nil -and no error is thrown. This is meant for use in pre-loaded files -where some variables or functions used to compute VALUE may not yet -be defined. You can then re-evaluate VALUE in startup.el, for instance -using `custom-reevaluate-setting'." - (condition-case nil - (custom-initialize-default symbol value) - (error (set-default symbol nil)))) - (defun custom-initialize-reset (symbol value) "Initialize SYMBOL based on VALUE. Set the symbol, using its `:set' function (or `set-default' if it has none). @@ -139,6 +117,10 @@ 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." + ;; Until the var is actually initialized, it is kept unbound. + ;; This seemed to be at least as good as setting it to an arbitrary + ;; value like nil (evaluating `value' is not an option because it + ;; may have undesirable side-effects). (push symbol custom-delayed-init-variables)) (defun custom-declare-variable (symbol default doc &rest args) diff --git a/lisp/epa-hook.el b/lisp/epa-hook.el index 593b5dcf150..0987b2a221d 100644 --- a/lisp/epa-hook.el +++ b/lisp/epa-hook.el @@ -86,6 +86,11 @@ May either be a string or a list of strings.") With prefix argument ARG, turn auto encryption on if positive, else off. Return the new status of auto encryption (non-nil means on)." :global t :init-value t :group 'epa-file :version "23.1" + ;; We'd like to use custom-initialize-set here so the setup is done + ;; before dumping, but at the point where the defcustom is evaluated, + ;; the corresponding function isn't defined yet, so + ;; custom-initialize-set signals an error. + :initialize 'custom-initialize-delay (setq file-name-handler-alist (delq epa-file-handler file-name-handler-alist)) (remove-hook 'find-file-hooks 'epa-file-find-file-hook) diff --git a/lisp/files.el b/lisp/files.el index 5487b10eb2c..9d6218cc4eb 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -195,6 +195,7 @@ If the buffer is visiting a new file, the value is nil.") (or (getenv "TMPDIR") (getenv "TMP") (getenv "TEMP") "/tmp")))) "The directory for writing temporary files." :group 'files + :initialize 'custom-initialize-delay :type 'directory) (defcustom small-temporary-file-directory @@ -204,6 +205,7 @@ If non-nil, this directory is used instead of `temporary-file-directory' by programs that create small temporary files. This is for systems that have fast storage with limited space, such as a RAM disk." :group 'files + :initialize 'custom-initialize-delay :type '(choice (const nil) directory)) ;; The system null device. (Should reference NULL_DEVICE from C.) @@ -385,6 +387,7 @@ ignored." :group 'auto-save :type '(repeat (list (string :tag "Regexp") (string :tag "Replacement") (boolean :tag "Uniquify"))) + :initialize 'custom-initialize-delay :version "21.1") (defcustom save-abbrevs t diff --git a/lisp/font-core.el b/lisp/font-core.el index 0ba7295cc06..7112b6b227c 100644 --- a/lisp/font-core.el +++ b/lisp/font-core.el @@ -299,8 +299,9 @@ means that Font Lock mode is turned on for buffers in C and C++ modes only." (define-globalized-minor-mode global-font-lock-mode font-lock-mode turn-on-font-lock-if-desired - :extra-args (dummy) - :initialize 'custom-initialize-safe-default + ;; What was this :extra-args thingy for? --Stef + ;; :extra-args (dummy) + :initialize 'custom-initialize-delay :init-value (not (or noninteractive emacs-basic-display)) :group 'font-lock :version "22.1") diff --git a/lisp/frame.el b/lisp/frame.el index 35cbbfbe1a2..e5d92fa1df3 100644 --- a/lisp/frame.el +++ b/lisp/frame.el @@ -1605,7 +1605,7 @@ cursor display. On a text-only terminal, this is not implemented." no-blinking-cursor (eq system-type 'ms-dos) (not (memq window-system '(x w32))))) - :initialize 'custom-initialize-safe-default + :initialize 'custom-initialize-delay :group 'cursor :global t (if blink-cursor-idle-timer (cancel-timer blink-cursor-idle-timer)) diff --git a/lisp/mail/sendmail.el b/lisp/mail/sendmail.el index 7d34aee05eb..955e424cf23 100644 --- a/lisp/mail/sendmail.el +++ b/lisp/mail/sendmail.el @@ -168,6 +168,7 @@ This is used by the default mail-sending commands. See also (function-item feedmail-send-it :tag "Use Feedmail package") (function-item mailclient-send-it :tag "Use Mailclient package") function) + :initialize 'custom-initialize-delay :group 'sendmail) ;;;###autoload diff --git a/lisp/rfn-eshadow.el b/lisp/rfn-eshadow.el index eb54636e105..5788ab7447b 100644 --- a/lisp/rfn-eshadow.el +++ b/lisp/rfn-eshadow.el @@ -216,6 +216,11 @@ that portion dim, invisible, or otherwise less visually noticeable. With prefix argument ARG, turn on if positive, otherwise off. Returns non-nil if the new state is enabled." :global t + ;; We'd like to use custom-initialize-set here so the setup is done + ;; before dumping, but at the point where the defcustom is evaluated, + ;; the corresponding function isn't defined yet, so + ;; custom-initialize-set signals an error. + :initialize 'custom-initialize-delay :init-value t :group 'minibuffer :version "22.1" diff --git a/lisp/simple.el b/lisp/simple.el index f318d496776..a34d8937cd8 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -3898,6 +3898,7 @@ Invoke \\[apropos-documentation] and type \"transient\" or commands which are sensitive to the Transient Mark mode." :global t :init-value (not noninteractive) + :initialize 'custom-initialize-delay :group 'editing-basics) ;; The variable transient-mark-mode is ugly: it can take on special diff --git a/lisp/startup.el b/lisp/startup.el index d5133290ba8..14758727c02 100644 --- a/lisp/startup.el +++ b/lisp/startup.el @@ -698,10 +698,6 @@ opening the first frame (e.g. open a connection to an X server).") after-init-time nil command-line-default-directory default-directory) - ;; Choose a reasonable location for temporary files. - (custom-reevaluate-setting 'temporary-file-directory) - (custom-reevaluate-setting 'small-temporary-file-directory) - (custom-reevaluate-setting 'auto-save-file-name-transforms) ;; Force recomputation, in case it was computed during the dump. (setq abbreviated-home-dir nil) @@ -914,18 +910,6 @@ opening the first frame (e.g. open a connection to an X server).") ;; 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) - (custom-reevaluate-setting 'tooltip-mode) - (custom-reevaluate-setting 'global-font-lock-mode) - (custom-reevaluate-setting 'file-name-shadow-mode) - (custom-reevaluate-setting 'send-mail-function) - (custom-reevaluate-setting 'focus-follows-mouse) - (custom-reevaluate-setting 'global-auto-composition-mode) - (custom-reevaluate-setting 'transient-mark-mode) - (custom-reevaluate-setting 'auto-encryption-mode) (normal-erase-is-backspace-setup-frame) diff --git a/lisp/tooltip.el b/lisp/tooltip.el index 6c34e950268..49ecaffd0e6 100644 --- a/lisp/tooltip.el +++ b/lisp/tooltip.el @@ -52,7 +52,7 @@ the help text in the echo area, and does not make a pop-up window." ;; Even if we start on a text-only terminal, make this non-nil by ;; default because we can open a graphical frame later (multi-tty). :init-value t - :initialize 'custom-initialize-safe-default + :initialize 'custom-initialize-delay :group 'tooltip (unless (or (null tooltip-mode) (fboundp 'x-show-tip)) (error "Sorry, tooltips are not yet available on this system")) -- 2.39.2