The VikiD Truth

Knowledge base / Computing / Tools & dev workflow

Computing | computingFreedom | Build | Picolisp | Picolisp Machine | Pil Sources | Linux | BASH | C-Programmming | Operating Systems | Javascipt | Emacs | vim | Pharo Smalltalk | Computer Security | Python | The Compiler | Identifiers | Literals | storage_linkage | Networking

Emacs Notes

Here is the truth about Emacs: it is not a text editor. It is a Lisp machine that happens to ship with a text editor written in that Lisp. Every key you press runs an Emacs Lisp function, and you can read, change or replace any of them while it is running. These are my working notes, but first the orientation I wish I had been given.

What it is, in plain words

GNU Emacs was started by Richard Stallman in 1984. Emacs 30 is the current major release in 2026. It is a small C core (display, I/O, a Lisp interpreter and native compiler) and over a million lines of Emacs Lisp on top. The key ideas:

Recent versions made things much better out of the box: native compilation of Lisp (Emacs 28+), Eglot for LSP and Tree-sitter modes (29+), use-package built in (29+), and better completion and editing defaults in 30.

Why it matters

An everyday analogy: a workshop that builds its own tools

Most editors are a toolbox: you use what came in it. Emacs is a workshop with a lathe. When you need a tool that does not exist, you turn one, hang it on the wall next to the others, and it works exactly like the factory-made ones.

A hands-on example: run it as a server on Vikix

The notes below use systemctl --user, which is for systemd distros. On Void with runit there is no user systemd, so the simplest approach is to start the daemon from your session, for example in ~/.xinitrc or StumpWM’s ~/.stumpwmrc:

emacs --daemon            # start once per login
emacsclient -c            # new graphical frame, instant
emacsclient -t            # open in the terminal
export EDITOR="emacsclient -t" VISUAL="emacsclient -c -a ''"

-a '' means “if no server is running, start one”. From StumpWM you can bind a key to it:

;; ~/.stumpwmrc  (StumpWM is Common Lisp too)
(define-key *root-map* (kbd "e") "exec emacsclient -c -a ''")

A small, modern init.el to get going:

(setq inhibit-startup-screen t
      select-enable-clipboard t)       ; share the clipboard (modern name)
(global-display-line-numbers-mode 1)
(electric-pair-mode 1)
(use-package eglot :hook (c-mode . eglot-ensure))   ; LSP for C via clangd
(use-package magit :ensure t)                       ; Git

Note the clipboard variable in the notes below, x-select-enable-clipboard, is the old name; select-enable-clipboard replaced it and is on by default now.

Common misconceptions

My own config

My real setup is public as vukini/emacs-void: one literate config.org loaded by a small init.el. Two pages walk through it:

On Vikix the daemon is started at login, and Super+x opens a frame with emacsclient -c -a ''.

Connections

Notes

Start an emacs server.

systemctl --user enable emacs

Close an emacs client, see delete-frame

Copy emacs text to the clipboard:

(custom-set-variables '(x-select-enable-clipboard t))

(global-set-key "\C-w" 'clipboard-kill-region)
(global-set-key "\M-w" 'clipboard-kill-ring-save)
(global-set-key "\C-y" 'clipboard-yank)
2{Notes from Mastering Emacs}
In Emacs, the buffer is the data structure.

Useful tips

Use ‘C-x ESC ESC’ (‘repeat-complex-command’)

NavigatingParentheses

C-M-n forward-list   Move forward over a parenthetical group

C-M-p backward-list  Move backward over a parenthetical group

C-M-f forward-sexp   Move forward over a balanced expression

C-M-b backward-sexp  Move backward over a balanced expression

C-M-k kill-sexp      Kill balanced expression forward

C-M-SPC mark-sexp    Put the mark at the end of the sexp.

Scale or Zoom Text

(text-scale-adjust 1)	C-x C-= or C-x C-+	Increase text size by one step
(text-scale-adjust -1)	C-x C–	                Decrease text-size by one step

Setting Fonts

Emacs Wiki Set Fonts

Record Macros

  1. Record: ctrl+x ( or ‘q’ in evil mode
  2. Perform any actions to record
  3. Stop recording by pressing ctrl+x or ‘q’ in evil mode)
  4. Play: ctrl+x e

Naming Macros

  1. Start: Ctrl+x Ctrl+k n
  2. Give name-of-macro, and press ENTER
  3. Play: M-x name-of-macro

Tabs and Spaces

Last edited · 14 revisions

Tags: #Computing