Search code examples
emacsemacsclient

How to keep emacsclient alive after file closed?


I start emacs with /usr/local/bin/emacs --fg-daemon via launchd, and open emacsclient frames in the terminal via /usr/local/bin/emacsclient -t -s $TMPDIR/emacs$(id -u)/server $filename.

When I close (via C-x k or C-x #) the buffer/file that I passed to emacsclient when I opened the frame, the frame closes on me.

How can I keep the emacsclient frame open after I close the file/buffer I passed when I opened it?


Solution

  • Usually, Emacs will delete the client frame when you finish editing the file passed to emacsclient.

    You can instead open file by

    emacsclient SOME_ARGS_YOU_SPECIFIED \
                --eval '(find-file YOUR-FILENAME)'
    

    Or you can write a shell function that passes the filename to emacsclient the way described above.