From: Eli Zaretskii Date: Tue, 12 Jun 2018 15:03:56 +0000 (+0300) Subject: Fix initialization of custom-delayed-init-variables X-Git-Tag: emacs-27.0.90~4871 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=e9c189ccae342c63de2629c5a51d1f40d1a562b6;p=emacs.git Fix initialization of custom-delayed-init-variables * lisp/startup.el (command-line): Re-evaluate delayed-init custom variables one more time after setting up the initial window-system. (Bug#30994) * doc/emacs/custom.texi (Early Init File): * etc/NEWS: Warn against using early-init.el as a substitute for .emacs. --- diff --git a/doc/emacs/custom.texi b/doc/emacs/custom.texi index dbcc4c1fd1a..51e36ea4b75 100644 --- a/doc/emacs/custom.texi +++ b/doc/emacs/custom.texi @@ -2606,7 +2606,7 @@ Type @kbd{C-q}, followed by the key you want to bind, to insert @var{char}. @subsection The Early Init File @cindex early init file - Most customizations for Emacs can be put in the normal init file, + Most customizations for Emacs should be put in the normal init file, @file{.emacs} or @file{~/.emacs.d/init.el}. However, it is sometimes desirable to have customizations that take effect during Emacs startup earlier than the normal init file is processed. Such customizations can be put in the early @@ -2619,5 +2619,15 @@ which only affect the installation of new packages, and not the process of making already-installed packages available, may be customized in the regular init file. @xref{Package Installation}. + We do not recommend that you move into @file{early-init.el} +customizations that can be left in the normal init files. That is +because the early init file is read before the GUI is initialized, so +customizations related to GUI features will not work reliably in +@file{early-init.el}. By contrast, the normal init files are read +after the GUI is initialized. If you must have customizations in the +early init file that rely on GUI features, make them run off hooks +provided by the Emacs startup, such as @code{window-setup-hook} or +@code{tty-setup-hook}. @xref{Hooks}. + For more information on the early init file, @pxref{Init File,,, elisp, The Emacs Lisp Reference Manual}. diff --git a/etc/NEWS b/etc/NEWS index 402dcb13c7f..52cedc4d401 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -58,6 +58,13 @@ is initialized. The primary purpose is to allow customizing how the package system is initialized given that initialization now happens before loading the regular init file (see below). +We recommend against putting any customizations in this file that +don't need to be set up before initializing installed add-on packages, +because the early init file is read too early into the startup +process, and some important parts of the Emacs session, such as +window-system and other GUI features, are not yet set up, which could +make some customization fail to work. + +++ ** Installed packages are now activated *before* loading the init file. This is part of a change intended to eliminate the behavior of diff --git a/lisp/startup.el b/lisp/startup.el index 245b9ac5ba4..fdf6cc1dbaa 100644 --- a/lisp/startup.el +++ b/lisp/startup.el @@ -1126,11 +1126,11 @@ please check its value") ;; Re-evaluate predefined variables whose initial value depends on ;; the runtime context. (let (current-load-list) ; c-r-s may call defvar, and hence LOADHIST_ATTACH - (mapc 'custom-reevaluate-setting + (setq custom-delayed-init-variables ;; 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)))) + (nreverse custom-delayed-init-variables)) + (mapc 'custom-reevaluate-setting custom-delayed-init-variables)) ;; Warn for invalid user name. (when init-file-user @@ -1262,6 +1262,13 @@ please check its value") (startup--setup-quote-display) (setq internal--text-quoting-flag t)) + ;; Re-evaluate again the predefined variables whose initial value + ;; depends on the runtime context, in case some of them depend on + ;; the window-system features. Example: blink-cursor-mode. + (let (current-load-list) ; c-r-s may call defvar, and hence LOADHIST_ATTACH + (mapc 'custom-reevaluate-setting custom-delayed-init-variables) + (setq custom-delayed-init-variables nil)) + (normal-erase-is-backspace-setup-frame) ;; Register default TTY colors for the case the terminal hasn't a