diff options
author | Chris Feng <chris.w.feng@gmail.com> | 2016-08-01T11·49+0800 |
---|---|---|
committer | Chris Feng <chris.w.feng@gmail.com> | 2016-08-01T11·49+0800 |
commit | e7ff9a9f90f0356a9ab8a9ca3857df03deeb1696 (patch) | |
tree | 9447bce3fc7f662abd70a0f0e1c242edd2b02265 /exwm.el | |
parent | 173bbde88599cf9bf8dbda87d3282c2f243716be (diff) |
Fix restarting issues
* exwm-workspace.el (exwm-workspace--confirm-kill-emacs): Prompt for unsaved files before restarting; avoid running `server-force-stop' early; restore the 'client' frame parameter before calling `exwm--exit'; correctly handle emacsclient. * exwm.el (exwm-restart): Always kill subordinate Emacs instances.
Diffstat (limited to 'exwm.el')
-rw-r--r-- | exwm.el | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/exwm.el b/exwm.el index 861d51a9707b..dd279bbcd091 100644 --- a/exwm.el +++ b/exwm.el @@ -88,10 +88,29 @@ "Restart EXWM." (interactive) (when (exwm-workspace--confirm-kill-emacs "[EXWM] Restart? " 'no-check) - (apply #'call-process (car command-line-args) nil nil nil - (cdr command-line-args)) - ;; Kill this instance at last. - (kill-emacs))) + (let* ((attr (process-attributes (emacs-pid))) + (args (cdr (assq 'args attr))) + (ppid (cdr (assq 'ppid attr))) + (pargs (cdr (assq 'args (process-attributes ppid))))) + (cond + ((= ppid 1) + ;; The parent is the init process. This probably means this + ;; instance is an emacsclient. Anyway, start a control instance + ;; to manage the subsequent ones. + (call-process (car command-line-args)) + (kill-emacs)) + ((string= args pargs) + ;; This is a subordinate instance. Return a magic number to + ;; inform the parent (control instance) to start another one. + (kill-emacs ?R)) + (t + ;; This is the control instance. Keep starting subordinate + ;; instances until told to exit. + ;; Run `server-force-stop' if it exists. + (run-hooks 'kill-emacs-hook) + (with-temp-buffer + (while (= ?R (shell-command-on-region (point) (point) args)))) + (kill-emacs)))))) (defun exwm--update-window-type (id &optional force) "Update _NET_WM_WINDOW_TYPE." |