Stale Lisp definitions when hot-reloading code in a running Emacs daemon
0 reputation · 07 Jan 2025, 22:20 UTC
Emacs server mode lets a single daemon process host multiple emacsclient sessions that share one Lisp image, so reloading an application's source with load-file or eval-buffer updates function definitions for every connected client at once. The refresh, however, is not guaranteed to be complete: advice attached to a function, closures that captured an earlier function object, and macro expansions already embedded in callers can keep executing old code, and reloading a file does not re-run defcustom initialization, so customized variables may retain stale values.
The Emacs documentation does not prescribe a universal hot-reload pattern, which leaves an open design choice between relying on a plain reload and calling unload-feature first to obtain a cleaner state.
- Which constructs — advice, closures, macro expansions,
defcustomdefaults — reliably survive a plainload-filereload in a daemon session, and which are refreshed? - When is
unload-featureactually required before reloading application code, and what state can it discard that a simple reload would preserve? - How should a small application be structured so its code can be updated in a live daemon without restarting connected clients?