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

老子叫甜甜 提交于 2019-12-06 11:50:59

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