reddit / emacs

Laptop shut down unexpectedly (0% battery). After booting up, emacs said something like "desktop in use PID #2323, do you want to use (y/n)?" I said yes. Then loaddefs.el shows up as my starting buffer? Why?

Status-Detective-783 · 2022-03-28 02:20
macport emacs v.27.2. I have `(desktop-save-mode 1)`. As per https://www.gnu.org/software/emacs/manual/html_node/emacs/Saving-Emacs-Sessions.html#Saving-Emacs-Sessions, > The file in which Emacs saves the desktop is locked while the session runs, to avoid inadvertently overwriting it from another Emacs session. That lock is normally removed when Emacs exits, but if Emacs or your system crashes, the lock stays, and when you restart Emacs, it will by default ask you whether to use the locked desktop file. So I expected emacs to just load as normal. Why did it open loaddefs.el? And what is that file?
MikeSeth · 2022-03-28 07:19
You have a stale lock file, and there is probably a debugger buffer open, because something in your system is inconsistent and triggered an error in emacs initialization
404cn · 2022-03-28 08:40
Did you enable emacs daemon on system startup?
Phil-Hudson · 2022-03-28 09:25
There are several files called `loaddefs.el` in a standard Emacs installation. Each contains a bunch of autoload declarations -- an optimization technique. Emacs normally loads such files and evaluates them silently and transparently, keeping them out of the buffer list and so on. The `desktop` package does keep track of them, however, so if your Emacs crashed while one was open, it's not surprising to find `desktop` re-opening it. Just close it.
Status-Detective-783 · 2022-03-28 17:36
I think so. I have this in my init.el (server-start)
Status-Detective-783 · 2022-03-28 17:37
Makes sense, thanks!
404cn · 2022-03-29 02:19
Yes, emacsclient will load desktop file too, so maybe start daemon manually is a good idea.
Status-Detective-783 · 2022-03-29 02:27
I'm not sure what you mean. Is the loaddefs.el file my "desktop file"? What would be the problem with containing this in my init.el? As you can see, I'm very new to all this. btw, the only reason I'm including it in my init.el right now, is because I'm using macport emacs, and if I want to fire up emacs from my command-line, yet use my GUI instance of emacs, then starting up the server provides for that.
404cn · 2022-03-29 02:35
My English is poor, but I will try to explain this in my experience. You have `(desktop-save-mode 1)` in your config file, so emacs will save "session" in a file called ".emacs-desktop", and if you start emacs it will try to load this file, if there already an emacs started(emacsclient, even you didn't start GUI or TUI), and then you start another emcas, it will ask "desktop in use PID....", and you say yes, then this new emacs load your ".emacs-desktop" file. Why loaddef.el is your start buffer? Because the "session" save this to ".emacs-desktop" file(may be file opened on your previous emacs), when you load this file it open everything save in this "session".
404cn · 2022-03-29 02:38
And yes, loaddefs.el is in your "desktop file", and it's not a problem.
Status-Detective-783 · 2022-03-29 05:20
Thanks!