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

request: restart emacs from emacsclient #3

Closed biocyberman closed 7 years ago

biocyberman commented 8 years ago

Most of the time use emacs via command emacsclient --alternate-editor="" -t. This start emacs-server/daemon and then connect a frame to this server. This allows me to open and close emacs windows on different directory very quickly. In addition, I can share kill ring among the opening clients. Currently, if I run restart-emacs command while I am in one of the emacsclient frame, Emacs just quits and does not recreate the frame in current terminal. My elisp skill is still not enough for me to write an additional function to do this.

This is the pseudocode I am thinking about:

(setq emacsclient-command quote(TERM=xterm-256color && emacsclient --alternate-editor="" -t))
(defun restart-emacs-from-emacsclient (&arg)
"This restart the emacs daemon and reopen a frame with current buffer. Make sure to show a warning if there are other emacsclient frames somewhere else"

(setq buffname get-current-buffer-name)
(if (other-frame-exists) (ask-for-confirmation))
(do-restart-emacs-in-demon-mode) && (call-system-command emacsclient-command buffname)
)
iqbalansari commented 8 years ago

Thanks for the bug report :smile: . I will look into this soon.

iqbalansari commented 7 years ago

Hi @biocyberman ,

I got sometime to work on this and it is mostly complete, being able to restore GUI frames opened by Emacs daemon after a restart. You can look at current state here.

However one problem with existing implementation is that there is no way restore the emacsclient instances started in a terminal (atleast with the APIs Emacs exposes currently), instead the current implementation drops a notification on the terminal with instructions to reconnect to the daemon after a restart. Thoughts? Does that work for you?

Inviting @zeltak to the discussion, since he requested a similar feature.

seagle0128 commented 7 years ago

Any update for this issue?

iqbalansari commented 7 years ago

Not much actually, as you might have read above, the problem right now is that there is no way restart-emacs can restore frames on terminals. How do you use Emacs daemon generally, specifically does my suggestion to @biocyberman

the current implementation drops a notification on the terminal with instructions to reconnect to the daemon after a restart.

Work for you?

I plan to complete to merge whatever I progress I have made this weekend since it also solves #6

Thanks

iqbalansari commented 7 years ago

Hi,

I have added support for this on the master branch (see the README for some caveats), could you please test it once MELPA updates.

Right now it is disabled by default to enable it put something like the below to your init file

(setq restart-emacs-restore-frames t)

Thanks

iqbalansari commented 7 years ago

This has been fixed in the latest version available on MELPA, the limitations in the current implementation are mentioned in the README.