gpt4 book ai didi

emacs - 告诉 ido 忽略所有星形缓冲区,除了一些

转载 作者:行者123 更新时间:2023-12-03 22:48:53 26 4
gpt4 key购买 nike

通常我想要 ido忽略所有非用户缓冲区,即所有以 * 开头的缓冲区.我使用以下设置实现了这一点:

(setq ido-ignore-buffers '("\\` " "^\*"))

但是,这在使用 shell 或解释器时会带来问题,例如 ielm ,其中交互缓冲区被命名为 *ielm* .显然,手动添加要忽略的所有缓冲区并不是一个真正的选择,因为加载了许多不同的 emacs 包后,列表可能会变得很长。我知道 C-aido 中禁用了忽略模式,然而,我不想打 C-a每次我切换到 ielm缓冲。

我的问题是:

Is there some variable which allows to specify buffers which ido should not ignore (although they match the normal ignore list)? Or is there some other approach for solving this?

最佳答案

ido-ignore-buffers的名单指向的变量不仅可以包含正则表达式,还可以包含函数(实际上是它们的任意组合)。很容易提供一个函数来过滤除*ielm* 之外的所有非用户缓冲区。 :

(defun ido-ignore-non-user-except-ielm (name)
"Ignore all non-user (a.k.a. *starred*) buffers except *ielm*."
(and (string-match "^\*" name)
(not (string= name "*ielm*"))))

(setq ido-ignore-buffers '("\\` " ido-ignore-non-user-except-ielm))

这是具有多个未忽略缓冲区名称的示例:

(setq my-unignored-buffers '("*ielm*" "*scratch*" "*foo*" "*bar*"))

(defun my-ido-ignore-func (name)
"Ignore all non-user (a.k.a. *starred*) buffers except those listed in `my-unignored-buffers'."
(and (string-match "^\*" name)
(not (member name my-unignored-buffers))))

(setq ido-ignore-buffers '("\\` " my-ido-ignore-func))

ido.el 的评论中可以找到一个使用忽略函数的有趣示例。源代码(我在每行的开头删除了 ;;):

(defun ido-ignore-c-mode (name)
"Ignore all c mode buffers -- example function for ido."
(with-current-buffer name
(derived-mode-p 'c-mode)))

基本上,一旦你有了缓冲区名称,你就可以做任何你想做的检查/忽略。

关于emacs - 告诉 ido 忽略所有星形缓冲区,除了一些,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20494400/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com