I want to modify the highlighting of my JS files, so that every line starting with
LOG gets shown in a different color.1
I wrote the following
(require 'font-core) (font-lock-mode 1) (defface mg-js-pseudo-face '((t (:background "White"))) "..." :group 'faces) (defvar mg-js-pseudo-regex "^[ \t]*\\(LOG .*\\)") (defun mg-js-pseudo-hook () (font-lock-add-keywords nil `( (,mg-js-pseudo-regex 1 'mg-js-pseudo-face t)) ;;; <----- here )) (add-hook 'js-mode-hook 'mg-js-pseudo-hook)
It works well when highlighting the whole line (using
0 instead of
1 in the marked line). It does nothing at all, when used as is. Why?
1It's invalid JS, I know. It gets preprocessed by the server to
console.log with some added information.