~/.config/emacs

ARAWAS Emacs — welcome back.

This is the config you now have: one init.el you can read top to bottom, a dozen downloaded packages, and the same files on the laptop and the server.

1;; ARAWAS Emacs. SPC is the leader; M-SPC in insert state.
2;; Leader letters mirror Emacs: SPC h = C-h, SPC p = C-x p, SPC r = C-x r,
3;; SPC w = C-w, SPC x = C-x. Anything you read in the manual works.
4;;
5;; SPC , buffers, recent files, bookmarks SPC . find a file
6;; SPC SPC run a command (M-x) SPC s r search the project
7;; SPC p p switch project, then f g m e SPC g g magit
8;; SPC r m bookmark this spot SPC r b jump to a bookmark
9;; SPC c a code actions (also gd, K, C-o) SPC h k what does a key do?
10;; SPC m c capture a note SPC m w write today
11;; SPC a todo.txt SPC b k close this buffer
12;;
13;; Config: SPC f c (zM folds it). Guide: ~/.config/emacs/docs/index.html
14
15
-UUU:--- *scratch* All L15 <N> (Lisp Interaction company WK ElDoc)
For information about GNU Emacs and the GNU system, type SPC h C-a.
startup
0.2–0.6 s was 2–3 s
packages you list
12 was ~40
code in init.el
293 lines was 1,509 across config.org and scripts
runs on
Emacs 29 & 30 window or terminal

First ten minutes ;;; start

Tick them off as you go. Your browser remembers the ticks; nothing else does.

0 of 8 done

The leader, in one rule ;;; leader

A leader letter that matches an Emacs prefix is that prefix. Anything you read in the manual or online works with the leader too: swap C-h for SPC h, or C-x p for SPC p. In insert state, M-SPC is the leader.

leadersame asholds
SPC h= C-hhelp: describe keys, functions, variables, modes
SPC p= C-x pprojects: switch, find file, grep, compile, magit
SPC r= C-x rbookmarks and registers
SPC w= C-wwindows, the vim way
SPC x= C-xeverything else Emacs keeps under C-x

The other letters are your own groups:

SPC b buffersSPC c codeSPC d diredSPC e evalSPC f filesSPC g gitSPC m orgSPC s searchSPC t togglesSPC a todo.txt

Every key ;;; keys

Filter the way your minibuffer does: type words in any order. Try project file, bookmark or go.

Everyday recipes ;;; recipes

Get back to something

SPC , and type part of a name. Start with b SPC, f SPC or m SPC to see only buffers, recent files or bookmarks. C-^ flips between your last two buffers.

Work in a project

SPC p p picks the repo. Then SPC p f finds files, SPC s r searches everything with ripgrep, SPC p c runs go test ./... with clickable errors, and SPC p m opens magit.

Write Go

Completion pops up after two letters (C-n/C-p, RET). gd jumps to a definition and C-o comes back. K shows docs. SPC c a organizes imports, SPC c r renames, SPC c d lists errors. Saving runs gofmt.

Write Java

Same keys as Go. jdtls 1.61.0 lives in ~/.local/share/jdtls and starts by itself when you open a .java file. It's the last release that runs on Java 21; 1.62.0 and later need Java 25.

Notes and writing

SPC m c then s spark, i learned, p place or q queue. Each one is a single line at the top of life.org. SPC m l opens it, SPC m w opens today's entry in writing/2026.org.

Tasks and git

SPC a opens todo.txt, the same file tuxedo edits. SPC g g shows the repo's status: s stages, c commits, P pushes, and each opens a small menu that shows the next key.

tutorial 1 · about 15 minutes

Go: an empty folder to passing tests

