# emacs-mirror/emacs architecture

> Architecture diagram of the GitHub repository emacs-mirror/emacs, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/emacs-mirror/emacs
- Repository: https://github.com/emacs-mirror/emacs

## Overview

GNU Emacs is an extensible, customizable, self-documenting real-time display editor. A user enters commands through a terminal or graphical interface; Emacs evaluates commands and editing operations against buffers, then redisplays the result. The README identifies the C runtime and primitives in `src`, most higher-level functionality in Lisp, and input methods in `leim`; those latter directories are not present in the supplied tree, so they are described only where the README supports them. The graph emphasizes runtime stages and major capabilities, not every platform port or utility.

Main entry points: [`src/cmds.c`](https://github.com/emacs-mirror/emacs/blob/master/src/cmds.c) (Command execution), [`src/eval.c`](https://github.com/emacs-mirror/emacs/blob/master/src/eval.c) (Lisp evaluator), [`src/buffer.c`](https://github.com/emacs-mirror/emacs/blob/master/src/buffer.c) (Buffer state), [`src/frame.c`](https://github.com/emacs-mirror/emacs/blob/master/src/frame.c) (Frames)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["User interaction"]
  node_keyboard["Input dispatch<br/>[keyboard.c]"]
  node_commands["Command execution<br/>[cmds.c]"]
  node_minibuffer["Minibuffer<br/>[minibuf.c]"]
  node_inputmethods["Input methods"]
end

subgraph group_runtime["Editor runtime"]
  node_startup["Emacs startup<br/>[emacs.c]"]
  node_reader["Lisp reader<br/>[lread.c]"]
  node_evaluator["Lisp evaluator<br/>[eval.c]"]
  node_bytecode["Bytecode runtime<br/>[bytecode.c]"]
  node_extensions["Lisp extensions"]
end

subgraph group_editing["Editing services"]
  node_buffers["Buffer state<br/>[buffer.c]"]
  node_files["File operations<br/>[fileio.c]"]
  node_search["Search and replace<br/>[search.c]"]
  node_syntax["Syntax analysis<br/>[syntax.c]"]
  node_undo["Undo history<br/>[undo.c]"]
end

subgraph group_display["Display and platforms"]
  node_redisplay["Redisplay engine<br/>[xdisp.c]"]
  node_windows["Window layout<br/>[window.c]"]
  node_frames["Frames<br/>[frame.c]"]
  node_terminal["Terminal backend<br/>[terminal.c]"]
  node_android["Android interface<br/>[androidterm.c]"]
  node_fonts["Font and text<br/>[font.c]"]
end

subgraph group_integration["External integration"]
  node_processes["Process control<br/>[process.c]"]
  node_client["Emacs client<br/>[emacsclient.c]"]
end

node_user(("Editor user"))
node_external(("External programs"))

node_user -->|"enters commands"| node_keyboard
node_keyboard -->|"dispatches"| node_commands
node_commands -->|"invokes Lisp"| node_evaluator
node_evaluator -->|"reads forms"| node_reader
node_evaluator -->|"runs bytecode"| node_bytecode
node_commands -->|"edits"| node_buffers
node_commands -->|"requests input"| node_minibuffer
node_commands -->|"accesses files"| node_files
node_commands -->|"searches text"| node_search
node_commands -->|"queries syntax"| node_syntax
node_commands -->|"records edits"| node_undo
node_files -->|"loads and saves"| node_buffers
node_search -->|"matches and replaces"| node_buffers
node_buffers -->|"supplies text"| node_redisplay
node_redisplay -->|"lays out content"| node_windows
node_windows -->|"arranges windows"| node_frames
node_frames -->|"renders through"| node_terminal
node_terminal -->|"uses fonts"| node_fonts
node_frames -.->|"platform interface"| node_android
node_processes -->|"starts processes"| node_external
node_client -->|"communicates with server"| node_external
node_inputmethods -.->|"provides character input"| node_keyboard
node_extensions -.->|"extends behavior"| node_evaluator
node_startup -->|"loads Lisp"| node_reader

click node_keyboard "https://github.com/emacs-mirror/emacs/blob/master/src/keyboard.c"
click node_commands "https://github.com/emacs-mirror/emacs/blob/master/src/cmds.c"
click node_minibuffer "https://github.com/emacs-mirror/emacs/blob/master/src/minibuf.c"
click node_startup "https://github.com/emacs-mirror/emacs/blob/master/src/emacs.c"
click node_reader "https://github.com/emacs-mirror/emacs/blob/master/src/lread.c"
click node_evaluator "https://github.com/emacs-mirror/emacs/blob/master/src/eval.c"
click node_bytecode "https://github.com/emacs-mirror/emacs/blob/master/src/bytecode.c"
click node_buffers "https://github.com/emacs-mirror/emacs/blob/master/src/buffer.c"
click node_files "https://github.com/emacs-mirror/emacs/blob/master/src/fileio.c"
click node_search "https://github.com/emacs-mirror/emacs/blob/master/src/search.c"
click node_syntax "https://github.com/emacs-mirror/emacs/blob/master/src/syntax.c"
click node_undo "https://github.com/emacs-mirror/emacs/blob/master/src/undo.c"
click node_redisplay "https://github.com/emacs-mirror/emacs/blob/master/src/xdisp.c"
click node_windows "https://github.com/emacs-mirror/emacs/blob/master/src/window.c"
click node_frames "https://github.com/emacs-mirror/emacs/blob/master/src/frame.c"
click node_terminal "https://github.com/emacs-mirror/emacs/blob/master/src/terminal.c"
click node_android "https://github.com/emacs-mirror/emacs/blob/master/src/androidterm.c"
click node_fonts "https://github.com/emacs-mirror/emacs/blob/master/src/font.c"
click node_processes "https://github.com/emacs-mirror/emacs/blob/master/src/process.c"
click node_client "https://github.com/emacs-mirror/emacs/blob/master/lib-src/emacsclient.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_keyboard,node_commands,node_minibuffer,node_inputmethods,node_user toneBlue
class node_startup,node_reader,node_evaluator,node_bytecode,node_extensions toneAmber
class node_buffers,node_files,node_search,node_syntax,node_undo toneMint
class node_redisplay,node_windows,node_frames,node_terminal,node_android,node_fonts toneRose
class node_processes,node_client,node_external toneIndigo
```

## Components

### User interaction

- [Input dispatch](https://github.com/emacs-mirror/emacs/blob/master/src/keyboard.c): `src/keyboard.c`
- [Command execution](https://github.com/emacs-mirror/emacs/blob/master/src/cmds.c): `src/cmds.c`
- [Minibuffer](https://github.com/emacs-mirror/emacs/blob/master/src/minibuf.c): `src/minibuf.c`
- **Input methods**

### Editor runtime

- [Emacs startup](https://github.com/emacs-mirror/emacs/blob/master/src/emacs.c): `src/emacs.c`
- [Lisp reader](https://github.com/emacs-mirror/emacs/blob/master/src/lread.c): `src/lread.c`
- [Lisp evaluator](https://github.com/emacs-mirror/emacs/blob/master/src/eval.c): `src/eval.c`
- [Bytecode runtime](https://github.com/emacs-mirror/emacs/blob/master/src/bytecode.c): `src/bytecode.c`
- **Lisp extensions**

### Editing services

- [Buffer state](https://github.com/emacs-mirror/emacs/blob/master/src/buffer.c): `src/buffer.c`
- [File operations](https://github.com/emacs-mirror/emacs/blob/master/src/fileio.c): `src/fileio.c`
- [Search and replace](https://github.com/emacs-mirror/emacs/blob/master/src/search.c): `src/search.c`
- [Syntax analysis](https://github.com/emacs-mirror/emacs/blob/master/src/syntax.c): `src/syntax.c`
- [Undo history](https://github.com/emacs-mirror/emacs/blob/master/src/undo.c): `src/undo.c`

### Display and platforms

- [Redisplay engine](https://github.com/emacs-mirror/emacs/blob/master/src/xdisp.c): `src/xdisp.c`
- [Window layout](https://github.com/emacs-mirror/emacs/blob/master/src/window.c): `src/window.c`
- [Frames](https://github.com/emacs-mirror/emacs/blob/master/src/frame.c): `src/frame.c`
- [Terminal backend](https://github.com/emacs-mirror/emacs/blob/master/src/terminal.c): `src/terminal.c`
- [Android interface](https://github.com/emacs-mirror/emacs/blob/master/src/androidterm.c): `src/androidterm.c`
- [Font and text](https://github.com/emacs-mirror/emacs/blob/master/src/font.c): `src/font.c`

### External integration

- [Process control](https://github.com/emacs-mirror/emacs/blob/master/src/process.c): `src/process.c`
- [Emacs client](https://github.com/emacs-mirror/emacs/blob/master/lib-src/emacsclient.c): `lib-src/emacsclient.c`

### Other components

- **Editor user**
- **External programs**

## Connections

- Editor user → Input dispatch: enters commands
- Input dispatch → Command execution: dispatches
- Command execution → Lisp evaluator: invokes Lisp
- Lisp evaluator → Lisp reader: reads forms
- Lisp evaluator → Bytecode runtime: runs bytecode
- Command execution → Buffer state: edits
- Command execution → Minibuffer: requests input
- Command execution → File operations: accesses files
- Command execution → Search and replace: searches text
- Command execution → Syntax analysis: queries syntax
- Command execution → Undo history: records edits
- File operations → Buffer state: loads and saves
- Search and replace → Buffer state: matches and replaces
- Buffer state → Redisplay engine: supplies text
- Redisplay engine → Window layout: lays out content
- Window layout → Frames: arranges windows
- Frames → Terminal backend: renders through
- Terminal backend → Font and text: uses fonts
- Frames → Android interface: platform interface
- Process control → External programs: starts processes
- Emacs client → External programs: communicates with server
- Input methods → Input dispatch: provides character input
- Lisp extensions → Lisp evaluator: extends behavior
- Emacs startup → Lisp reader: loads Lisp
