Emacs:在不同目录中的同名缓冲区之间切换
我有两个同名但位于不同目录的文件:
apples/main.cpp
oranges/main.cpp
我通过 emacs apples/main.cpp Oranges/main.cpp
在一个 emacs 窗口中打开它们
当我使用 Cx b
要在这两个缓冲区之间切换,缓冲区名称为“main.cpp”和“main.cpp<2>”。我希望在切换缓冲区时能够看到这两个文件的完整路径,这样我就可以消除苹果和橙子版本之间的歧义。有办法做到这一点吗?
一种方法可能是修改生成 <2> 的任何代码。在第二个 main.cpp 之后,当 Emacs 检测到具有该名称的缓冲区已打开时。但是,我找不到如何执行此操作。
I have two files with the same name but in different directories:
apples/main.cpp
oranges/main.cpp
I open them in one emacs window via emacs apples/main.cpp oranges/main.cpp
When I use C-x b
to switch between these two buffers, the buffer names are "main.cpp" and "main.cpp<2>". I would love to be able to see the full path of these two files when switching buffers, so that I may disambiguate between the apples and the oranges version. Is there a way to do this?
One way could be to modify whatever code generates the <2> after the second main.cpp when Emacs detects that a buffer with that name is already open. However, I couldn't find how to do this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用 uniquify。我这样使用它:
Use uniquify. I use it like that:
扩展托马斯的答案。
除了 forward 之外,您还可以考虑 uniquify-buffer-name-style 的其他选项:
文件 /foo/bar/mumble/name 和 /baz/quux/mumble/name 将具有以下内容各种样式的缓冲区名称:
如果要删除冲突文件的公共目录后缀,请将下面的行添加到您的 emacs init 文件中。
(setq uniquify-strip-common-suffix t)
现在,如果您打开 /a1/b/c/d 和 /a2/b/c/d,缓冲区名称将显示
“d|a1”和“d|a2”而不是“d|a1/b/c”和“d|a2/b/c”。
Expanding on Tomasz's answer.
There are other options for uniquify-buffer-name-style, besides forward, that you may consider:
Files /foo/bar/mumble/name and /baz/quux/mumble/name would have the following buffer names in the various styles:
If you want to strip common directory suffixes of conflicting files, add the line below to your emacs init file.
(setq uniquify-strip-common-suffix t)
Now, if you open /a1/b/c/d and /a2/b/c/d, the buffer names will say
"d|a1" and "d|a2" instead of "d|a1/b/c" and "d|a2/b/c".
使用 lusty 浏览器。配置它:
Use lusty explorer. Configure it with: