Use emacsclient and have a emacs server running at all times. Super fast startup times, you can even use emacsclient -nw (or make an alias 'e' for that) in the terminal for fast edits with instantaneous startup.
You could also make a script that starts emacs as a client only if a server already is running
#!/bin/sh
if [ "$#" -eq 0 ]
then
echo "Starting new Emacs process ..." >&2
nohup emacs > /dev/null 2>&1 &
elif emacsclient -n "$@" 2> /dev/null
then
echo "Opened $@ in Emacs server" >&2
else
echo "Opening $@ in a new Emacs process ..." >&2
nohup emacs "$@" > /dev/null 2>&1 &
fi
(Copied from an emacs starter kit but don't remember which...)
As a tip, if you enjoy quick startup times, you might want to try running emacs in daemon mode. Just fire up a emacs --daemon instance, and you can then use emacsclient to instantly connect to it.
Users who want fast startup simply load emacs-server once on system startup and run the emacsclient when needed. Emacs starts in a jiffy when done this way. Of course this probably will not help you with resetting accumulated states.
Fast startup times are solved by never quitting emacs :) Really, emacsclient starts nearly instantly, and all the heavy stuff like language servers and emacs proper just run in server mode.
Parent is talking about using "emacsclient". Basically you start Emacs in daemon mode (e.g. add "(server-start)" at end of config), and you never kill it. You just pay slow startup cost once, any subsequent client invocation after that is instantaneous.
Run `emacs -nw --daemon` to start a background emacs server.
Now, you can do `emacsclient -nw <file>` to boot up with almost no startup time. I have vi aliased to this, and `emacs -nw --daemon` opened by launchctl.
A gotcha: If you change your emacs config and need to restart, be sure to `pkill emacs` to get rid of the daemon.
The best way to run emacs IMO is to use "emacs --daemon" to spawn a single daemon process, and then connect to it using emacsclient. Then, startup time is instant!
Doom Emacs loads very fast so theoretically it's possible to configure Emacs to be fast too (mine starts in a second, cold start is a little slower).
But I think most people don't care about it enough because they either never close Emacs and/or use it in server-mode where emacsclient is pretty much instantaneous. Can I ask why you don't like doing that?
reply