all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* multi-line highlighting
@ 2021-02-28 10:01 Colin Baxter
  2021-02-28 10:13 ` Colin Baxter
  2021-02-28 16:00 ` Stefan Monnier
  0 siblings, 2 replies; 5+ messages in thread
From: Colin Baxter @ 2021-02-28 10:01 UTC (permalink / raw)
  To: help-gnu-emacs

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.




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-02-28 17:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-28 10:01 multi-line highlighting Colin Baxter
2021-02-28 10:13 ` Colin Baxter
2021-02-28 12:34   ` Colin Baxter
2021-02-28 16:00 ` Stefan Monnier
2021-02-28 17:57   ` Colin Baxter

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.