## title: A GNU Emacs experience throught NixOS
## date: "2025-02-26"
## Introduction
I have always used VSCode as a code editor. I've already
tried using Vim, but only for testing purposes and not with
the aim of changing text editors.
(HTM) VSCode
(HTM) Vim
This time, I decided to use a FLOSS code editor in the
terminal, the aim being to replace VSCode indefinitely. This
blog post is actually written with it.
(HTM) FLOSS
(HTM) VSCode
It is none other than Emacs. For the convenience of writing
and reading this post, I'll simply write “Emacs” to
designate the implementation of the GNU project.
(HTM) Emacs
(HTM) implementation of the GNU
## Why
Why did I leave VSCode and decide to switch to Emacs?
(HTM) VSCode
(HTM) Emacs
### Leaving VSCode
Because it's a RAM-hungry graphics application. You shouldn't
need that much memory to edit text and connect to an LSP
server. We're talking about 1.2 GB compared with around 200
MB for the same project.
Also, I don't want all the additional features offered, such
as file name and text parsing, to suggest that I download
extensions. I simply need a simple, functional text-editing
application. I don't enjoy using VSCode anymore, so it's
time to say goodbye.
(HTM) VSCode
### Choosing Emacs
Of all the text editors out there, I chose Emacs. It's
actually much more than that. In the words of Protesilaos
Stavrou.
(HTM) Emacs
(HTM) Protesilaos Stavrou
“It is a programmable platform where text editing is one of
the main points of interaction.”
Indeed, I see Emacs more as an operating system than as a
text editor. The possibilities for configuring and extending
it are virtually infinite.
(HTM) Emacs
Also, I find it an excellent UNIX citizen. The default
keystroke sequences correspond to those used in other
applications in the terminal. ar example, the moves in a
Linux manual read with the man command or those in the
results of fzf.
Another reason was to be able to modify any behavior, to be
able to have an application that corresponds precisely to
what you want to have.
## Learning
So I installed Emacs version 29.4 and started learning how
to use it properly.
(HTM) Emacs
### Mastering Emacs, Mickey Pertersen
This book explained the important concepts of the
application and gave me a solid foundation for getting
started with Emacs. Certain chapters, such as “The Theory of
Movement” and “The Theory of Editing”, explained to me the
best practices for efficient and rapid buffering.
(HTM) Emacs
I highly recommend this book for anyone wishing to start
learning Emacs.
(HTM) Emacs
### Emacs Lisp Intro
I've also read the “Emacs Lisp Intro” written in Emacs as a
manual. Since most of the code is written in Emacs Lisp,
it's essential to understand the language, or at least know
how to read it, in order to configure the editor.
(HTM) Emacs
(HTM) Emacs
For example, I needed to write some to display line numbers
at the start of org-present mode, and to hide them at the end
of minor mode execution.
(HTM) org-present
### Environment
As I said earlier, Emacs is a platform with a whole host of
features. This makes it all the more tempting to leave this
environment, which offers numerous possibilities, such as
organizing a diary, compiling a project, accessing a shell
or terminal emulator, making a presentation, taking notes,
managing Emacs modes and packages, etc.
(HTM) Emacs
(HTM) Emacs
Staying in the same environment made me more productive and
faster. For computer development, Emacs can be configured
like an IDE, precisely and fully controlled.
(HTM) Emacs
One last very important thing to know is that any piece of
Emacs is documented, meaning that whatever I do or try to
do, I can find documentation. Emacs is its own
documentation.
(HTM) Emacs
(HTM) Emacs
## Configuration
### Via NixOS
Concerning the tool configuration, being on NixOS, I decided
to use the Emacs module provided by the home-manager. To
remain consistent with my current configuration, which is
highly modularized, each Emacs package has its own Nix
module.
(HTM) NixOS
(HTM) Emacs
(HTM) Emacs
Here's what the file structure looks like.
modules/home/editors/emacs
├── default.nix
└── packages
├── auto-save
│ └── default.nix
├── dashboard
│ └── default.nix
├── dired
│ └── default.nix
├── doom-modeline
│ └── default.nix
├── ivy
│ └── default.nix
├── lsp-mode
│ ├── bash-language-server
│ │ └── default.nix
│ ├── default.nix
│ ├── dockerfile
│ │ └── default.nix
│ ├── gopls
│ │ └── default.nix
...
These modules contain the dependencies, i.e. the Emacs
packages and the Emacs Lisp configuration.
(HTM) Emacs
(HTM) Emacs
Here's an example with the org-superstar package.
(HTM) org-superstar
{
config,
lib,
namespace,
...
}:
let
inherit (lib) mkIf;
inherit (lib.${namespace}) mkBoolOpt;
cfg = config.${namespace}.editors.emacs.packages.org-
superstar;
in
{
options.${namespace}.editors.emacs.packages.org-superstar =
{
enable = mkBoolOpt false "Whether or not to enable the
emacs org-superstar package.";
};
config = mkIf cfg.enable {
programs.emacs = {
extraPackages = (epkgs: [ epkgs.org-superstar ]);
extraConfig = ''
(use-package org-superstar
:ensure t
:after org
:hook (org-mode . org-superstar-mode)
:custom
(org-superstar-remove-leading-stars t)
(org-superstar-headline-bullets-list '("⁖" "✿" "▷"
"✸")))
'';
};
};
}
## Notes taking on Emacs
Emacs has a major mode called Org, which modifies Emacs
behavior to create an environment suited to writing data in
org format. It integrates perfectly with Emacs other
features and keeps me in the application.
(HTM) Emacs
(HTM) Org
(HTM) Emacs
(HTM) Emacs
I used to take my notes with Obsidian. I refactored all my
notes and converted them to Org format.
(HTM) Org
## Conclusion
From now on, I intend to use Emacs as my main text editor,
as well as for note-taking.
(HTM) Emacs