The VikiD Truth

Knowledge base / Computing / Tools & dev workflow

Starting Emacs & the config file

emacs | computing

Launching Emacs

I actually start emacs as a daemon service when entering Linux. This requires a little setup which is not all that difficult. I don’t know which version or distribution of linux you use. But the line that starts emacs as a daemon is this:

$ /usr/bin/emacs24 --daemon

You can add this line to “Startup Applications” in Ubuntu. Like so:

startup-apps

edit-startup

By doing this emacs is always running in the background.

I then call any emacs session with:

$ emacsclient -c

Which I setup in the “Main Menu” like this:

mmenu

props

I usually also set to an alias on my system for easy access, like this:

alias em='emacsclient -c'

The very first lines of my .emacs also contains the line:

(server-start)

Which ensures that emacs then sets itself as a server that can serve the emacsclient requests.

This way I always have emacs running as a server, the same instance running wherever and whenever I need it.

Startup Procedure

When emacs starts up, it (usually) reads a configuration file called .emacs.

Emacs users use this file to fine tune their emacs configuration and load various applications, modules, and utility functions.

It has become quite a fashion for people to share these config files on sites like github and bitbucket. Anyone can the download the .emacs files of another user to incorporate useful code into their own configurations.

I have decided to go another way. What I will attempt to do here is describe my current strategies.

Creating your .emacs

I actually keep most of my configuration in an org-mode file called init.org and it is this file that is loaded at the end of my .emacs.

With the lines:

(require 'org)                                ;load org-mode
(require 'ob-tangle)                          ;allow literate programming tangling
(require 'cl)                                 ;allow common-lisp style functions
(org-babel-load-file "~/.emacs.d/init.org")   ;load the init file with source code

To continue please visit init.org.

A 2026 update to the steps above

The screenshots above come from an old Ubuntu desktop and emacs24. The idea is unchanged, but the commands are simpler now:

The plain idea

Your config file is a program that Emacs runs every time it starts. Whatever that program does, adding key bindings, loading packages, setting colours, becomes part of your editor. Keeping it as an org file (init.org) means the program is also a readable document explaining itself.

Why it matters

A running daemon means Emacs starts once, and every later window opens instantly with all your buffers, history and open files still there. Combine that with a config you understand line by line and the editor stops being a tool you open and becomes a place you work in.

An analogy: the kettle that is always warm

Starting Emacs from cold each time is filling and boiling a kettle for every cup of tea. The daemon keeps the water hot; emacsclient just pours.

A worked example

# once
systemctl --user enable --now emacs
# in ~/.bashrc
alias em='emacsclient -c -a ""'
;; ~/.emacs.d/init.el
(require 'org)
(org-babel-load-file (expand-file-name "init.org" user-emacs-directory))

org-babel-load-file extracts (“tangles”) the Emacs Lisp blocks from init.org into init.el next to it, and loads that. The tangled file is only rebuilt when init.org changes, so startup stays fast.

Common misconceptions

How it connects

Emacs, Emacs Lisp, init.org, and Bash for the alias.

Sources

Last edited · 21 revisions

Tags: #Computing