// the find
jart/emacs-copilot
Large language model code completion for Emacs
A ~100-line Emacs Lisp script that wires a locally-running llamafile LLM into Emacs as an inline code completion tool. It streams tokens directly into your buffer and maintains per-file prompt history so the model retains context across completions. Aimed squarely at Emacs users who want local, private Copilot-style completions without cloud dependencies.
The context-tracking approach — appending each interaction to a per-file `.prompt` file and using llamafile's prompt cache — is genuinely clever and avoids re-tokenizing the whole history on every call. The kill-ring pruning that removes deleted code from the prompt history is a nice touch most similar tools miss. Being a single self-contained `.el` file you paste and eval means there's nothing to install, no package manager dependency, no breaking updates. Works on CPU-only hardware if you pick a small enough model.
The llamafile binary name is hardcoded in the Lisp source, so switching models means editing the function by hand. Last push was January 2024 — the recommended models (WizardCoder 34b) have since been lapped by much better options, and the README makes no mention of how to swap in anything else without reading the code. The two-line context window sent to the model is aggressively small; it only sees the current and previous line, not the surrounding function or file, which limits completion quality significantly. No package.el or use-package integration, so it won't survive an Emacs config reload without manual re-eval.