plexus / chemacs

Emacs profile switcher
652 stars 45 forks source link

'--dump-file' support? #37

Closed makkus closed 3 years ago

makkus commented 3 years ago

Hi there, quick question: would it be possible, in principle, to support the '--dump-file' argument? I'd like to be able to add a dump file to a chemacs profile, for faster startup (in cases where I don't want to use emacsclient).

plexus commented 3 years ago

Hi Markus,

I'm not familiar with dump-files. Can you explain briefly what this would mean exactly?

makkus commented 3 years ago

Hi,

sorry, yes, should have given some context...

So, Emacs has this feature called 'portable dumper' which lets you dump the (memory) state of an Emacs instance (with all loaded elisp files, packages etc) into a file. If you then start Emacs with the '--dump-file [path_to_dump_file]' option, startup is much faster, since no loading of packages/elisp files has to be done anymore (at least for the packages that were loaded when the whole thing was dumped). You can reduce startup from several seconds to sub-one-second times in some instances. Also, for example the first time opening an org mode file would be much quicker, since the whole of org-mode would also already be loaded into memory.

Now, this only works on the same machine (you can't use dump files on other machines than the one used to create them), or different versions of Emacs. It also mostly only works for the same Emacs configuration used when dumping (this is why I think it'd be a good fit for chemacs, since it already makes it easy to manage those configurations).

The dumping only has to be done once. Well, until there is a configuration or other relevant change. Spacemacs for example has an option to automatically build such a dump file whenever necessary, more or less automatically. After dumping, you get the speedup with every Emacs invocation, so, for example, in a lot of cases emacsclient is not necessary anymore, since the 'normal' startup is already fast enough. I have a few other use-cases in mind, but I'd need a way to manage different Emacs configs alongside their respective dump files.

Long story short: what I would find useful is an option in a chemacs profile, to specify a path to a dump file along the other options (env, etc...). So, if such a path existed, Chemacs would then start emacs with the '--dump-file' option, pointing to the dump file in question. Does that make sense?

I could implement this myself and send a pull request, but would be keen to know whether you see any blockers/reasons this would not work with Chemacs?

plexus commented 3 years ago

That all sounds reasonable, but I'm not sure we can do that in chemacs. Chemacs is just a .emacs/init.el type script. By the time it kicks in emacs has already loaded...

makkus commented 3 years ago

Ah, ok. Makes sense. In that case I'll probably write a shell-wrapper around chemacs. Thanks!