new
这个关键字可以用其他的颜色高亮而不是白色,然后在代码中的数字也可以用其他颜色高亮而不是白色自己折腾了一个elisp配置
(add-hook 'after-change-major-mode-hook
'(lambda () (font-lock-add-keywords
nil
'(("[^a-zA-Z]\\([0-9]+\\)[^a-zA-Z]"
1 font-lock-warning-face prepend)))))
但是发现一个问题就是,普通代码中的数字的确是用非白色高亮了,可是字符串中的数字也被高亮了,我想重新写一个判断是否为字符串的hook去覆盖,但是折腾了半天也不对,new关键字的高亮也是一样,在代码中高亮了,字符串和注释中也是被高亮了,反而不好看了
而且还有一个问题就是,上面这个简陋的正则只能让
foo1
显示正常
如果是
foo11
foo111
之类的变量中连续超过两个数字的话,变量中得数字也会被不同颜色高亮了
正则不是很精通,请大大们指点一下,该装什么mode或者写个啥hook可以满足我地需求
阿神2017-04-22 08:58:34
It doesn’t have to be so troublesome. I won’t explain the specific technology. In addition to modifying the color theme, I use the following footnote method. The following is to highlight the three strings l1 l2 l3:
#+STARTUP: content
# Local Variables:
# eval: (highlight-phrase "\bl1\b" (quote hi-pink))
# eval: (highlight-phrase "\bl2\b" (quote hi-yellow))
# eval: (highlight-phrase "\bl3\b" (quote hi-green))
# End:
Theoretically, it can be associated with the mode by hooking it into a mode-hook. For more details, you can search related.