此外,您不希望服务器以批处理模式启动。因此,在我的.emacs中,我使用
(defconst --batch-mode
(or noninteractive (member "--batch-mode" command-line-args))
"True when running in batch-mode (--batch-mode command-line switch set).")
接着
(unless --batch-mode
(require 'server)
(when (and (= emacs-major-version 23)
(= emacs-minor-version 1)
(equal window-system 'w32))
;; Suppress error "directory ~/.emacs.d/server is unsafe" on Windows.
(defun server-ensure-safe-dir (dir) "Noop" t))
(server-start))
服务器功能仍然反复无常:server-start
当%HOME%/.emacs.d/server目录不存在时抛出。连续 Emacs 不会再启动了!显而易见的解决方案是创建丢失的目录并重试;我在网上的某个地方找到了解决方案,但真的不记得在哪里。以下代码在我的几台 Windows 机器上成功运行多年:
(unless --batch-mode
(require 'server)
(when (and (= emacs-major-version 23)
(= emacs-minor-version 1)
(equal window-system 'w32))
;; Suppress error "directory ~/.emacs.d/server is unsafe" on Windows.
(defun server-ensure-safe-dir (dir) "Noop" t))
(condition-case nil
(server-start)
(error
(let* ((server-dir (if server-use-tcp server-auth-dir server-socket-dir)))
(when (and server-use-tcp
(not (file-accessible-directory-p server-dir)))
(display-warning
'server (format "Creating %S" server-dir) :warning)
(make-directory server-dir t)
(server-start))))
)
)
此代码在从棒上运行 Emacs 时也有效。
希望这可以帮助。