recentf 会导致 emacs卡死

编辑过 samba目录下的文件,然后虚拟机关了,调用recentf时,可能是要清理不存在的文件,但是挂载盘符又不存在了,导致emacs卡住,不知道怎样禁止recentf清理文件?

(setq recentf-auto-cleanup 'never)

你这种情况可以先用 emacs -Q 打开 recentf 的保存文件手动把造成影响的部分 entry 删除.

1 个赞

好,多谢!!

与其禁止自动清理,不如添加进 recentf 之前,把那些挂载的过滤掉(用 ``` recentf-exclude

清理 recentf 不就是要剔除失效的文件条目吗,为什么遇到 samba 会卡住?不报错还是没捕捉错误?应该有比禁止更好的方法。

因为 samba 导致的 recent 清理出现问题的报告我只找到一条 Recent recentf slowdown? 它也只是名称中包含了samba 字样。

我又用emacs -q启动试了一下,确实会卡很久。

步骤如下:

1.emacs -q启动,eval-buffer以下代码(在test-recentf.el中)

(require 'recentf)
(setq recentf-max-saved-items 100)
(recentf-mode 1)

2.挂载samba目录到v: 盘

3.在emacs中打开v盘中一个简单的cpp文件

4.看下recentf-list 中有这个文件记录后,C-x C-c退出

5.关闭虚拟机smb

$ sudo /etc/init.d/smbd stop

6.再次emacs -q启动,打开 test-recentf.el,M-x eval-buffer,看到minibuffer中显示 Cleaning up … recentf list…,

此时emacs卡了几十秒,不能编辑,鼠标拉伸窗口,就变成白屏,几十秒后windows弹出一个网络连接出错的窗口,然后emacs才恢复了

图片

恢复后看Message显示

For information about GNU Emacs and the GNU system, type C-h C-a.
Quit
scroll-bar-toolkit-scroll: End of buffer
Making completion list...
Quit
Loading d:/emacs_env/home/.emacs.d/recentf...done
Cleaning up the recentf list...
File v:/untitled/main.cpp removed from the recentf list
Cleaning up the recentf list...done (1 removed)
Mark set [2 times]
End of buffer
Mark set
Making completion list...
Mark set
Beginning of buffer
Mark set

我在 这里stackexchange 看到有说 which takes a lot of time when the Internet is bad.

有点像是这样的情况,samba关闭后,在访问挂载路径,资源管理器出现这样的进度条,也卡着,鼠标转圈圈,直到过很久弹出一个错误框,才不卡了。

当recentf中的远程文件被移除后,重新打开emacs,调用recentf就不会卡了。

长时间无影响是因为要等待网络回应超时,应该是 windows 这个超时时长比较长,按你的描述估计是大概 30s。因为对方不会主动回复,你只能等超时。

linux 这面你取消挂载就直接目录不存在,就会清理掉。这个可能和 windows 处理盘符的逻辑有关。现在你是在缓存里有个目录,所以访问目录 windows 可能尝试去连接。重启后检测到这个盘符不存在了,可能直接就清掉了。

嗯,应该是系统的原因,只能把recentf的清理关掉,关掉后就不会卡住了。