Customizing your Emacs Experience with Themes

As technology has progressed, this has led to the development of tools like Integrated Development Environments that offer bundles of features to its users. However, despite the huge popularity that IDEs have gained in recent times, text editors are still more commonly used, mainly due to their high performance and speeds and the flexibility that they provide users to create and edit files of all types of languages.

Modern text editors can match IDEs in terms of features being provided. With the whole work of developers revolving around playing with programs and bouncing in and out of their workflows, it is thus imperative to use an editor that should be easy to work with and do the job the way it was intended to be done.

One such great text editor that has been around for quite some time is Emacs, which, due to being heavily customizable and flexible, has become the key figure behind the work of organizations around the world. Emacs is often considered as a lisp machine rather than just a text editor, and that is certainly not wrong since it can be set up like a shell, an email client, and so much more.

This speciality of Emacs arises from it having a Lisp interpreter at its core, meaning users can configure Emacs just by adding a few lines of Lisp code. With text editors having a very simplistic style, this attribute of Emacs allows users to customize its looks and style it in the way they like.

Hence, today we will be looking at how one can customize Emacs with Themes and some other features.

Initial Look

Initially, when you load Emacs, the theme that appears along with Emacs is the following:

This, however, does not really look that pleasing to the eye. Let us change this and style Emacs with a new design.


However, before we actually move on to the actual process, we first need to add a few lines to our initialization file. When Emacs starts, the first file that is processed is this initialization file, which contains commands written in Lisp that allow users to configure Emacs. It is basically what you call the customization settings file of Emacs. To open our initialization file, hit the keys Ctrl + x followed by Ctrl + f and then enter ~/.emacs. Over here, we first need to add some prerequisite code before updating Emacs with our new theme. For this, we need to add the following lines of code to our init file:

(require 'package)
(add-to-list 'package-archives
'("melpa" . "http://melpa.org/packages/") t)
(unless (package-installed-p 'use-package)
(package-install 'use-package))

The code, given above, basically adds the Melpa archive to the list of package repositories found in Emacs and gives it permission to use these packages.

Furthermore, it installs use package, a package which can be used to further install other packages.

Adding a Theme to Emacs

Now we will be adding a theme to our Emacs. There are numerous great themes available out there. A good site for checking this out is Emacs Themes.

For this tutorial, I will be adding the Zenburn theme to our Emacs. To do this, once again open the initialization file and add the following lines of code to it:

(use-package zenburn-theme
:ensure t
(load-theme 'zenburn t))

This installs the Zenburn theme and loads it up once Emacs is restarted. Now our Emacs looks something like this:

Compared to the initial theme, this looks so much better.

Further Customizing our Theme

The best thing about Emacs is the freedom that it provides you. For users that are not happy about some stuff about the theme they just added, Emacs even allows you to tweak it. This can be simply changing a few colors or scaling the font sizes of headings and titles and so much more.

Let us show an example of this. In my case, I will be changing the font family that comes along with Emacs. To do this, I will be adding the following line of code to my init file:

(set-face-attribute 'default nil :font "DejaVu Sans Mono")

This sets up the font family or as Emacs recalls it, font face as DejaVu Sans. I can further customize this by changing its font size or specifying a separate font for some specific language like C++.

Default Themes of Emacs

Emacs itself comes with several default themes. For users that do not want to get into the hassle of changing their initialization file, they can simply add one of these default themes to their Emacs. Users can check the default themes of Emacs by pressing Alt + x and entering customize-themes.

This will bring them to a screen which looks something like this:

All the themes presented above in the list come along with Emacs 26. For selecting a theme from this list, users need to go onto the name of the theme they want to select and press enter.

They will immediately see a change in Emacs and a cross sign will also appear alongside the box of the theme they selected. For example, if I select tango-dark, then it would look like this;

However, this still isn’t permanent, and after reloading Emacs, the old Emacs theme will appear.

To permanently set this up as your theme for Emacs, go to the Save Theme Settings Button and press enter.

Now when you restart your Emacs, you will see this theme appear instead of your old one.

Disabling Custom Theme

For users that do not get used to their new theme and would prefer the old one, they can disable it by using the disable-theme command. For example, if I want to disable my Zenburn theme, then I need to add the following line of code to my init file:

(disable-theme 'zenburn)

This disables my Zenburn theme and switches to the default theme. Note: add the disable-theme command after the load-theme command.


The ease at which users can change themes or font sizes that come with Emacs shows its versatility and extensibility, and this is what makes Emacs so powerful and unique compared to other text editors.

About the author

Zeeman Memon

Hi there! I'm a Software Engineer who loves to write about tech. You can reach out to me on LinkedIn.