我在定义彼此不冲突的粗体和下划线组合时遇到了麻烦。一条下划线胜过部分粗体和下划线。关于如何区分它们,使它们不冲突,有什么想法吗?我想让每个LaTeX命令保持不同的颜色。
加粗下划线:{\bf\uline{insert-text}}
下划线:\uline{insert-text}
注意1:我不使用\underline,因为它不能正确地换行。
注2: insert-text的变量代码还应该允许我突出显示属于该变量代码的某些关键字。
注3:同样的问题可能会发生在单独使用粗体时:{\bf insert-text}
(font-lock-add-keywords 'latex-mode (list
(list (concat "\\(\{\\)\\(\\\\bf\\)\\(\\\\uline\\)\\(\{\\)\\(\\(.\\|\n\\)+?\\)\\(\}\\)\\(\}\\)")
'(1 lawlist-regular t)
'(2 lawlist-red t)
'(3 lawlist-blue t)
'(4 lawlist-regular t)
'(5 lawlist-bold-underline t)
'(7 lawlist-regular t)
'(8 lawlist-regular t))
(list (concat "\\(\\\\uline\\)\\(\{\\)\\(\\(.\\|\n\\)+?\\)\\(\}\\)")
'(1 lawlist-green t)
'(2 lawlist-regular t)
'(3 lawlist-underline t)
'(5 lawlist-regular t))
lawlist-keywords
))发布于 2013-05-21 20:16:04
条目出现的顺序(在某些情况下)将控制后续条目是否优于先前条目。这个示例中没有包括面的定义--还必须列出这些定义。
(defvar lawlist-keywords
(list (concat "\\b\\(?:"
(regexp-opt (list "FIXME" "TODO" "BUGS"))
"\\)\\b") 0 'lawlist-red t))
(font-lock-add-keywords 'latex-mode (list
(list (concat "\\(\{\\)\\(\\\\bf\\)\\(\\(.\\|\n\\)+?\\)\\(\}\\)")
'(1 lawlist-regular t)
'(2 lawlist-purple t)
'(3 lawlist-bold t)
'(5 lawlist-regular t))
(list (concat "\\(\\\\uline\\)\\(\{\\)\\(\\(.\\|\n\\)+?\\)\\(\}\\)")
'(1 lawlist-green t)
'(2 lawlist-regular t)
'(3 lawlist-underline t)
'(5 lawlist-regular t))
(list (concat "\\(\{\\)\\(\\\\bf\\)\\(\\\\uline\\)\\(\{\\)\\(\\(.\\|\n\\)+?\\)\\(\}\\)\\(\}\\)")
'(1 lawlist-regular t)
'(2 lawlist-red t)
'(3 lawlist-blue t)
'(4 lawlist-regular t)
'(5 lawlist-bold-underline t)
'(7 lawlist-regular t)
'(8 lawlist-regular t))
lawlist-keywords
))发布于 2013-05-21 21:39:24
在您的规则中,您已指定't‘作为您的规则中的'OVERRIDE’标志:
(1 lawlist-regular t)“t”的意思是替换现有的字体。
相反,请尝试:
(1 larlist-regular append)这会将新的字体添加到现有的。
来自Emacs变量font-lock-keywords的文档
匹配-突出显示应采用以下形式:
(SUBEXP FACENAME [覆盖LAXMATCH])
..。
OVERRIDE和LAXMATCH是标志。如果OVERRIDE为t,则可以覆盖现有字体。如果为keep,则仅突出显示尚未设置字体的部分。如果为prepend或append,则现有字体设置将与新字体设置合并,其中新字体设置或现有字体设置将分别优先。
https://stackoverflow.com/questions/16659455
复制相似问题