iqbalansari / restart-emacs

A simple emacs package to restart emacs from within emacs
GNU General Public License v3.0
154 stars 14 forks source link

Allow starting new instance of Emacs without killing current session #19

Closed raxod502 closed 3 years ago

raxod502 commented 3 years ago

I frequently use restart-emacs when testing modifications to my Emacs configuration. However, restarting is not always the best way to test changes, because if the changes are broken, then I no longer have a working Emacs session with which to fix them. It's better if I can start a new session to see if the changes work, before killing the original session if desired.

This PR implements a new user option restart-emacs-inhibit-kill-p which, if non-nil, tweaks the behavior of the restart-emacs function to start a new session instead of performing a restart. I have been using this feature for a few years via el-patch but figured it might be desired upstream.

Please let me know if additional changes or information are needed.

iqbalansari commented 3 years ago

Hi @raxod502, thanks for the PR and the detailed explanation. I was wondering if this is better suited as a separate command rather than a variable. I think it is convenient from the user's perspective to have a separate command which the user can invoke without having to set a variable, thoughts?

raxod502 commented 3 years ago

That seems reasonable. What do you think of making the user option a private variable, and introducing a new command that will bind it to non-nil around calling restart-emacs?

Alternatively, I could try factoring out some of the logic of restart-emacs into a utility function and then implement two separate commands (for restarting and starting a new session) which would use that utility function in order to reduce the amount of code duplication.

iqbalansari commented 3 years ago

I think the first approach, a private variable with a helper command to which binds to to non-nil while calling restart-emacs, would work for now

raxod502 commented 3 years ago

The latest commit should implement the desired functionality, thanks for the feedback. Let me know if updates to changelog or tests are desired as well.

raxod502 commented 3 years ago

Updated the README as well.

iqbalansari commented 3 years ago

Thanks a lot @raxod502