Emacs 协作缓冲区以错误的模式打开
我正在使用 Emacs 和 Rudel 与远程程序员协作。 Rudel 有一个已发布缓冲区的概念。当我的合作伙伴发布缓冲区时,我可以订阅它,并且我们可以同时编辑它。
我的问题是,当他发布带有 *.py 扩展名的 Python 文件并且我订阅它时,我的缓冲区不会自动设置为 python 模式(它处于基本模式)。我怎样才能得到它,以便缓冲区以正确的语言模式打开?
I am using Emacs and Rudel to collaborate with a remote programmer. Rudel has a concept of published buffers. When my partner publishes a buffer, I can subscribe to it and the we can both edit it simultaneously.
My problem is that when he publishes a Python file with a *.py extension and I subscribe to it, my buffer is not set to python-mode automatically (it is in fundamental mode). How can I get it so that the buffer opens with the correct language mode?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不太了解 Rudel,无法提供 100% 的解决方案,但您想要做的是这样的:
仅,您需要替换
...get-name-from-document...< /code> 代码部分,其中包含计算结果为您想要的文件名的内容,例如,如果缓冲区名为
myfile.py
,那么您可以将其更改为(buffer-名称)
。但是,如果缓冲区的名称很奇怪,也许您需要从文档对象中提取名称(Rudel 内部使用文档对象来表示您正在共享的内容)。因此,如果(buffer-name)
不起作用,您可以尝试(rudel-suggested-buffer-name document)
。即尝试上面的代码,但使用以下行之一:
并且
set-auto-mode
将使用buffer-file-name
的值来确定主要模式,使用 < a href="http://www.gnu.org/s/emacs/manual/html_node/elisp/Auto-Major-Mode.html" rel="nofollow noreferrer">一般 Emacs 机制。I don't know Rudel well enough to give a 100% solution, but what you want to do is something like this:
Only, you need to replace the
...get-name-from-document...
portion of the code with something that evaluates to the file name that you want, for example, if the buffer is namedmyfile.py
, then you can change that to(buffer-name)
. But, if the buffers get odd names, perhaps you need to extract the name from the document object (Rudel internally uses a document object to represent the thing you are sharing). So, if(buffer-name)
doesn't work, you can try(rudel-suggested-buffer-name document)
.i.e. try the above code but using one of these lines:
and
The
set-auto-mode
will use value ofbuffer-file-name
to determine the major mode using the general Emacs mechanisms.我对 rudel 的工作原理一无所知。但是,您是否尝试过在文本文件中明确设置模式?尝试将类似这样的内容添加到文件的第一行:
在文件中首先添加这样的行将导致 emacs 忽略文件的扩展名并以给定模式打开。
I know absolutely nothing about how rudel works. However, have you tried explicitly setting the mode in the text file? Try adding something like this to the first line of the file:
Putting a line like this first in the file will cause emacs to ignore the file's extension and open in the given mode.