Emacs font lock mode: provide a custom color instead of a face

筅森魡賤 提交于 2019-11-29 19:07:04

问题


On this page discussing font lock mode, an example is provided which highlights a custom pattern:

 (add-hook 'c-mode-hook
           (lambda ()
            (font-lock-add-keywords nil
             '(("\\<\\(FIXME\\):" 1 font-lock-warning-face t)))))

Is there a way to provide a custom color instead of font-lock-warning-face and without defining a new custom face. I want to be able to write something like:

(font-lock-add-keywords nil '(("\\<\\(FIXME\\):" 1 "Blue" t)))

or an RGB color definition:

(font-lock-add-keywords nil '(("\\<\\(FIXME\\):" 1 "#F0F0F0" t)))

Using the double quotes doesn't work. Do you know what will make it work?


回答1:


(font-lock-add-keywords nil '(("\\<\\(FIXME\\):" 1 '(:foreground "blue") t)))
(font-lock-add-keywords nil '(("\\<\\(FIXME\\):" 1 '(:foreground "#F0F0F0") t)))

A full list of attributes is in the manual.



来源:https://stackoverflow.com/questions/6258455/emacs-font-lock-mode-provide-a-custom-color-instead-of-a-face

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!