Keep Emacs running in the background on Android

April 22, 2026

emacs

When not running as a daemon, Emacs kills the process when the last frame is deleted. On Android, this happens when you close the app from your recent apps list. Overriding handle-delete-frame lets you stop Emacs from shutting itself down, letting it run in the background for as long as you’d like.

(advice-add 'handle-delete-frame :override
          (lambda (event)
            (let* ((frame (posn-window (event-start event))))
              (delete-frame frame t))))