# AGENTS.md — willem's .doom.d This file provides context for LLM coding agents working on this Doom Emacs configuration repository. ## Repository Overview This is a [Doom Emacs](https://github.com/doomemacs/doomemacs) configuration at `~/.doom.d/`. The Doom framework lives in `~/.emacs.d/` (managed via straight.el). This repo only contains user configuration: - `init.el` — Doom module declarations (what features to enable) - `config.el` — Main user configuration (editor settings, keybindings, org, latex, gptel, etc.) - `packages.el` — Package declarations for `doom sync` - `custom.el` — Auto-generated by Emacs' customize system - `config-mac.el` — Mac-specific configuration (gptel backends, LLM tools) - `config-local.example.el` — Example local overrides (not committed with secrets) ### Custom Package Directories **`mostalive/`** — Personal extensions by Willem (@mostalive) - `my-org-roam.el` — `org-roam-node-insert-immediate` (insert link without opening buffer), org-agenda file collection, log file opener - `journelly-convert-entry-to-org-roam.el` — Convert Journelly app entries to org-roam notes - `convert-chats-to-org.el` — Chat log formatting utilities **`qwan/`** — QWAN partnership utilities - `qwan-blog.el` — Blog publishing helpers (publish draft to `../_posts/`, org-to-markdown link conversion, image markdown link creation, URL stripping) - `qwan-refactor.el` — Elisp refactoring utilities with ERT tests (rename function at point, remove tests, `as-function-name`) - `qwan-markdown-dnd.el` — Drag-and-drop image attachment for markdown buffers (copies dropped files to `attachments/`, inserts markdown link) **`coe-xx/`** — Cross-stitch pattern editor (from Craft of Emacs guide) - `coe-xx.el` — Major mode for `.coe-xx` pattern files - `coe-demo.el` — Demo functions ## User Identity - **Willem van den Ende** — @mostalive - **QWAN** — partnership entity (Willem's collaborative practice) - **Org-roam directory**: `~/MyDocuments/qwan/essays/willem/` - **Blog**: Static site, markdown files in `../_posts/` relative to org-roam dir - **Mastodon**: @mostalive@mastodon.social ## Workflow Patterns ### Key Commands | Action | Command | |--------|---------| | Reload config | `M-x doom/reload` | | Sync packages | `doom sync` (terminal) | | Run all ERT tests | `(ert t)` | | Run matching tests | `(ert "test-pattern-*")` | ### Code Style Conventions - **Naming**: Functions use namespace prefixes: `qwan/`, `my/`, `org-roam-node-insert-immediate` (no conflict needed). - **Testing**: ERT tests follow the function being tested. Test names use `test-` prefix or describe the function. Tests live in the same file as the code. - **Loading**: Custom packages loaded via `add-load-path!` + `require` in `config.el`. - **Formatting**: `elisp-autofmt` installed for Elisp formatting. ## Markdown Drag-and-Drop **Status**: Implemented in `qwan/qwan-markdown-dnd.el` (see above). **How it works**: 1. When a file is dragged from Finder into a markdown buffer, Emacs' `dnd-protocol-alist` dispatches to `qwan-markdown-dnd-handler` 2. The handler copies the file into `qwan-markdown-attachment-dir` (default `"attachments"`, relative to the markdown file) 3. On name conflicts, appends a timestamp suffix 4. For images, inserts `![alt](path)`; for other files, inserts `[filename](path)` 5. Configure per-repo via `.dir-locals.el`: ```elisp ((markdown-mode . ((qwan-markdown-attachment-dir . "assets/images")))) ``` **Related existing code in `qwan/qwan-blog.el`**: - `qwan/image-mode-copy-filename-as-markdown-image-link` — copies markdown image link to kill-ring from an image buffer - `qwan/relative-path-to-attachments` — strips prefix to get relative path from `/attachments` - `qwan/string-as-markdown-image-link` — wraps path in markdown image syntax **Org DND**: The `+dragndrop` flag (fixed from `+download-dnd`) enables `org-download` for org-mode screenshots, clipboard images, and nicer inline previews. ## Org-mode Configuration Highlights - **org-roam** enabled with heavy customization - **org-pomodoro** + gnuplot + pretty bullets - **Export**: LaTeX with xelatex (ET Bembo font, Tufte style), HTML without preamble - **Elfeed** RSS with org integration, org-roam capture for saved articles - **Publishing**: Drafts published to `../_posts/` with date prefix ## LLM Integration (gptel / pi) - **Primary backend**: Local llama.cpp server at `localhost:8000` - **Alternative**: Ollama at `localhost:11434` - **Presets**: `explain`, `elixir`, `elisp`, `glm-fast`, `glm-think`, `glm-search` - **Custom tools**: `projectile-search` (code search), `search_notes` (org-roam RIP grep) - **pi-coding-agent**: Also installed for agentic coding assistance ## Key Editor Settings - **Theme**: leuven - **Line numbers**: relative - **Evil mode**: `evil-move-cursor-back` nil, `evil-move-beyond-eol` t - **Company**: idle delay disabled - **Magit**: magit-delta enabled, diff-hl disabled in magit (to avoid refresh errors) - **Spell check**: aspell (hunspell not used) ## Important Gotchas - Changing `init.el` or `packages.el` requires `doom sync` then `M-x doom/reload` - `load!` is Doom's version of `load` for files relative to `doom-user-dir` - `after!` runs code after a package has loaded - `use-package!` is Doom's wrapper around `use-package` - `map!` for keybindings (especially leader keys) - `add-load-path!` for adding directories to Emacs' `load-path`