在emacs中着色文本片段(Colorize snippets of text in emacs)
假设我想强调一些单词,所以我想将这几个单词的颜色改为绿色。
有没有一种简单的方法在emacs中执行此操作?
谢谢。
Suppose I have a few words I would like to highlight, so I want to change the color of those few words only to, say, green.
Is there an easy way to do this in emacs?
Thank you.
最满意答案
这就是我所做的,使用font-lock-add-keywords 。 我想在我的代码中突出显示TODO: , HACK:和FIXME:这两个词。
(defface todo-face '((t ())) "Face for highlighting comments like TODO: and HACK:") (set-face-background 'todo-face cyan-name) ;; Add keywords we want highlighted (defun add-todo-to-current-mode () (font-lock-add-keywords nil '(("\\(TODO\\|HACK\\|FIXME\\):" 1 'todo-face prepend)) t))This is what I've done, using font-lock-add-keywords. I wanted to highlight the words TODO:, HACK:, and FIXME: in my code.
(defface todo-face '((t ())) "Face for highlighting comments like TODO: and HACK:") (set-face-background 'todo-face cyan-name) ;; Add keywords we want highlighted (defun add-todo-to-current-mode () (font-lock-add-keywords nil '(("\\(TODO\\|HACK\\|FIXME\\):" 1 'todo-face prepend)) t))更多推荐
发布评论