Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/mercurial/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
有没有emacs模式,在编辑my.hgrc文件时会显示语法hilighting?_Emacs_Mercurial - Fatal编程技术网

有没有emacs模式,在编辑my.hgrc文件时会显示语法hilighting?

有没有emacs模式,在编辑my.hgrc文件时会显示语法hilighting?,emacs,mercurial,Emacs,Mercurial,Emacs不识别扩展名.hgrc,所以它使用基本模式,所有文本都是黑色的,包括注释。是否有一个好的模式用于编辑.hgrc?当我编辑.hgrc时,如何配置emacs以自动使用该模式 迄今为止从答案中学到的知识: conf模式是我想要的模式,有多种方法可以配置emacs来使用它进行编辑 (add-to-list 'auto-mode-alist '("/\\.[^/]*rc" . conf-mode) t) 我的.emacs.el,所以 我的emacs以Conf[Unix]模式打开所有RC文件(包

Emacs不识别扩展名.hgrc,所以它使用基本模式,所有文本都是黑色的,包括注释。是否有一个好的模式用于编辑.hgrc?当我编辑.hgrc时,如何配置emacs以自动使用该模式

迄今为止从答案中学到的知识:

conf模式
是我想要的模式,有多种方法可以配置emacs来使用它进行编辑

(add-to-list 'auto-mode-alist '("/\\.[^/]*rc" . conf-mode) t)
我的
.emacs.el
,所以 我的emacs以
Conf[Unix]
模式打开所有RC文件(包括
.hgrc


第三个参数为的原因是运行控制文件的默认模式是,除非先前的设置覆盖它。

访问
。hgrc
,使用
M-x Conf mode
切换到Conf mode,然后键入
M-x add file本地变量prop line RET mode RET Conf mode

这会在
.hgrc
的开头添加一条特殊注释,告知Emacs对此文件使用
conf模式

# -*- mode: conf; -*-

[extensions]
hgext.color =
# …

特别的评论行是有效的。我只是键入它,保存,然后做了
m-x还原缓冲区
。此解决方案适用于
.hgrc
,因为它从未签入共享repo,因为在共享repo中,该行会困扰非emacs用户。有趣的是,添加注释行的命令比键入注释行更多的是击键。哦,emacs:)@Digoro对我来说,由于SMex和IDO的模糊补全,击键只是
M-x aflp-RET M-RET
,而且在频繁使用时,您会将该命令绑定到一个键。不管怎么说,只要把这行字打出来就没什么错了。我之所以使用这个命令,是因为它是明确的,并且避免了任何类型之类的混淆。