User's Initialization File

From WikEmacs
(Redirected from .emacs)
Jump to: navigation, search

User's Initialization File or dotemacs or init file is a file to store your configurations/customizations for Emacs written in Emacs Lisp, located at either ${HOME}/.emacs.d/init.el or (archaically) at ${HOME}/.emacs or at %HOME%\_emacs on MS Windows.

The most reliable way to find our the place of the initialization file on your system is to check the value of the user-init-file variable.

Configuration Example[edit]

For a good example of an init file check out some of the starter kits, like Prelude.

Debugging the Init file[edit]

$ emacs --debug-init

Running the above command will enable the Emacs Lisp debugger for errors in the init file.

How to package your config and packages[edit]

Will come a moment when you want to duplicate your emacs configuration into another computer. And you realize that you rely on a lot of third party packages that you don't want to re-install manually ! So how can we package our config, along with all our packages ? There are some options.

First you would obviously bundle everything into source control (except for a private file). Bitbucket and Gitlab offer private repos.

You then must read the page on package.el to see a way to list all the packages you use.

You can use Cask to manage all the dependencies. A Cask file lists them all, like

   (depends-on "cask")
   (depends-on "dash")
   (depends-on "evil")

Some write their config in org-mode and load it with a call to org-babel, which is doable in one line in ~/.emacs.d/init.el:

   (require 'org)
   (require 'ob-tangle)
   (org-babel-load-file (expand-file-name "~/.emacs.d/"))

See an example config with Cask and org-mode.

some split it in multiple elisp files, some keep it in one big file.

Finally, to speed up the installation and ensure the same environment, you can also commit the pckages installed with package.el.

You can take inspiration from Starter Kits.

See Also[edit]

  • Prelude, a much more powerful and productive set of initial configuration than the one you get out of the box.
  • Emacs Starter Kit
  • package.el, the built-in package manager in Emacs 24.

External links[edit]