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

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

Re: Passing values through a variable


From: Emanuel Berg
Subject: Re: Passing values through a variable
Date: Sun, 14 Feb 2021 04:56:47 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

michael-franzese wrote:

> Does anybody know how to use "font-lock-add-keywords" to
> highlight keywords?

Oh, no, not again :)

But wait... if it happens again and again, _I_ don't have to
do it again!

"if anything can start anew, then everything must continue"

So yes, here is an example:

Note: The keywords don't have to be expressions BTW. They can
be single words. Then, instead of the index (1 in the example)
just add a dot, i.e. (word . face)

\alpha^{high}
\beta_{low}

(progn
  (font-lock-add-keywords
   'emacs-lisp-mode
   '(
     ("\\^{\\([[:alnum:]]*\\)}" 1 font-lock-builtin-face)
     ("_{\\([[:alnum:]]*\\)}"   1 font-lock-function-name-face)
     )
   t)
  (text-mode)
  (emacs-lisp-mode) )
;;                   ^ eval

You can see the result in this screenshot:

  https://dataswamp.org/~incal/figures/emacs/high-low.png

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




reply via email to

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