[英]How to clear the Emacs buffer history?
When I press Cx b
( ido-switch-buffer
) I get a lot of buffers that I don't want to see. 当我按下
Cx b
( ido-switch-buffer
)时,我得到了很多我不想看到的缓冲区。 I'd like to clear the buffer history. 我想清除缓冲区历史记录。
I tried evaluating this expression (using Mx eval-buffer
): 我尝试评估这个表达式(使用
Mx eval-buffer
):
(setq ido-buffer-history '())
And it took effect; 它生效了; I can tell because I looked at the variable with
Ch v ido-buffer-history
. 我可以说,因为我用
Ch v ido-buffer-history
查看了变量。 However, the change did not get reflected in the minibuffer when I press Cx b
. 但是,当我按下
Cx b
时,这个改变没有反映在迷你缓冲器中。
What else should I do? 我还该怎么办? Are there other variables I should be clearing?
还有其他变量我应该清算吗?
UPDATE : The 'extra' buffers that I'm seeing are not active. 更新 :我看到的'额外'缓冲区不活跃。 Interestingly,
Cx Cb
( ido-fallback-command
) shows exactly what I would expect. 有趣的是,
Cx Cb
( ido-fallback-command
)正好显示了我的期望。 It is the buffer history that I'm interested in. (See the buffer-name-history
and ido-buffer-history
variables for more context.) 这是我感兴趣的缓冲区历史记录。(有关更多上下文,请参阅
buffer-name-history
和ido-buffer-history
变量。)
Note: Perhaps it will help to mention that I'm using the emacs-starter-kit which has ido-ubiquitous
installed. 注意:也许有必要提一下,我正在使用安装了
ido-ubiquitous
的emacs-starter-kit。
Add the following to your init.el: (setq ido-use-virtual-buffers nil)
将以下内容添加到init.el :(
(setq ido-use-virtual-buffers nil)
For posterity: 后人:
Those are all the active buffers in your session. 这些都是会话中的所有活动缓冲区。 You can clean them with the following commands:
您可以使用以下命令清除它们:
Mx clean-buffer-list
will close any clean buffers you haven't used in a while Mx clean-buffer-list
将关闭你暂时没有使用的所有干净缓冲区 Mx kill-some-buffers
will visit each buffer and ask if you want to close it Mx kill-some-buffers
将访问每个缓冲区并询问您是否要关闭它 Mx kill-matching-buffers
will prompt for a regex over buffer names, which you can just leave blank Mx kill-matching-buffers
将提示缓冲区名称的正则表达式,您可以将其留空 Edit: There's also the boring old buffer menu you get with Cx Cb
. 编辑:你还可以使用
Cx Cb
获得无聊的旧缓冲区菜单。 In this menu, you can hold d
until it marks each buffer for deletion, then press x
to commit. 在此菜单中,您可以按住
d
直到它标记每个缓冲区以进行删除,然后按x
进行提交。
Thanks to Chris, I learned about ido's virtual buffers. 感谢Chris,我了解了ido的虚拟缓冲区。 I don't want to disable
ido-use-virtual-buffers
altogether. 我不想完全禁用
ido-use-virtual-buffers
。 I want to clear the history as needed; 我想根据需要清除历史; these commands accomplish that goal:
这些命令实现了这个目标:
(setq ido-virtual-buffers '())
(setq recentf-list '())
(Note that clearing ido-virtual-buffers
was not sufficient -- recentf-list
also must be cleared.) (注意,清除
ido-virtual-buffers
还不够 - 还必须清除recentf-list
。)
I found this entry on emacswiki. 我在emacswiki上找到了这个条目。
The variable that stores the buffer history you are referring to is buffer-name-history
存储您引用的缓冲区历史记录的变量是
buffer-name-history
If you run Mx describe-variable RET buffer-name-history RET
you will see all of the dead buffers that no longer really exist. 如果运行
Mx describe-variable RET buffer-name-history RET
您将看到所有不再存在的死缓冲区。 The wiki recommends creating a hook that removes the buffer name from the list whenever you kill a buffer. wiki建议创建一个钩子,每当你杀死一个缓冲区时,该钩子就会从列表中删除缓冲区名称。
I just did: Mx eval-expression RET (setq buffer-name-history '()) RET
我刚刚做了:
Mx eval-expression RET (setq buffer-name-history '()) RET
This seems to have worked. 这似乎有效。 The next time I ran Cx b I only cycled-through my real buffers.
下次我运行Cx b时,我只循环通过我的真实缓冲区。
That said, setting the variable to nil seems to completely disable the functionality (the variable doesn't seem to be re-populated once I open more buffers). 也就是说,将变量设置为nil似乎完全禁用了功能(一旦打开更多缓冲区,变量似乎不会重新填充)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.