我在守护进程模式下使用 emacs,我还有一个 initial-buffer-choice
变量集。有时,当我编辑文件时,emacs 会崩溃
我用于 initial-buffer-choice
.在这种情况下,当我开始
带有 --daemon 的 emacs,它将与消息一起挂起:
"todo.org has auto save data; consider M-x recover-this-file"
由于我主要从 init 脚本启动守护程序,因此我无法确认或
拒绝这个对话框,所以守护进程永远挂起。我怎样才能绕过
在这种情况下自动保存数据的通知?我不介意失去
必要时自动保存数据。
这是我的尝试:
(defadvice command-line
(around my-command-line-advice)
"Be non-interactive while starting a daemon."
(if (and (daemonp)
(not server-process))
(let ((noninteractive t))
ad-do-it)
ad-do-it))
(ad-activate 'command-line)
但是,这不起作用。我仍然得到相同的悬挂行为。
实际上,在建议中放置一个“消息”调用表明建议
根本没有被调用。
类似问题:emacs-daemon startup freezes if file has auto-save data .但是,此解决方案不适用于
initial-buffer-choice
.接受的答案似乎是从以前的版本中编辑的,该版本可能已成功定义了对 command-line
的建议。正如我试图做的那样,但不幸的是,这个版本现在已经消失了,取而代之的是一个特定于 desktop.el 的版本。
最佳答案
一种可能性是把它放在你的 .emacs 中:
(setq auto-save-default nil)
另一个(可能更好的解决方案)是通过使用它来查找文件来抑制警告消息:
(find-file-noselect FILENAME &optional NOWARN RAWFILE WILDCARDS)
正如您在此处看到的,您可以使用可选的 NOWARN 参数抑制警告消息(因为这是导致问题的原因)。
来源:this EmacsWiki page
如果我要自己解决这个问题,您可以进行以下更改。
在 .emacs 设置中定义:
(defun find-file (filename &optional wildcards)
(interactive
(find-file-read-args "Find file: "
(confirm-nonexistent-file-or-buffer)))
; the "t" here is normally set to "nil", this should solve the problem
(let ((value (find-file-noselect filename t nil wildcards)))
(if (listp value)
(mapcar 'switch-to-buffer (nreverse value))
(switch-to-buffer value))))
编辑:到目前为止,这对任何人都没有帮助,但为了完整起见,它可能会对一些人有所帮助。
目前提问者确认的方式是使用
emacs-startup-hook
并将其与 (kill-buffer "*scratch*")
结合使用和 (find-file "~/.../todo.org")
.
关于emacs - 当初始缓冲区选择具有自动保存数据时,如何防止 emacs 挂起?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15586792/