A Few Emacs Customizations
So while setting up my new laptop I needed to copy my emacs settings over and thought this would be a good topic for a short blog post.
I like to keep things as standard as possible, especially key bindings. This way if I find myself ever needing to use a strange computer my muscle memory will help me find my way around 1. However, I do customize a few things, and emacs is one of them. As you will see these customizations are mainly visual or for things that do not change user interactions.
Backups
Emacs provides a robust backup system for ensuring inadvertent changes can be recovered. By default, it will save the previous version in the same directory as the original suffixed with a tilde (~
).
I don’t like my filesystem being littered with these backup files, so I add the following to my $HOME/.emacs
file:
(setq backup-directory-alist `(("." . "~/.emacs_backups")))
(setq backup-by-copying t)
(setq delete-old-versions t
kept-new-versions 6
kept-old-versions 2
version-control t)
This puts all backup files on %HOME/.emacs_backups
. These files will be named <absolute path><filename>~<revision num>~
, where the path separator is !
. This configuration will keep the latest 5 backups of every file edited with emacs.
Column number
By default emacs displays the line number in the status area. I find it useful to display the column number as well.
(setq column-number-mode t)
You can always enable (or disable) it selectively by using M-x column-number-mode
.
Menu Bar
I also strictly use emacs from a terminal and really have no use for the built-in menu, so I disable it with the following:
(menu-bar-mode -1)
Again, you can toggle it selectively by using M-x menu-bar-mode
.
Selecting Text
By default emacs highlights selected text (C-Space) with a bright yellow background, and leaves the font face foreground color the same. Depending on the colors you use, this can be very difficult to read:

You can change this to something more pleasing like so:
(set-face-attribute 'region nil :background "#666" :foreground "#ffffff")

The Minibuffer Font Color
Likewise, the default color for the minibuffer font is blue
and is very hard to read on a black background:

This can be changed via:
(set-face-foreground 'minibuffer-prompt "lightblue")

That is it for now. I’ll have other posts that cover some other emacs customizations I use, namely Syntax Highlighting 2, and a major mode for use with Go programming.
Thanks for visiting.