From: Colin Baxter <m43cap@yandex.com>
To: help-gnu-emacs@gnu.org
Subject: multi-line highlighting
Date: Sun, 28 Feb 2021 10:01:50 +0000 [thread overview]
Message-ID: <87lfb8bje9.fsf@yandex.com> (raw)
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.
next reply other threads:[~2021-02-28 10:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-28 10:01 Colin Baxter [this message]
2021-02-28 10:13 ` multi-line highlighting Colin Baxter
2021-02-28 12:34 ` Colin Baxter
2021-02-28 16:00 ` Stefan Monnier
2021-02-28 17:57 ` Colin Baxter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87lfb8bje9.fsf@yandex.com \
--to=m43cap@yandex.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.