当我执行 Cx Cf TAB 时,如何防止 Emacs 显示所有我不感兴趣的文件(例如 ~ 备份文件、.pyc 文件或 .orig 文件)?
它在一方面工作:如果我知道我要打开的文件以 foo 开头,并且我输入 foo TAB 那么迷你缓冲区会正确地自动完成一直到 foo .py。它正确地忽略了 foo~ 和 foo.pyc,因为 ~ 和 .pyc 都在 完成忽略扩展。如果我真的想通过输入自己的所有字母,它也可以正确地让我打开任一被忽略的文件。
但是,如果我只是按 TAB 来调出完成列表缓冲区,则该列表包含扩展名为 completion-ignored-extensions 的文件,这使得查找起来非常困难我在寻找什么。
显然,忽略无趣文件的代码已经存在并且正在运行。如何让完成列表缓冲区尊重完成忽略扩展?
(顺便说一句,我可以让 dired 表现出类似的行为吗?)
How do I prevent Emacs from showing me all the files I'm not interested in (such as ~ backup files, .pyc files, or .orig files) when I: C-x C-f TAB ?
It is working in one respect: if I know the file I want to open begins with foo and I type foo TAB then the mini-buffer correctly autocompletes all the way to foo.py. It correctly ignored foo~ and foo.pyc, because both ~ and .pyc are in completion-ignored-extensions. It also correctly lets me open either ignored file if I really want to by typing in all the letters my self.
However, if I just hit TAB to to bring up the completion list buffer then that list includes files with extensions in completion-ignored-extensions, which makes it very difficult to find what I'm looking for.
Clearly the code to ignore uninteresting files is there and working. How do I get the completion list buffer to respect completion-ignored-extensions?
(by-the-by, can I make dired behave similarly?)
发布评论
评论(4)
这条建议会过滤掉
'completion-ignored-extensions
中列出的扩展名的文件:注意:这不会影响
dired
。对于
dired
问题,请将其添加到您的 .emacs 中阅读 dired-x 的文档 了解那里有什么可用的。
This piece of advice filters out files with extensions listed in
'completion-ignored-extensions
:Note: This doesn't affect
dired
.For the
dired
issue, add this to your .emacsRead the documentation for dired-x to get an idea of what's available there.
我建议使用 ido-mode 来忽略文件;它默认随 Emacs 一起提供,并添加了许多其他有用的增强功能,您很快就会喜欢上这些功能。 这篇掌握 Emacs 博文中的“无知是福”部分介绍了如何忽略文件、目录和缓冲区:
ido-ignore-buffers
获取要在 Cx b 中忽略的缓冲区列表ido-ignore-directories
获取 Cx d 和 Cx Cf 中要忽略的目录列表ido-ignore-files
获取 中要忽略的文件列表Cx CfI would recommend using ido-mode to ignore files; it comes with Emacs by default and adds many other useful enhancements that you'll quickly learn to love. The Ignorance is Bliss section from this Mastering Emacs blog post covers how to ignore files, directories, and buffers:
ido-ignore-buffers
Takes a list of buffers to ignore in C-x bido-ignore-directories
Takes a list of directories to ignore in C-x d and C-x C-fido-ignore-files
Takes a list of files to ignore in C-x C-fIcicles 的作用默认情况下你期望的。它始终遵循
completion-ignored-extensions
进行文件名补全,包括缓冲区*Completions*
。您可以随时通过在迷你缓冲区中点击 C-. 来打开/关闭此忽略功能。此外,如果您使用库
completion-ignored-build.el
由 Kevin Ryde 编写,然后 Icicles 自动利用该库对忽略的文件扩展名的动态调整。 (只需加载
completion-ignored-build.el
——不要启用其次要模式或建议。)Icicles does what you expect by default. It always respects
completion-ignored-extensions
for file-name completion, including for buffer*Completions*
. And you can toggle this ignoring on/off at anytime, by hitting C-. in the minibuffer.In addition, if you use library
completion-ignored-build.el
by Kevin Ryde, then Icicles automatically takes advantage of that library's dynamic adjustment of ignored file extensions. (Just loadcompletion-ignored-build.el
-- do not enable its minor mode or advice.)恐怕我不知道完成的答案。我认为这是设计使然 - 当您知道要查找的名称时,您可能不需要备份文件等。但当您不知道时,最好拥有所有文件的列表。
但是,对于 dired,您可以在启动时加载 'dired-x' 包(在 .emacs 中),这提供了 dired-omit-mode:
您可以使用 'Mxcustomize-variabledired-omit-files'设置要忽略的实际模式。然后,当您处于拨号模式时,您可以使用 MO(字母,而不是数字)来打开和关闭“省略”。
I don't know of an answer for completion, I'm afraid. I think this is by design - when you know the name you're looking for, you probably don't want e.g. the backup file. But when you don't know, it's probably better to have a list of all of the files.
However, for dired, you can load the 'dired-x' package on startup (in your .emacs), and this provides dired-omit-mode:
You can use 'M-x customize-variable<RET>dired-omit-files' to set the actual patterns to ignore. Then when you are in dired mode you can use M-O (the letter, not the number) to toggle 'omission' on and off.