help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

multi-line highlighting


From: Colin Baxter
Subject: multi-line highlighting
Date: Sun, 28 Feb 2021 10:01:50 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)

Hello,

I have in an org-mode file a need to color the face of the string
between 'Alpha:' and a period. To achieve this I have

#+begin_src elisp
(add-hook 'org-mode-hook (lambda ()
   (font-lock-add-keywords nil
     '(("\\(Alpha:\\)\\([^\n\r\t]+\\)\\(.\\)"
      (1 font-lock-builtin-face) ;; Face for 'Alpha:'.
      (2 font-lock-doc-face) ;; Subsequent face)))))
#+end_src

This works well. 'Alpha:' is in font-lock-builtin-face and the rest of
the line until the period is in font-lock-doc-face. Occasionally,
unfortunately, the line runs over to a "new line" - and of course the
face locking 2 is lost on the new line.

How can I maintain the font locking 2 for two or maybe three lines? I
have tried inserting a '\n' in the regexp and a

#+begin_src elisp
eval: (set (make-local-variable 'font-lock-multiline) t)
#+end_src

as a local variable, but to no avail. I have searched online, but all
the examples I've found are based on adding keywords, which is not what
I want. I'm probably overlooking something simple.

I would be grateful for pointers as to where to look.

Best wishes,

Colin Baxter.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]