Goal: a small package with a table-driven test. Watch it fail, jump straight to the failure, fix it, rename safely, commit.

  1. First time only: tell git who you are. Without this, every commit in a new repo fails with unable to auto-detect email address.

    git config --global user.name "Your Name"
    git config --global user.email you@example.com

    Then make the module and open the first file:

    mkdir -p ~/code/greet && cd ~/code/greet
    go mod init example.com/greet
    emacs greet.go
  2. Press SPC g i, then RET. The folder is now a git repo, and that is what makes it a project for every SPC p key. q closes magit.

  3. Press i and type the function. Completion pops up after fmt.Sp. Save with :w; gofmt tidies the spacing.

    package greet
    
    import "fmt"
    
    // Greet says hello to name.
    func Greet(name string) string {
    	return fmt.Sprintf("Hello, %s", name)
    }
  4. SPC . and open greet_test.go. Write a test with two cases:

    package greet
    
    import "testing"
    
    func TestGreet(t *testing.T) {
    	cases := []struct{ in, want string }{
    		{"Abed", "Hello, Abed!"},
    		{"", "Hello, stranger!"},
    	}
    	for _, c := range cases {
    		if got := Greet(c.in); got != c.want {
    			t.Errorf("Greet(%q) = %q, want %q", c.in, got, c.want)
    		}
    	}
    }
  5. SPC p c, clear the suggested make -k with C-a C-k, type go test ./... and RET. Both cases fail, and each failure is a link. M-g n jumps to the first one in greet_test.go; press it again for the next.

  6. Fix Greet, save, and press SPC p c then RET: it remembers the command. Inside the *compilation* window, gr reruns it too. You get ok example.com/greet.

    func Greet(name string) string {
    	if name == "" {
    		name = "stranger"
    	}
    	return fmt.Sprintf("Hello, %s!", name)
    }
  7. Put the cursor on Greet and press SPC c r, then type Hello. gopls renames it in both files, never touching strings that merely contain the word. gr on it lists every use; K shows its doc comment.

  8. Commit: SPC g g, put the cursor on Untracked files and press s to stage them all, then c c. The message buffer opens in normal state, so press i, write the message, and finish with C-c C-c.

New keys: SPC g i SPC p c M-g n M-g p gr (rerun, in *compilation*) SPC c r gr (every use, in code) K SPC g g

tutorial 2 · about 20 minutes

Java: one file, then a Maven project

Goal: compile and run a single file with a deliberate mistake, then move to a Maven project with tests, the way most real Java code is built.

Part A · a single file

  1. mkdir -p ~/code/hello && cd ~/code/hello && git init
    emacs Hello.java
  2. Type this, typo included. Within a few seconds jdtls starts, [eglot:hello] appears in the mode line, and nme gets underlined. SPC c d lists the errors in this file.

    public class Hello {
        public static void main(String[] args) {
            String name = args.length > 0 ? args[0] : "Abed";
            System.out.println("Hello, " + nme);
        }
    }
  3. SPC p c, clear the prompt, run javac Hello.java. The cannot find symbol error is a link: M-g n lands on line 4.

  4. Fix it (cw on nme, type name), save, then SPC p c with java Hello.java World. Since Java 11 a single source file runs directly, with no separate compile step. You see Hello, World.

Part B · a Maven project

Maven isn't installed yet, so this half hasn't been run in your setup. These are the standard commands.

  1. sdk install maven
    cd ~/code
    mvn archetype:generate -DgroupId=com.example -DartifactId=demo \
      -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
    cd demo && git init
    emacs src/main/java/com/example/App.java
  2. jdtls reads pom.xml and fetches the dependencies the first time, which can take a minute; the mode line shows when it's busy. After that, completion knows your libraries too.

  3. SPC p c with mvn -q test. Compiler errors appear as [ERROR] …/App.java:[12,5] … and are links, so M-g n works the same as with Go. To run one test class: mvn -q test -Dtest=AppTest.

  4. On an error, SPC c a offers fixes such as adding an import or creating the missing method. SPC c r renames across classes.

