how do i keep emacs server running when the current window is closed (x) on windows using emacsW32?

南楼画角 提交于 2020-01-02 10:15:26

问题


I'm using EmacsW32 (patched) on windows. Emacs is running in server mode so that subsequent calls to emacsclientw open files in the same server session.

I have C-x C-c mapped to make the current frame invisible and not kill the emacs server process. I'd like clicking the window's X (close) button to also just hide the frame & not terminate the server process as it currently does.

Any ideas ? Thanks!


回答1:


Sure, I have a method of doing this. There may be refinements possible, but this is a good starting place.

First, I setup a variable and advise the kill-emacs function

(defvar bnb/really-kill-emacs nil)
(defadvice kill-emacs (around bnb/really-exit activate)
    "Only kill emacs if the variable is true"
    (if bnb/really-kill-emacs
        ad-do-it)
      (bnb/exit))

The bnb/exit function just makes the frame invisible like what you have bound to C-x C-c.

I then have an additional function to properly exit emacs if that is ever necessary. That will set the variable and call kill-emacs as follows.

(defun bnb/really-kill-emacs ()
    (interactive)
    (setq bnb/really-kill-emacs t)
    (kill-emacs))


来源:https://stackoverflow.com/questions/2001485/how-do-i-keep-emacs-server-running-when-the-current-window-is-closed-x-on-wind

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!