aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorRadon Rosborough2018-02-17 13:36:16 +0200
committerEli Zaretskii2018-02-17 13:36:16 +0200
commit24acb31c04b4048b85311d794e600ecd7ce60d3b (patch)
tree0a5a8c098c07b0f69f5ac96be546dc8c43013880 /doc
parent8224430bd9d71dfcf2524b758d8ac14a1d93b0d5 (diff)
downloademacs-24acb31c04b4048b85311d794e600ecd7ce60d3b.tar.gz
emacs-24acb31c04b4048b85311d794e600ecd7ce60d3b.zip
Add early init file, stop package-initialize insertion
Discussion on emacs-devel leading up to this change (approximately 150 messages): - https://lists.gnu.org/archive/html/emacs-devel/2017-08/msg00154.html - https://lists.gnu.org/archive/html/emacs-devel/2017-08/msg00433.html - https://lists.gnu.org/archive/html/emacs-devel/2017-09/msg00023.html - https://lists.gnu.org/archive/html/emacs-devel/2017-09/msg00599.html - https://lists.gnu.org/archive/html/emacs-devel/2017-10/msg00332.html * lisp/startup.el (early-init-file): New variable. (load-user-init-file): New function. (command-line): Load the early init file using `load-user-init-file'. Move the check for an invalid username to just before that, and move the initialization of the package system to just after. Load the regular init file using `load-user-init-file'. * lisp/emacs-lisp/package.el (package--ensure-init-file): Remove definition, usage, and documentation. (package--init-file-ensured): Remove definition and usage. * src/lread.c (Vuser_init_file): Note change in semantics due to its usage while loading the early init file. * doc/emacs/custom.texi: Document early init file. * doc/emacs/package.texi: Document changes to when package-initialize is called. Change terminology for package 'loading'. * doc/lispref/os.texi: Document early init file. Update startup summary. * doc/lispref/package.texi: Document changes to when package-initialize is called, and advise against calling it in the init file. Change terminology for package 'loading'. * doc/misc/org.texi: Don't recommend to call package-initialize in the init file.
Diffstat (limited to 'doc')
-rw-r--r--doc/emacs/custom.texi18
-rw-r--r--doc/emacs/emacs.texi1
-rw-r--r--doc/emacs/package.texi82
-rw-r--r--doc/lispref/os.texi39
-rw-r--r--doc/lispref/package.texi30
-rw-r--r--doc/misc/org.texi4
6 files changed, 109 insertions, 65 deletions
diff --git a/doc/emacs/custom.texi b/doc/emacs/custom.texi
index 2726690f09f..b985d12cde4 100644
--- a/doc/emacs/custom.texi
+++ b/doc/emacs/custom.texi
@@ -2167,6 +2167,7 @@ Manual}.
2167* Terminal Init:: Each terminal type can have an init file. 2167* Terminal Init:: Each terminal type can have an init file.
2168* Find Init:: How Emacs finds the init file. 2168* Find Init:: How Emacs finds the init file.
2169* Init Non-ASCII:: Using non-@acronym{ASCII} characters in an init file. 2169* Init Non-ASCII:: Using non-@acronym{ASCII} characters in an init file.
2170* Early Init File:: Another init file, which is read early on.
2170@end menu 2171@end menu
2171 2172
2172@node Init Syntax 2173@node Init Syntax
@@ -2567,3 +2568,20 @@ instance:
2567 2568
2568@noindent 2569@noindent
2569Type @kbd{C-q}, followed by the key you want to bind, to insert @var{char}. 2570Type @kbd{C-q}, followed by the key you want to bind, to insert @var{char}.
2571
2572@node Early Init File
2573@subsection The Early Init File
2574@cindex early init file
2575
2576 Most customizations for Emacs can be put in the normal init file,
2577@file{.emacs} or @file{~/.emacs.d/init.el}. However, it is sometimes
2578desirable to have customizations that take effect during Emacs startup
2579earlier than the normal init file is processed. Such customizations
2580can be put in the early init file, @file{~/.emacs.d/early-init.el}.
2581This file is loaded before the package system is initialized, so in it
2582you can customize variables that affect the initialization process,
2583such as @code{package-enable-at-startup} and @code{package-load-list}.
2584@xref{Package Installation}.
2585
2586 For more information on the early init file, @pxref{Early Init
2587File,,, elisp, The Emacs Lisp Reference Manual}.
diff --git a/doc/emacs/emacs.texi b/doc/emacs/emacs.texi
index 163b6f23d84..65affeb59fe 100644
--- a/doc/emacs/emacs.texi
+++ b/doc/emacs/emacs.texi
@@ -1163,6 +1163,7 @@ The Emacs Initialization File
1163* Terminal Init:: Each terminal type can have an init file. 1163* Terminal Init:: Each terminal type can have an init file.
1164* Find Init:: How Emacs finds the init file. 1164* Find Init:: How Emacs finds the init file.
1165* Init Non-ASCII:: Using non-@acronym{ASCII} characters in an init file. 1165* Init Non-ASCII:: Using non-@acronym{ASCII} characters in an init file.
1166* Early Init File:: Another init file, which is read early on.
1166 1167
1167Dealing with Emacs Trouble 1168Dealing with Emacs Trouble
1168 1169
diff --git a/doc/emacs/package.texi b/doc/emacs/package.texi
index bc6afb7966a..6c7493790d3 100644
--- a/doc/emacs/package.texi
+++ b/doc/emacs/package.texi
@@ -241,57 +241,55 @@ lower-priority archives will not be shown in the menu, if the same
241package is available from a higher-priority archive. (This is 241package is available from a higher-priority archive. (This is
242controlled by the value of @code{package-menu-hide-low-priority}.) 242controlled by the value of @code{package-menu-hide-low-priority}.)
243 243
244 Once a package is downloaded and installed, it is @dfn{loaded} into 244 Once a package is downloaded and installed, it is made available to
245the current Emacs session. Loading a package is not quite the same as 245the current Emacs session. Making a package available adds its
246loading a Lisp library (@pxref{Lisp Libraries}); loading a package 246directory to @code{load-path} and loads its autoloads. The effect of
247adds its directory to @code{load-path} and loads its autoloads. The 247a package's autoloads varies from package to package. Most packages
248effect of a package's autoloads varies from package to package. Most 248just make some new commands available, while others have more
249packages just make some new commands available, while others have more
250wide-ranging effects on the Emacs session. For such information, 249wide-ranging effects on the Emacs session. For such information,
251consult the package's help buffer. 250consult the package's help buffer.
252 251
253 By default, Emacs also automatically loads all installed packages in 252 After a package is installed, it is automatically made available by
254subsequent Emacs sessions. This happens at startup, after processing 253Emacs in all subsequent sessions. This happens at startup, before
255the init file (@pxref{Init File}). As an exception, Emacs does not 254processing the init file but after processing the early init file
256load packages at startup if invoked with the @samp{-q} or 255(@pxref{Early Init File,,, elisp, The Emacs Lisp Reference Manual}).
257@samp{--no-init-file} options (@pxref{Initial Options}). 256As an exception, Emacs does not make packages available at startup if
257invoked with the @samp{-q} or @samp{--no-init-file} options
258(@pxref{Initial Options}).
258 259
259@vindex package-enable-at-startup 260@vindex package-enable-at-startup
260 To disable automatic package loading, change the variable 261 To keep Emacs from automatically making packages available at
261@code{package-enable-at-startup} to @code{nil}. 262startup, change the variable @code{package-enable-at-startup} to
263@code{nil}. You must do this in the early init file (@pxref{Early
264Init File,,, elisp, The Emacs Lisp Reference Manual}), as the variable
265is read before loading the regular init file. Currently this variable
266cannot be set via Customize.
262 267
263@findex package-initialize 268@findex package-initialize
264 The reason automatic package loading occurs after loading the init 269 If you have set @code{package-enable-at-startup} to @code{nil}, you
265file is that user options only receive their customized values after 270can still make packages available either during or after startup. To
266loading the init file, including user options which affect the 271make installed packages available during startup, call the function
267packaging system. In some circumstances, you may want to load 272@code{package-initialize} in your init file. To make installed
268packages explicitly in your init file (usually because some other code 273packages available after startup, invoke the command @kbd{M-x
269in your init file depends on a package). In that case, your init file 274package-initialize}.
270should call the function @code{package-initialize}. It is up to you
271to ensure that relevant user options, such as @code{package-load-list}
272(see below), are set up prior to the @code{package-initialize} call.
273This will automatically set @code{package-enable-at-startup} to @code{nil}, to
274avoid loading the packages again after processing the init file.
275Alternatively, you may choose to completely inhibit package loading at
276startup, and invoke the command @kbd{M-x package-initialize} to load
277your packages manually.
278 275
279@vindex package-load-list 276@vindex package-load-list
280 For finer control over package loading, you can use the variable 277 For finer control over which packages are made available at startup,
281@code{package-load-list}. Its value should be a list. A list element 278you can use the variable @code{package-load-list}. Its value should
282of the form @code{(@var{name} @var{version})} tells Emacs to load 279be a list. A list element of the form @w{@code{(@var{name}
283version @var{version} of the package named @var{name}. Here, 280@var{version})}} tells Emacs to make available version @var{version} of
284@var{version} should be a version string (corresponding to a specific 281the package named @var{name}. Here, @var{version} should be a version
285version of the package), or @code{t} (which means to load any 282string (corresponding to a specific version of the package), or
286installed version), or @code{nil} (which means no version; this 283@code{t} (which means to make available any installed version), or
287disables the package, preventing it from being loaded). A list 284@code{nil} (which means no version; this disables the package,
288element can also be the symbol @code{all}, which means to load the 285preventing it from being made available). A list element can also be
289latest installed version of any package not named by the other list 286the symbol @code{all}, which means to make available the latest
290elements. The default value is just @code{'(all)}. 287installed version of any package not named by the other list elements.
291 288The default value is just @code{'(all)}.
292 For example, if you set @code{package-load-list} to @code{'((muse 289
293"3.20") all)}, then Emacs only loads version 3.20 of the @samp{muse} 290 For example, if you set @code{package-load-list} to @w{@code{'((muse
294package, plus any installed version of packages other than 291"3.20") all)}}, then Emacs only makes available version 3.20 of the
292@samp{muse} package, plus any installed version of packages other than
295@samp{muse}. Any other version of @samp{muse} that happens to be 293@samp{muse}. Any other version of @samp{muse} that happens to be
296installed will be ignored. The @samp{muse} package will be listed in 294installed will be ignored. The @samp{muse} package will be listed in
297the package menu with the @samp{held} status. 295the package menu with the @samp{held} status.
diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi
index 42be60449de..be2d148a1e2 100644
--- a/doc/lispref/os.texi
+++ b/doc/lispref/os.texi
@@ -95,6 +95,22 @@ if requested by environment variables such as @env{LANG}.
95@item 95@item
96It does some basic parsing of the command-line arguments. 96It does some basic parsing of the command-line arguments.
97 97
98@item
99It loads your early init file (@pxref{Early Init File,,, emacs, The
100GNU Emacs Manual}). This is not done if the options @samp{-q},
101@samp{-Q}, or @samp{--batch} were specified. If the @samp{-u} option
102was specified, Emacs looks for the init file in that user's home
103directory instead.
104
105@item
106It calls the function @code{package-initialize} to activate any
107optional Emacs Lisp package that has been installed. @xref{Packaging
108Basics}. However, Emacs doesn't initialize packages when
109@code{package-enable-at-startup} is @code{nil} or when it's started
110with one of the options @samp{-q}, @samp{-Q}, or @samp{--batch}. To
111initialize packages in the latter case, @code{package-initialize}
112should be called explicitly (e.g., via the @samp{--funcall} option).
113
98@vindex initial-window-system@r{, and startup} 114@vindex initial-window-system@r{, and startup}
99@vindex window-system-initialization-alist 115@vindex window-system-initialization-alist
100@item 116@item
@@ -154,15 +170,6 @@ It loads your abbrevs from the file specified by
154(@pxref{Abbrev Files, abbrev-file-name}). This is not done if the 170(@pxref{Abbrev Files, abbrev-file-name}). This is not done if the
155option @samp{--batch} was specified. 171option @samp{--batch} was specified.
156 172
157@item
158It calls the function @code{package-initialize} to activate any
159optional Emacs Lisp package that has been installed. @xref{Packaging
160Basics}. However, Emacs doesn't initialize packages when
161@code{package-enable-at-startup} is @code{nil} or when it's started
162with one of the options @samp{-q}, @samp{-Q}, or @samp{--batch}. To
163initialize packages in the latter case, @code{package-initialize}
164should be called explicitly (e.g., via the @samp{--funcall} option).
165
166@vindex after-init-time 173@vindex after-init-time
167@item 174@item
168It sets the variable @code{after-init-time} to the value of 175It sets the variable @code{after-init-time} to the value of
@@ -361,6 +368,7 @@ Equivalent to @samp{-q --no-site-file --no-splash}.
361@cindex init file 368@cindex init file
362@cindex @file{.emacs} 369@cindex @file{.emacs}
363@cindex @file{init.el} 370@cindex @file{init.el}
371@cindex @file{early-init.el}
364 372
365 When you start Emacs, it normally attempts to load your @dfn{init 373 When you start Emacs, it normally attempts to load your @dfn{init
366file}. This is either a file named @file{.emacs} or @file{.emacs.el} 374file}. This is either a file named @file{.emacs} or @file{.emacs.el}
@@ -384,6 +392,19 @@ file; this way, even if you have su'd, Emacs still loads your own init
384file. If those environment variables are absent, though, Emacs uses 392file. If those environment variables are absent, though, Emacs uses
385your user-id to find your home directory. 393your user-id to find your home directory.
386 394
395@cindex early init file
396 Emacs also attempts to load a second init file, called the
397@dfn{early init file}, if it exists. This is a file named
398@file{early-init.el} in your @file{~/.emacs.d} directory. The
399difference between the early init file and the regular init file is
400that the early init file is loaded much earlier during the startup
401process, so you can use it to customize some things that are
402initialized before loading the regular init file. For example, you
403can customize the process of initializing the package system, by
404setting variables such as @var{package-load-list} or
405@var{package-enable-at-startup}. @xref{Package Installation,,,
406emacs,The GNU Emacs Manual}.
407
387@cindex default init file 408@cindex default init file
388 An Emacs installation may have a @dfn{default init file}, which is a 409 An Emacs installation may have a @dfn{default init file}, which is a
389Lisp library named @file{default.el}. Emacs finds this file through 410Lisp library named @file{default.el}. Emacs finds this file through
diff --git a/doc/lispref/package.texi b/doc/lispref/package.texi
index 21dfe1c2717..877aaf89a35 100644
--- a/doc/lispref/package.texi
+++ b/doc/lispref/package.texi
@@ -105,24 +105,32 @@ adds the package's content directory to @code{load-path}, and
105evaluates the autoload definitions in @file{@var{name}-autoloads.el}. 105evaluates the autoload definitions in @file{@var{name}-autoloads.el}.
106 106
107 Whenever Emacs starts up, it automatically calls the function 107 Whenever Emacs starts up, it automatically calls the function
108@code{package-initialize} to load installed packages. This is done 108@code{package-initialize} to make installed packages available to the
109after loading the init file and abbrev file (if any) and before 109current session. This is done after loading the early init file, but
110running @code{after-init-hook} (@pxref{Startup Summary}). Automatic 110before loading the regular init file (@pxref{Startup Summary}).
111package loading is disabled if the user option 111Packages are not automatically made available if the user option
112@code{package-enable-at-startup} is @code{nil}. 112@code{package-enable-at-startup} is set to @code{nil} in the early
113init file.
113 114
114@deffn Command package-initialize &optional no-activate 115@deffn Command package-initialize &optional no-activate
115This function initializes Emacs' internal record of which packages are 116This function initializes Emacs' internal record of which packages are
116installed, and loads them. The user option @code{package-load-list} 117installed, and makes the packages available to the current session.
117specifies which packages to load; by default, all installed packages 118The user option @code{package-load-list} specifies which packages to
118are loaded. If called during startup, this function also sets 119make available; by default, all installed packages are made available.
120If called during startup, this function also sets
119@code{package-enable-at-startup} to @code{nil}, to avoid accidentally 121@code{package-enable-at-startup} to @code{nil}, to avoid accidentally
120loading the packages twice. @xref{Package Installation,,, emacs, The 122evaluating package autoloads more than once. @xref{Package
121GNU Emacs Manual}. 123Installation,,, emacs, The GNU Emacs Manual}.
122 124
123The optional argument @var{no-activate}, if non-@code{nil}, causes 125The optional argument @var{no-activate}, if non-@code{nil}, causes
124Emacs to update its record of installed packages without actually 126Emacs to update its record of installed packages without actually
125loading them; it is for internal use only. 127making them available; it is for internal use only.
128
129In most cases, you should not need to call @code{package-initialize},
130as this is done automatically during startup. Simply make sure to put
131any code that should run before @code{package-initialize} in the early
132init file, and any code that should run after it in the primary init
133file (@xref{Init File,,, emacs, The GNU Emacs Manual}).
126@end deffn 134@end deffn
127 135
128@node Simple Packages 136@node Simple Packages
diff --git a/doc/misc/org.texi b/doc/misc/org.texi
index aa3b029ab7c..68aa01ca18c 100644
--- a/doc/misc/org.texi
+++ b/doc/misc/org.texi
@@ -890,9 +890,7 @@ Elisp libraries. You can install Org with @kbd{M-x package-install RET org}.
890been visited, i.e., where no Org built-in function have been loaded. 890been visited, i.e., where no Org built-in function have been loaded.
891Otherwise autoload Org functions will mess up the installation. 891Otherwise autoload Org functions will mess up the installation.
892 892
893Then, to make sure your Org configuration is taken into account, initialize 893If you want to use Org's package repository,
894the package system with @code{(package-initialize)} in your Emacs init file
895before setting any Org option. If you want to use Org's package repository,
896check out the @uref{http://orgmode.org/elpa.html, Org ELPA page}. 894check out the @uref{http://orgmode.org/elpa.html, Org ELPA page}.
897 895
898@subsubheading Downloading Org as an archive 896@subsubheading Downloading Org as an archive