如何让emacs支持git的文本着色?

4
在我的当前开发环境中,当我以交互模式(--interactive)运行git rebase命令时,它经常会打开vi并提示我更改某些文本文件,以此告诉它如何处理rebase。 vi以一种似乎由git确定的方式突出显示这些文件。(像'pick'、'squash'等在这种情况下对git有特殊含义的关键字会用不同的颜色突出显示。)
我更喜欢使用emacs而不是vi,所以我将git配置为打开emacs(git config --global core.editor "emacs -nw")。不幸的是,与vi不同,emacs无法突出显示由git提供的文件。我该怎么办?
编辑:
如果您不熟悉交互式git rebase生成的文件,请参考以下示例:
pick f218f23 A major overhaul of the cucumber integration tests
pick 601d8f4 A bunch of minor bug fixes and refactoring
pick 1adc507 Adding and updating documentation for various files.

# Rebase ff8cb22..1adc507 onto ff8cb22
#
# Commands:
#  p, pick = use commit
#  r, reword = use commit, but edit the commit message
#  e, edit = use commit, but stop for amending
#  s, squash = use commit, but meld into previous commit
#  f, fixup = like "squash", but discard this commit's log message
#  x <cmd>, exec <cmd> = Run a shell command <cmd>, and stop if it fails
#
# If you remove a line here THAT COMMIT WILL BE LOST.
# However, if you remove everything, the rebase will be aborted.
c:\my_project\.git\rebase-merge\git-rebase-todo [unix] (15:50 26/10/2012)

在这个例子中,关键字'pick'、修订哈希值、提交描述和注释都将以不同的颜色突出显示。
2个回答

3

要么已经有相关模式存在(例如作为magit的一部分),否则就需要有人为此编写一个模式(如果您展示一些样本内容和文件名类型的提示,这应该是相当容易的)。


啊,那么这实际上是 VI 中内置的功能?这很有道理。无论如何,我需要研究一下 magit。我还添加了一个 git 交互式变基生成的文件示例。 - Ajedi32

0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接