《有关elisp括号配对的Emacs Mode》里,告诉了大家Emacs提供的show-paren-mode。这个mode应该能满足大家日常coding的需要了,不过,这个mode有一个缺点,就是,当你的光标在()中间的时候,两边的括弧不会有高亮显示。

在coding的时候,不能快速准确地找到离当前光标最近的()对,是件让人很辛苦的事。

现在再给大家介绍一个highlight-parentheses mode,这个mode能识别出离光标最近的那对parentheses。这些parentheses可以是()、[]、{}、《》中的任意一种。只要你把光标停留在一对parentheses中,这对parentheses就会自动高亮显示。

只要把highlight-parentheses.el扔到你的path里去,然后在.emacs里加入这段代码:

(add-to-list ‘load-path “/path/to/highlight-parentheses”)
(require ‘highlight-parentheses)
(highlight-parentheses-mode 1)

这样你就可以让highlight-parentheses-mode随着你的Emacs开启而激活了。当然,你也可以用命令M-x highlight-parentheses-mode来手动开启与关闭highlight-parentheses mode

这样,一切有关parentheses高亮的东西,是不是完美了?