I'd like to highlight code with various faces in a minor mode.
Here's a screenshot that's close to what I want:
One thing that I'm missing is having the comment chars
font-lock-comment-face. The idea is to have comments that "belong"
to an outline highlighted as plain text, so it's easier to read. While
having regular comments with their usual less prominent face.
Here's the code that I used:
(setq-local font-lock-defaults '(python-font-lock-keywords nil nil nil nil (font-lock-syntactic-face-function . lpy-font-lock-syntactic-face-function))) (defun lpy-font-lock-syntactic-face-function (state) "Return syntactic face given STATE. Returns 'defalt face for comments that belong to an outline." (cond ((nth 3 state) (if (python-info-docstring-p state) font-lock-doc-face font-lock-string-face)) ((save-excursion (while (and (> (point) (point-min)) (progn (move-beginning-of-line 0) (eq (char-after) ?\#)))) (forward-line 1) (looking-at "#\\*+ ")) 'default) (t font-lock-comment-face)))
The thing is, I have no clue about the interface on which
font-lock-syntactic-face-function operates, other than it receives a
complex data structure
state, has different point state, and returns
Could someone explain this interface? Is there a better one perhaps?