gd works across your own classes. Jumping into JDK or library classes needs an extra package (jdtls serves them as jdt:// class files), which this config doesn't set up.

New keys: SPC c d SPC c a cw, plus everything from tutorial 1, which works the same way here.

tutorial 3 · about 10 minutes

Find your way around code you didn't write

Goal: move through an unfamiliar codebase by meaning instead of by scrolling. Start in the greet project from tutorial 1.

  1. In greet.go, put the cursor on Sprintf and press gd. You are now inside Go's own source, fmt/print.go. C-o takes you back.

  2. Go there again and press SPC s i: every function in the file, filtered as you type. Try Fprint.

  3. Back in your project, on Hello press gr: every use, in a list. RET opens one. M-g n and M-g p walk the list without leaving your code.

  4. SPC s r and type want: ripgrep across the whole project, previewing each hit as you move.

  5. SPC w v splits the window. Then SPC p f opens greet_test.go on the right, SPC w h / SPC w l hop between the halves, and SPC w o goes back to one window.

  6. Found a spot you'll need again? SPC r m and give it a name. SPC r b brings you back from anywhere, even after a restart.

  7. SPC , then b SPC for open buffers only, or m SPC for bookmarks only. C-^ flips between your last two buffers.

New keys: gd C-o SPC s i gr M-g n SPC s r SPC w v SPC w o SPC r m SPC r b C-^

tutorial 4 · about 15 minutes

Teach Emacs a new trick in Lisp

Goal: write your own command, try it while Emacs runs, give it a key under SPC i, and keep it in your config.

  1. SPC b x opens *scratch*. Press i and type this. When you type (, Emacs adds the ); typing ) over it just steps past.

    (defun my/insert-date (with-time)
      "Insert today's date.  With C-u, the time too."
      (interactive "P")
      (insert (format-time-string
               (if with-time "%Y-%m-%d %H:%M" "%Y-%m-%d"))))

    ESC, cursor anywhere inside it, SPC e d. The echo area says my/insert-date: the command exists now.

  2. Run it by name with SPC SPC my/insert-date. Then SPC h f my/insert-date shows your own docstring: Emacs documents your code like its own.

  3. Give it a key while Emacs runs: type this line and press SPC e d on it.

    (keymap-set my/leader-map "i d" #'my/insert-date)

    In insert state, M-SPC i d types today's date and C-u M-SPC i d adds the time. (In normal state the text lands before the cursor, which is why insert state suits it.) This works at once because keymap-set changes the live map. Editing the big my/leader-map block in init.el builds a new map, and that's why those edits need a restart.

  4. Keep it: SPC f c, find ;;; Leader key, paste the defun under my/sudo-this-file, and add this line inside my/leader-map:

    "i" (cons "insert" (define-keymap "d" #'my/insert-date))

    Restart Emacs. SPC now shows i as +insert.

  5. Stretch: a command that copies the current file's path. Thanks to OSC 52 it reaches your laptop's clipboard even over SSH. Add it the same way, as "y" #'my/copy-file-path inside the "f" group, so it lives at SPC f y.

    (defun my/copy-file-path ()
      "Copy this buffer's file path, ready to paste anywhere."
      (interactive)
      (kill-new buffer-file-name)
      (message "Copied %s" buffer-file-name))
  6. Commit and share it: SPC p p, pick the Emacs config, m, stage with s, c c, i and the message, C-c C-c, then P u to push. On the server, git pull.

Reading Lisp in five lines

  • (f a b) calls f with a and b. Code and data are both lists.
  • (defun name (args) "doc" (interactive) body) makes a command you can bind to a key.
  • (setq x 1) sets a variable; (let ((x 1)) …) makes one that only lives inside.
  • SPC e e evaluates anything you type; M-x ielm is a Lisp prompt to play in.
  • SPC h f and SPC h v explain any function or variable, with a link to its source.

tutorial 5 · about 15 minutes

Change a lot at once, then ship it

Goal: make a sweeping change safely, review it piece by piece, and commit only what you mean.

  1. Rename by meaning: SPC c r on a symbol in Go or Java renames it in every file. Comments and strings that happen to contain the word stay as they are.

  2. Replace text across the project: SPC p r, type a regexp, then its replacement. At each match: y replaces, n skips, ! replaces the rest in this file, q stops.

  3. Repeat an edit with a vim macro: qa, make the change on one line, finish with j0, then q. @a replays it once, @@ again, 10@a ten times.

  4. Rename files the way you edit text: SPC d j, then C-x C-q. Edit the names (even :%s/old/new/ works), then C-c C-c applies, or C-c C-k cancels.

  5. Review with SPC g g. TAB on a file opens its diff. s on one hunk stages only that hunk, and u unstages. For a few lines, select them with v, then s.

  6. c c, i, write what changed and why, C-c C-c. P u pushes. Whatever you didn't stage stays in your working copy for the next commit.

New keys: SPC p r qa … q @a @@ C-x C-q TAB s u v c c P u

tutorial 6 · about 20 minutes

Magit: branch, stash, merge, resolve a conflict

Goal: work on a branch, set unfinished work aside, merge it back and fix the conflict, all from magit's status buffer. Use the greet project from tutorial 1.

  1. SPC g g. The status buffer is the hub: j/k move, TAB opens or closes a section, gr refreshes. Every letter opens a small menu that lists the next keys, so you can explore without memorising. SPC g SPC shows all of them.

  2. New branch: b c, RET to start from where you are, and name it excited. The header now reads Head: excited.

  3. In greet.go, change "Hello, %s!" to "Hey, %s!" and save. In magit, TAB on greet.go shows the diff, and s stages it. Then c c, i, the message, C-c C-c.

  4. Set work aside: make another small edit, save, then z z and call it wip. Your working copy is clean again, and z p brings the edit back later.

  5. Switch back: b b, pick master. Change the same line to "Hi, %s!" and commit it the same way.

  6. Merge: m m, pick excited. Both branches changed the same line, so magit lists greet.go as unmerged.

  7. RET on greet.go opens it with conflict markers. C-c ^ u keeps your side (the upper one), C-c ^ l takes theirs, and C-c ^ n jumps to the next conflict. Save.

  8. Back in magit, move onto greet.go and press s. Then c c: the merge message is already written, so just C-c C-c.

  9. History: l l shows the log as a graph, RET on a commit shows what it changed, and q goes back. In any file, SPC g b shows who last changed each line; q leaves.

Branching, committing, the merge and the conflict were run here. The z z name prompt, the log and blame weren't.

New keys: b c b b z z z p m m C-c ^ u C-c ^ l C-c ^ n l l SPC g b SPC g SPC

tutorial 7 · about 10 minutes

Eshell: a shell that speaks Lisp

Goal: use a shell where commands, Lisp and Emacs buffers mix, and where cd can take you onto your server.

  1. In a project, SPC p e opens Eshell at its root; anywhere else, SPC e s. RET runs the command in either vim state.

  2. Ordinary commands work: ls, git status, go test ./.... The output is a normal buffer, so / searches it and y copies from it.

  3. Lisp works at the same prompt: (* 6 7) prints 42. You can mix the two: echo (format-time-string "%A") prints today's weekday.

  4. Send output into a buffer: ls *.go > #<buffer gofiles>. Then SPC , and gofiles shows it.

  5. grep -n Hello *.go puts the results in a *grep* buffer where each hit is a link: RET or M-g n.

  6. find-file go.mod opens a file in Emacs straight from the prompt.

  7. M-p and M-n walk through the commands you ran before.

  8. On your server: cd /ssh:HOST:~ and Eshell carries on over SSH. ls lists remote files, and find-file notes.txt edits one with your local Emacs. This part of Emacs is called TRAMP.

Steps 1 and 4 to 6 were run here. The echo mix, the history keys and the SSH step weren't.

New keys: SPC p e SPC e s M-p M-n, plus (lisp), > #<buffer …>, find-file and /ssh: paths

tutorial 8 · about 10 minutes

Dired: manage files in two panes

Goal: copy, move, rename and tidy files from the keyboard, the way a two-pane file manager works.

  1. SPC d j opens the folder of the current file. j/k move, l opens, h goes up a folder.

  2. + makes a folder. Call it archive.

  3. Mark files: m marks, u unmarks, U clears every mark, t flips them. %m marks by pattern: type \.go$ for every Go file.

  4. Two panes: SPC w v splits, then open archive in the right pane. Back in the left one, C copies the marked files. Dired suggests the other pane as the destination, so RET is enough. r moves or renames the same way.

  5. Delete: d flags a file and x deletes everything flagged; D deletes the marked files at once. Both ask first, and deleted files are gone for good, not moved to a trash folder.

  6. Run a command on the marked files: X, then wc -l. Z compresses or uncompresses a file.

  7. Search and replace inside the marked files: Q, the regexp, the replacement, then the same y / n / ! keys as SPC p r.

  8. E opens a file with its system app, such as an image viewer or a PDF reader (Emacs 30, in a window).

These keys were checked against evil-collection's dired bindings, not run step by step.

New keys: + m u U t %m C r d x D X Z Q E

tutorial 9 · about 15 minutes

Org: notes that link, tables that align, code that runs

Goal: get comfortable with the Org basics behind life.org and writing/, in a practice file you delete afterwards.

  1. SPC . and open ~/org/practice.org. A new Org file gets a title and date header by itself.

  2. Type * Ideas and, below it, ** First one. TAB on a heading folds it; S-TAB cycles the whole file between an outline and everything.

  3. A table: type | name | lang | and press TAB. Org lines it up and moves to the next cell. Fill a row, then |- and TAB draws a rule (so does SPC m b -).

  4. A link: C-c C-l, type file:~/code/greet/greet.go or a web address, then a description. RET on the link follows it.

  5. Make a heading a task with SPC m t (TODO, then NEXT, …). SPC m d t then RET inserts today's date.

  6. Code that runs: <s TAB, write emacs-lisp after BEGIN_SRC, put (+ 1 2) inside, then C-c C-c inside the block. Org asks once, then writes the result, 3, under the block.

  7. Capture without leaving your work: SPC m c s writes a spark at the top of life.org. C-c C-c saves it and takes you back; C-c C-k cancels.

  8. Export: SPC m e, then h o writes an HTML page and opens it in your browser.

This follows standard Org behaviour and wasn't run step by step here.

New keys: S-TAB C-c C-l SPC m t SPC m d t C-c C-c C-c C-k SPC m e

tutorial 10 · about 10 minutes

Grow the config: add a package, then remove it

Goal: add markdown-mode for README files the declarative way, configure it, keep both machines alike, and practise removing a package.

  1. SPC f c, then under ;;; Packages add markdown-mode to the list. It comes from NonGNU ELPA, one of the release archives.

  2. Give it a block, for example under ;;; Programming:

    (use-package markdown-mode
      :mode ("README\\.md\\'" . gfm-mode)   ; GitHub-flavoured for READMEs
      :custom (markdown-fontify-code-blocks-natively t))
  3. Restart Emacs. Startup notices the missing package and installs it. Open README.md: headings and code blocks are coloured now.

  4. See what it added: SPC h m lists the keys of the current mode.

  5. Commit and push (SPC p p, the config, m, …). On the server, git pull and restart Emacs: it installs the same package there.

  6. Practise removing it: delete the name and the block, restart, then M-x package-autoremove. It offers to delete markdown-mode; answer y.

  7. About once a month, M-x package-upgrade-all on both machines keeps them current and alike.

Not run here, since it downloads a package. The install-on-startup and autoremove behaviour it relies on was tested when this config was built.

New keys: SPC h m M-x package-autoremove M-x package-upgrade-all, plus :mode and :custom in a use-package block

What's installed ;;; packages

Everything downloaded is one list near the top of init.el. Everything else ships with Emacs.

downloaded · 12

built in, switched on and set up

Where things live ;;; files

Settings go in init.el. Commands you wrote yourself go in lisp/. What Emacs downloads or remembers stays out of git.

~/.config/emacs/
├── early-init.el   startup, frame look
├── init.el         everything else
├── lisp/
│   ├── my-org-notes.el   notes commands
│   ├── my-todotxt.el     todo.txt helpers
│   └── which-keymap.el   SPC h K
├── themes/         gruber-darker
├── docs/index.html this guide
├── README.md
└── elpa/, history ...  not in git
;; init.el after zM
;;; Packages...           the download list
;;; Where things are...   PATH, lisp/
;;; Emacs itself...       scratch, backups
;;; Evil...
;;; Leader key...         every SPC binding
;;; Completion...
;;; Help...
;;; Files and projects...
;;; Git...
;;; Programming...        eglot, go, folding
;;; Terminal...           mouse, clipboard
;;; Org and notes...
;;; todo.txt...
;;; Look...               theme, italics

Changing things ;;; changing

On the server, and Java ;;; remote

The server runs Emacs 29.3. The same files work there; this exact setup was tested in an Ubuntu 24.04 container.

  1. Get the config. The first start downloads the packages, which takes about a minute.

    git clone git@github.com:alrawas/emacs-config.git ~/.config/emacs
    emacs -nw
  2. Let copying in Emacs reach your laptop's clipboard through tmux. Add this to ~/.tmux.conf on the server. The second line gives tmux full colors from alacritty.

    set -g set-clipboard on
    set -as terminal-features ',alacritty:RGB'
  3. Only if emacs -nw says the terminal type alacritty is not defined: run this once from the laptop.

    infocmp -x alacritty | ssh HOST -- tic -x -
  4. Install the language server and ripgrep on the server too. go install doesn't care which folder you run it from: with @latest it builds the named version and puts it in ~/go/bin.

    go install golang.org/x/tools/gopls@latest
    sudo apt install ripgrep
  5. Java, on any machine with Java 21: install jdtls 1.61.0, the last release that runs on it (newer ones need Java 25), and put its launcher on your PATH. Add Maven or Gradle if your projects use them.

    mkdir -p ~/.local/share/jdtls
    curl -L https://download.eclipse.org/jdtls/milestones/1.61.0/jdt-language-server-1.61.0-202609031315.tar.gz | tar -xz -C ~/.local/share/jdtls
    ln -s ~/.local/share/jdtls/bin/jdtls ~/.local/bin/jdtls
    sdk install maven

Two terminal habits: hold Shift while dragging to use the terminal's own selection, and start Emacs with emacsclient -t -a '' to keep one Emacs alive between SSH sessions.

What changed from the old config ;;; changes

keys

  • Bookmarks moved from SPC b to SPC r (m set, b jump, l list).
  • SPC h t is now the Emacs tutorial. Switch themes with M-x consult-theme.
  • SPC h r r is gone. Restart Emacs instead; it starts in under a second. For one block, SPC e d inside it.
  • SPC f u is gone. Type a /sudo::/etc/... path, or press SPC f U on an open file.
  • Gone with their packages: SPC o, SPC =, the neotree, vterm and peep keys, and SPC m B.
  • New: SPC ,, SPC c, SPC s s/i/r, SPC x, SPC p m.

behaviour

  • Line numbers show only in code and text. Long lines wrap only in prose.
  • The completion popup appears only in code, so writing in org stays quiet.
  • RET in normal state moves down a line, as in vim, instead of inserting one. On an org link it follows the link.
  • In insert state, RET indents the new line again.
  • Backups go to ~/.config/emacs/backups/ instead of ~/.Trash.
  • Startup opens *scratch*. There is no dashboard.
  • Org no longer adds org-capture-last-stored bookmarks.
  • The old literate config.org is in git history, in the commit “Snapshot the literate config before the rewrite”.