diff options
| author | Radon Rosborough | 2018-02-17 13:36:16 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2018-02-17 13:36:16 +0200 |
| commit | 24acb31c04b4048b85311d794e600ecd7ce60d3b (patch) | |
| tree | 0a5a8c098c07b0f69f5ac96be546dc8c43013880 /doc | |
| parent | 8224430bd9d71dfcf2524b758d8ac14a1d93b0d5 (diff) | |
| download | emacs-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.texi | 18 | ||||
| -rw-r--r-- | doc/emacs/emacs.texi | 1 | ||||
| -rw-r--r-- | doc/emacs/package.texi | 82 | ||||
| -rw-r--r-- | doc/lispref/os.texi | 39 | ||||
| -rw-r--r-- | doc/lispref/package.texi | 30 | ||||
| -rw-r--r-- | doc/misc/org.texi | 4 |
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 |
| 2569 | Type @kbd{C-q}, followed by the key you want to bind, to insert @var{char}. | 2570 | Type @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 | ||
| 2578 | desirable to have customizations that take effect during Emacs startup | ||
| 2579 | earlier than the normal init file is processed. Such customizations | ||
| 2580 | can be put in the early init file, @file{~/.emacs.d/early-init.el}. | ||
| 2581 | This file is loaded before the package system is initialized, so in it | ||
| 2582 | you can customize variables that affect the initialization process, | ||
| 2583 | such 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 | ||
| 2587 | File,,, 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 | ||
| 1167 | Dealing with Emacs Trouble | 1168 | Dealing 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 | |||
| 241 | package is available from a higher-priority archive. (This is | 241 | package is available from a higher-priority archive. (This is |
| 242 | controlled by the value of @code{package-menu-hide-low-priority}.) | 242 | controlled 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 |
| 245 | the current Emacs session. Loading a package is not quite the same as | 245 | the current Emacs session. Making a package available adds its |
| 246 | loading a Lisp library (@pxref{Lisp Libraries}); loading a package | 246 | directory to @code{load-path} and loads its autoloads. The effect of |
| 247 | adds its directory to @code{load-path} and loads its autoloads. The | 247 | a package's autoloads varies from package to package. Most packages |
| 248 | effect of a package's autoloads varies from package to package. Most | 248 | just make some new commands available, while others have more |
| 249 | packages just make some new commands available, while others have more | ||
| 250 | wide-ranging effects on the Emacs session. For such information, | 249 | wide-ranging effects on the Emacs session. For such information, |
| 251 | consult the package's help buffer. | 250 | consult 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 |
| 254 | subsequent Emacs sessions. This happens at startup, after processing | 253 | Emacs in all subsequent sessions. This happens at startup, before |
| 255 | the init file (@pxref{Init File}). As an exception, Emacs does not | 254 | processing the init file but after processing the early init file |
| 256 | load 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}). | 256 | As an exception, Emacs does not make packages available at startup if |
| 257 | invoked 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}. | 262 | startup, change the variable @code{package-enable-at-startup} to |
| 263 | @code{nil}. You must do this in the early init file (@pxref{Early | ||
| 264 | Init File,,, elisp, The Emacs Lisp Reference Manual}), as the variable | ||
| 265 | is read before loading the regular init file. Currently this variable | ||
| 266 | cannot 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 |
| 265 | file is that user options only receive their customized values after | 270 | can still make packages available either during or after startup. To |
| 266 | loading the init file, including user options which affect the | 271 | make installed packages available during startup, call the function |
| 267 | packaging system. In some circumstances, you may want to load | 272 | @code{package-initialize} in your init file. To make installed |
| 268 | packages explicitly in your init file (usually because some other code | 273 | packages available after startup, invoke the command @kbd{M-x |
| 269 | in your init file depends on a package). In that case, your init file | 274 | package-initialize}. |
| 270 | should call the function @code{package-initialize}. It is up to you | ||
| 271 | to ensure that relevant user options, such as @code{package-load-list} | ||
| 272 | (see below), are set up prior to the @code{package-initialize} call. | ||
| 273 | This will automatically set @code{package-enable-at-startup} to @code{nil}, to | ||
| 274 | avoid loading the packages again after processing the init file. | ||
| 275 | Alternatively, you may choose to completely inhibit package loading at | ||
| 276 | startup, and invoke the command @kbd{M-x package-initialize} to load | ||
| 277 | your 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 | 278 | you can use the variable @code{package-load-list}. Its value should |
| 282 | of the form @code{(@var{name} @var{version})} tells Emacs to load | 279 | be a list. A list element of the form @w{@code{(@var{name} |
| 283 | version @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 | 281 | the package named @var{name}. Here, @var{version} should be a version |
| 285 | version of the package), or @code{t} (which means to load any | 282 | string (corresponding to a specific version of the package), or |
| 286 | installed version), or @code{nil} (which means no version; this | 283 | @code{t} (which means to make available any installed version), or |
| 287 | disables the package, preventing it from being loaded). A list | 284 | @code{nil} (which means no version; this disables the package, |
| 288 | element can also be the symbol @code{all}, which means to load the | 285 | preventing it from being made available). A list element can also be |
| 289 | latest installed version of any package not named by the other list | 286 | the symbol @code{all}, which means to make available the latest |
| 290 | elements. The default value is just @code{'(all)}. | 287 | installed version of any package not named by the other list elements. |
| 291 | 288 | The 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 |
| 294 | package, 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 |
| 296 | installed will be ignored. The @samp{muse} package will be listed in | 294 | installed will be ignored. The @samp{muse} package will be listed in |
| 297 | the package menu with the @samp{held} status. | 295 | the 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 |
| 96 | It does some basic parsing of the command-line arguments. | 96 | It does some basic parsing of the command-line arguments. |
| 97 | 97 | ||
| 98 | @item | ||
| 99 | It loads your early init file (@pxref{Early Init File,,, emacs, The | ||
| 100 | GNU Emacs Manual}). This is not done if the options @samp{-q}, | ||
| 101 | @samp{-Q}, or @samp{--batch} were specified. If the @samp{-u} option | ||
| 102 | was specified, Emacs looks for the init file in that user's home | ||
| 103 | directory instead. | ||
| 104 | |||
| 105 | @item | ||
| 106 | It calls the function @code{package-initialize} to activate any | ||
| 107 | optional Emacs Lisp package that has been installed. @xref{Packaging | ||
| 108 | Basics}. However, Emacs doesn't initialize packages when | ||
| 109 | @code{package-enable-at-startup} is @code{nil} or when it's started | ||
| 110 | with one of the options @samp{-q}, @samp{-Q}, or @samp{--batch}. To | ||
| 111 | initialize packages in the latter case, @code{package-initialize} | ||
| 112 | should 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 |
| 155 | option @samp{--batch} was specified. | 171 | option @samp{--batch} was specified. |
| 156 | 172 | ||
| 157 | @item | ||
| 158 | It calls the function @code{package-initialize} to activate any | ||
| 159 | optional Emacs Lisp package that has been installed. @xref{Packaging | ||
| 160 | Basics}. However, Emacs doesn't initialize packages when | ||
| 161 | @code{package-enable-at-startup} is @code{nil} or when it's started | ||
| 162 | with one of the options @samp{-q}, @samp{-Q}, or @samp{--batch}. To | ||
| 163 | initialize packages in the latter case, @code{package-initialize} | ||
| 164 | should 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 |
| 168 | It sets the variable @code{after-init-time} to the value of | 175 | It 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 |
| 366 | file}. This is either a file named @file{.emacs} or @file{.emacs.el} | 374 | file}. 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 | |||
| 384 | file. If those environment variables are absent, though, Emacs uses | 392 | file. If those environment variables are absent, though, Emacs uses |
| 385 | your user-id to find your home directory. | 393 | your 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 | ||
| 399 | difference between the early init file and the regular init file is | ||
| 400 | that the early init file is loaded much earlier during the startup | ||
| 401 | process, so you can use it to customize some things that are | ||
| 402 | initialized before loading the regular init file. For example, you | ||
| 403 | can customize the process of initializing the package system, by | ||
| 404 | setting variables such as @var{package-load-list} or | ||
| 405 | @var{package-enable-at-startup}. @xref{Package Installation,,, | ||
| 406 | emacs,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 |
| 389 | Lisp library named @file{default.el}. Emacs finds this file through | 410 | Lisp 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 | |||
| 105 | evaluates the autoload definitions in @file{@var{name}-autoloads.el}. | 105 | evaluates 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 |
| 109 | after loading the init file and abbrev file (if any) and before | 109 | current session. This is done after loading the early init file, but |
| 110 | running @code{after-init-hook} (@pxref{Startup Summary}). Automatic | 110 | before loading the regular init file (@pxref{Startup Summary}). |
| 111 | package loading is disabled if the user option | 111 | Packages 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 |
| 113 | init file. | ||
| 113 | 114 | ||
| 114 | @deffn Command package-initialize &optional no-activate | 115 | @deffn Command package-initialize &optional no-activate |
| 115 | This function initializes Emacs' internal record of which packages are | 116 | This function initializes Emacs' internal record of which packages are |
| 116 | installed, and loads them. The user option @code{package-load-list} | 117 | installed, and makes the packages available to the current session. |
| 117 | specifies which packages to load; by default, all installed packages | 118 | The user option @code{package-load-list} specifies which packages to |
| 118 | are loaded. If called during startup, this function also sets | 119 | make available; by default, all installed packages are made available. |
| 120 | If 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 |
| 120 | loading the packages twice. @xref{Package Installation,,, emacs, The | 122 | evaluating package autoloads more than once. @xref{Package |
| 121 | GNU Emacs Manual}. | 123 | Installation,,, emacs, The GNU Emacs Manual}. |
| 122 | 124 | ||
| 123 | The optional argument @var{no-activate}, if non-@code{nil}, causes | 125 | The optional argument @var{no-activate}, if non-@code{nil}, causes |
| 124 | Emacs to update its record of installed packages without actually | 126 | Emacs to update its record of installed packages without actually |
| 125 | loading them; it is for internal use only. | 127 | making them available; it is for internal use only. |
| 128 | |||
| 129 | In most cases, you should not need to call @code{package-initialize}, | ||
| 130 | as this is done automatically during startup. Simply make sure to put | ||
| 131 | any code that should run before @code{package-initialize} in the early | ||
| 132 | init file, and any code that should run after it in the primary init | ||
| 133 | file (@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}. | |||
| 890 | been visited, i.e., where no Org built-in function have been loaded. | 890 | been visited, i.e., where no Org built-in function have been loaded. |
| 891 | Otherwise autoload Org functions will mess up the installation. | 891 | Otherwise autoload Org functions will mess up the installation. |
| 892 | 892 | ||
| 893 | Then, to make sure your Org configuration is taken into account, initialize | 893 | If you want to use Org's package repository, |
| 894 | the package system with @code{(package-initialize)} in your Emacs init file | ||
| 895 | before setting any Org option. If you want to use Org's package repository, | ||
| 896 | check out the @uref{http://orgmode.org/elpa.html, Org ELPA page}. | 894 | check 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 |