]> git.eshelyaron.com Git - emacs.git/commitdiff
Load site-start.el before early-init.el
authorSean Whitton <spwhitton@spwhitton.name>
Tue, 24 Jun 2025 16:33:39 +0000 (17:33 +0100)
committerEshel Yaron <me@eshelyaron.com>
Wed, 23 Jul 2025 19:15:19 +0000 (21:15 +0200)
* lisp/startup.el (command-line): Load site-start.el before
early-init.el.
(site-run-file):
* doc/lispref/os.texi (Startup Summary, Init File):
* etc/NEWS: Document the change.

(cherry picked from commit 192066d3b92a64a894def9dd9d5bd3040cc257ba)

doc/lispref/os.texi
etc/NEWS
lisp/startup.el

index 79001e761dca9e6a949b2e20e8a4a7e8d5014969..013c5b72203fc7f4fa5e2da87f2cc165cf69e8a0 100644 (file)
@@ -93,6 +93,11 @@ if requested by environment variables such as @env{LANG}.
 @item
 It does some basic parsing of the command-line arguments.
 
+@item
+It loads the library @file{site-start}, if it exists.  This is not
+done if the options @samp{-Q} or @samp{--no-site-file} were specified.
+@cindex @file{site-start.el}
+
 @item
 It loads your early init file (@pxref{Early Init File,,, emacs, The
 GNU Emacs Manual}).  This is not done if the options @samp{-q},
@@ -141,11 +146,6 @@ rather than build-time, context.
 @c @item
 @c It registers the colors available for tty frames.
 
-@item
-It loads the library @file{site-start}, if it exists.  This is not
-done if the options @samp{-Q} or @samp{--no-site-file} were specified.
-@cindex @file{site-start.el}
-
 @item
 It loads your init file (@pxref{Init File}).  This is not done if the
 options @samp{-q}, @samp{-Q}, or @samp{--batch} were specified.  If
@@ -409,9 +409,9 @@ loading of this file with the option @samp{--no-site-file}.
 
 @defopt site-run-file
 This variable specifies the site-customization file to load before the
-user's init file.  Its normal value is @code{"site-start"}.  The only
-way you can change it with real effect is to do so before dumping
-Emacs.
+user's early init file and regular init file.  Its normal value is
+@code{"site-start"}.  The only way you can change it with real effect is
+to do so before dumping Emacs.
 @c So why even mention it here.  I imagine it is almost never changed.
 @end defopt
 
index 3bb6b6f7496de3e2e722257cf20a5ccb1d9e68d4..83c8271c3da998188694120f17f03fc51b93afc6 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -51,6 +51,13 @@ OS selection instead of terminal-specific keybindings.
 You can keep the old behavior by putting `(xterm-mouse-mode -1)' in your
 init file.
 
++++
+** 'site-start.el' is now loaded before the user's early init file.
+Previously the order was early-init.el, site-start.el and then the
+user's regular init file, but now site-start.el comes first.  This
+allows site administrators to customize things that can normally only be
+done from early-init.el, such as adding to 'package-directory-list'.
+
 \f
 * Changes in Emacs 31.1
 
index 873488312cef3e85671a2b2324ee58ccfcc42b04..5c28084e9bc53b6b9686f6e24c2aeb687ac6a845 100644 (file)
@@ -321,7 +321,8 @@ This file is loaded at run-time before `user-init-file'.  It contains
 inits that need to be in place for the entire site, but which, due to
 their higher incidence of change, don't make sense to put into Emacs's
 dump file.  Thus, the run-time load order is: 1. file described in
-this variable, if non-nil; 2. `user-init-file'; 3. `default.el'.
+this variable, if non-nil; 2. `early-init-file', 3. `user-init-file';
+4. `default.el'.
 
 Don't use the `site-start.el' file for things some users may not like.
 Put them in `default.el' instead, so that users can more easily
@@ -1368,6 +1369,21 @@ please check its value")
            (setq xdg-dir (concat "~" init-file-user "/.config/emacs/"))
            (startup--xdg-or-homedot xdg-dir init-file-user)))
 
+    ;; Run the site-start library if it exists.
+    ;; This used to come after the early init file, but was moved here to
+    ;; make it possible for sites to do early init things on behalf of
+    ;; their users, such as adding to `package-directory-list'.
+    ;; This certainly has to come before loading the regular init file.
+    ;; Note that `user-init-file' is nil at this point.  Code that might
+    ;; be loaded from `site-run-file' and wants to test if -q was given
+    ;; should check `init-file-user' instead, since that is already set.
+    ;; See cus-edit.el for an example.
+    (when site-run-file
+      ;; Sites should not disable the startup screen.
+      ;; Only individuals may disable the startup screen.
+      (let ((inhibit-startup-screen inhibit-startup-screen))
+        (load site-run-file t t)))
+
     ;; Load the early init file, if found.
     (startup--load-user-init-file
      (lambda ()
@@ -1461,19 +1477,6 @@ please check its value")
     (let ((old-scalable-fonts-allowed scalable-fonts-allowed)
          (old-face-ignored-fonts face-ignored-fonts))
 
-      ;; Run the site-start library if it exists.  The point of this file is
-      ;; that it is run before .emacs.  There is no point in doing this after
-      ;; .emacs; that is useless.
-      ;; Note that user-init-file is nil at this point.  Code that might
-      ;; be loaded from site-run-file and wants to test if -q was given
-      ;; should check init-file-user instead, since that is already set.
-      ;; See cus-edit.el for an example.
-      (if site-run-file
-          ;; Sites should not disable the startup screen.
-          ;; Only individuals should disable the startup screen.
-          (let ((inhibit-startup-screen inhibit-startup-screen))
-           (load site-run-file t t)))
-
       ;; Load that user's init file, or the default one, or none.
       (startup--load-user-init-file
        (lambda ()