[英]emacs major-mode define font-lock for line preceding regexp
I'm working on making a custom emacs major-mode, but I'm completely unfamiliar with lisp - so I'm struggling. 我正在制作自定义的emacs主模式,但是我完全不熟悉lisp-所以我很挣扎。 I'm trying to add a font lock such that a line of repeating '
=
' or ' -
' is highlighted, along with the line above it (so that I can use these as headings), ie 我正在尝试添加字体锁,以便突出显示重复的'
=
'或' -
'一行以及其上方的一行(以便我可以将其用作标题),即
This is a Colored Heading
=========================
this is a differently-colored sub-heading
-----------------------------------------
I've tried to set this up with: 我尝试通过以下方式进行设置:
(font-lock-add-keywords nil '(("\\(.*\n=\{3,\}\\)"
1 font-lock-warning-face prepend)))
but it isn't working. 但它不起作用。 I thought this meant:
我认为这意味着:
' .*
' any characters “
.*
”任何字符
' \\n
' followed by a newline '
\\n
'后跟换行符
' =\\{3,\\}
' followed by 3 or more '=' characters '
=\\{3,\\}
',后接3个或更多'='字符
Where am I going wrong? 我要去哪里错了?
"\\{"
and "\\}"
are treated as an escape sequence, which they're not. "\\{"
和"\\}"
被视为转义序列,不是。 You need to use "\\\\{"
and "\\\\}"
instead: 您需要使用
"\\\\{"
和"\\\\}"
代替:
(font-lock-add-keywords nil '(("\\(.*\n=\\{3,\\}\\)"
1 font-lock-warning-face prepend)))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.