diff options
Diffstat (limited to 'devdocs/elisp/init-file.html')
| -rw-r--r-- | devdocs/elisp/init-file.html | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/devdocs/elisp/init-file.html b/devdocs/elisp/init-file.html new file mode 100644 index 00000000..67b22b6f --- /dev/null +++ b/devdocs/elisp/init-file.html @@ -0,0 +1,22 @@ + <h4 class="subsection">The Init File</h4> <p>When you start Emacs, it normally attempts to load your <em>init file</em>. This is either a file named <samp>.emacs</samp> or <samp>.emacs.el</samp> in your home directory, or a file named <samp>init.el</samp> in a subdirectory named <samp>.emacs.d</samp> in your home directory. </p> <p>The command-line switches ‘<samp>-q</samp>’, ‘<samp>-Q</samp>’, and ‘<samp>-u</samp>’ control whether and where to find the init file; ‘<samp>-q</samp>’ (and the stronger ‘<samp>-Q</samp>’) says not to load an init file, while ‘<samp>-u <var>user</var></samp>’ says to load <var>user</var>’s init file instead of yours. See <a href="https://www.gnu.org/software/emacs/manual/html_node/emacs/Entering-Emacs.html#Entering-Emacs">Entering Emacs</a> in <cite>The GNU Emacs Manual</cite>. If neither option is specified, Emacs uses the <code>LOGNAME</code> environment variable, or the <code>USER</code> (most systems) or <code>USERNAME</code> (MS systems) variable, to find your home directory and thus your init file; this way, even if you have su’d, Emacs still loads your own init file. If those environment variables are absent, though, Emacs uses your user-id to find your home directory. </p> <p>Emacs also attempts to load a second init file, called the <em>early init file</em>, if it exists. This is a file named <samp>early-init.el</samp> in your <samp>~/.emacs.d</samp> directory. The difference between the early init file and the regular init file is that the early init file is loaded much earlier during the startup process, so you can use it to customize some things that are initialized before loading the regular init file. For example, you can customize the process of initializing the package system, by setting variables such as <var>package-load-list</var> or <var>package-enable-at-startup</var>. See <a href="https://www.gnu.org/software/emacs/manual/html_node/emacs/Package-Installation.html#Package-Installation">Package Installation</a> in <cite>The GNU Emacs Manual</cite>. </p> <p>An Emacs installation may have a <em>default init file</em>, which is a Lisp library named <samp>default.el</samp>. Emacs finds this file through the standard search path for libraries (see <a href="how-programs-do-loading">How Programs Do Loading</a>). The Emacs distribution does not come with this file; it is intended for local customizations. If the default init file exists, it is loaded whenever you start Emacs. But your own personal init file, if any, is loaded first; if it sets <code>inhibit-default-init</code> to a non-<code>nil</code> value, then Emacs does not subsequently load the <samp>default.el</samp> file. In batch mode, or if you specify ‘<samp>-q</samp>’ (or ‘<samp>-Q</samp>’), Emacs loads neither your personal init file nor the default init file. </p> <p>Another file for site-customization is <samp>site-start.el</samp>. Emacs loads this <em>before</em> the user’s init file. You can inhibit the loading of this file with the option ‘<samp>--no-site-file</samp>’. </p> <dl> <dt id="site-run-file">User Option: <strong>site-run-file</strong> +</dt> <dd><p>This variable specifies the site-customization file to load before the user’s init file. Its normal value is <code>"site-start"</code>. The only way you can change it with real effect is to do so before dumping Emacs. </p></dd> +</dl> <p>See <a href="https://www.gnu.org/software/emacs/manual/html_node/emacs/Init-Examples.html#Init-Examples">Init File Examples</a> in <cite>The GNU Emacs Manual</cite>, for examples of how to make various commonly desired customizations in your <samp>.emacs</samp> file. </p> <dl> <dt id="inhibit-default-init">User Option: <strong>inhibit-default-init</strong> +</dt> <dd><p>If this variable is non-<code>nil</code>, it prevents Emacs from loading the default initialization library file. The default value is <code>nil</code>. </p></dd> +</dl> <dl> <dt id="before-init-hook">Variable: <strong>before-init-hook</strong> +</dt> <dd><p>This normal hook is run, once, just before loading all the init files (<samp>site-start.el</samp>, your init file, and <samp>default.el</samp>). (The only way to change it with real effect is before dumping Emacs.) </p></dd> +</dl> <dl> <dt id="after-init-hook">Variable: <strong>after-init-hook</strong> +</dt> <dd><p>This normal hook is run, once, just after loading all the init files (<samp>site-start.el</samp>, your init file, and <samp>default.el</samp>), before loading the terminal-specific library (if started on a text terminal) and processing the command-line action arguments. </p></dd> +</dl> <dl> <dt id="emacs-startup-hook">Variable: <strong>emacs-startup-hook</strong> +</dt> <dd><p>This normal hook is run, once, just after handling the command line arguments. In batch mode, Emacs does not run this hook. </p></dd> +</dl> <dl> <dt id="window-setup-hook">Variable: <strong>window-setup-hook</strong> +</dt> <dd><p>This normal hook is very similar to <code>emacs-startup-hook</code>. The only difference is that it runs slightly later, after setting of the frame parameters. See <a href="startup-summary">window-setup-hook</a>. </p></dd> +</dl> <dl> <dt id="user-init-file">Variable: <strong>user-init-file</strong> +</dt> <dd><p>This variable holds the absolute file name of the user’s init file. If the actual init file loaded is a compiled file, such as <samp>.emacs.elc</samp>, the value refers to the corresponding source file. </p></dd> +</dl> <dl> <dt id="user-emacs-directory">Variable: <strong>user-emacs-directory</strong> +</dt> <dd><p>This variable holds the name of the Emacs default directory. It defaults to <samp>${XDG_CONFIG_HOME-'~/.config'}/emacs/</samp> if that directory exists and <samp>~/.emacs.d/</samp> and <samp>~/.emacs</samp> do not exist, otherwise to <samp>~/.emacs.d/</samp> on all platforms but MS-DOS. Here, <samp>${XDG_CONFIG_HOME-'~/.config'}</samp> stands for the value of the environment variable <code>XDG_CONFIG_HOME</code> if that variable is set, and for <samp>~/.config</samp> otherwise. See <a href="https://www.gnu.org/software/emacs/manual/html_node/emacs/Find-Init.html#Find-Init">How Emacs Finds Your Init File</a> in <cite>The GNU Emacs Manual</cite>. </p></dd> +</dl><div class="_attribution"> + <p class="_attribution-p"> + Copyright © 1990-1996, 1998-2022 Free Software Foundation, Inc. <br>Licensed under the GNU GPL license.<br> + <a href="https://www.gnu.org/software/emacs/manual/html_node/elisp/Init-File.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Init-File.html</a> + </p> +</div> |
