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

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

Re: multi-line highlighting


From: Colin Baxter
Subject: Re: multi-line highlighting
Date: Sun, 28 Feb 2021 17:57:08 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

>>>>> Stefan Monnier <monnier@iro.umontreal.ca> writes:

    >> 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]+\\)\\(.\\)"
    >                                          ^^^ This is not the
    > regexp for a "period".

Yes, I discovered that fact.

I now have what I want working with this:

#+begin_src elisp
(add-hook 'org-mode-hook (lambda ()
   (font-lock-add-keywords nil
               '(("Alpha:\\|." . font-lock-warning-face)
                 ("Alpha:\\([^<]+?\\)." . (1 font-lock-constant-face))
                 ("Beta:\\|." . font-lock-doc-face)
                 ("Beta:\\([^<]+?\\)." .  (1 font-lock-comment-face))))))
#+end_src

My end marker is the FULLWIDTH FULL STOP character. It may not be the
most rigorous solution but it works.

    > Have you looked at the ELisp reference manual that comes with your
    > Emacs?  It has a section called "Font Lock Multiline".

Yes, I did.

Thanks.

Best wishes



reply via email to

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