AI generated
Configuration
The compile package is configured inlisp/init-prog.el:
compilation-scroll-outputis set to'first-error— the compilation buffer scrolls to follow output and stops scrolling when the first error appears.compilation-ask-about-saveis disabled — Emacs saves modified buffers before compiling without prompting.compilation-always-killis enabled — starting a new compilation kills any running one without asking.
Running a compilation
M-x compile prompts for a shell command and runs it. M-x recompile (or g in the compilation
buffer) re-runs the last command.
For per-language compile commands, compile-multi is configured in lisp/init-project.el with
presets for Go, Python, Haskell, Nix, and Rust:
M-x compile-multi to pick from these. The consult-compile-multi integration provides a
narrowing UI.
Navigating errors
In the compilation buffer
| Key | Command | What it does |
|---|---|---|
g | recompile | Re-run the last compilation command |
M-n | compilation-next-error | Move to the next error message |
M-p | compilation-previous-error | Move to the previous error message |
RET | compile-goto-error | Jump to the source location at point |
C-c C-f | next-error-follow-minor-mode | Auto-display source as you move through errors |
From any buffer
The standardM-g n (next-error) and M-g p (previous-error) work from any buffer — Emacs
tracks the last buffer that produced errors and jumps you there. This works across compile, grep,
occur, and any other mode that produces error-like output. M-g M-n and M-g M-p do the same
thing but are easier to type since you can hold Meta throughout.
This config also binds M-g e to consult-compile-error (in lisp/init-completion.el), which
provides a searchable, narrowable list of all compilation errors via consult.
Flymake integration
For in-buffer diagnostics,M-n and M-p are bound to flymake-goto-next-error and
flymake-goto-prev-error in flymake-mode-map (in lisp/init-prog.el). These navigate flymake
diagnostics inline without needing a compilation buffer.
Editing grep results
Thewgrep package (configured in lisp/init-prog.el) enables editing grep result buffers in place.
The workflow is:
consult-ripgrep— search across the projectC-c C-o(embark-export) — export results to a grep bufferC-x C-q— enterwgrepedit mode- Edit the results as you would any buffer
C-c C-c— apply changes to all matched files
grep-edit-mode will also be available.
How error parsing works
Compilation mode usescompilation-error-regexp-alist and compilation-error-regexp-alist-alist to
parse error output. Emacs ships with dozens of entries for GCC, Java, Ruby, Python, Perl, and many
more — no configuration needed for common tools.
Each entry has the shape:
TYPE controls severity: 2 = error, 1 = warning, 0 = info. The TYPE field can also be a
cons cell for conditional severity based on match groups.
Adding a custom error regexp
If you use a tool whose output format is not recognized, you can teach compilation mode about it:Useful variables
Beyond what this config sets, a few more compilation variables are worth knowing:The compilation mode family
Compilation mode is not just for compilers — it is the infrastructure for any structured output with source locations:- grep-mode —
M-x grep,M-x rgrep,M-x lgrepall produce compilation-derived buffers with the same navigation. - occur-mode —
M-x occurparticipates in the samenext-errorinfrastructure. - flymake — uses compilation-style error navigation under the hood.
M-g n to
jump to the next problem.