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: michael-franzese
Subject: Re: Passing values through a variable
Date: Sun, 14 Feb 2021 05:14:12 +0100

You have used

("_{\\([[:alnum:]]*\\)}" 1 font-lock-function-name-face)

How can I pass the "1" using a variable, rather than hardwiring it?


> Sent: Sunday, February 14, 2021 at 3:56 PM
> From: "Emanuel Berg via Users list for the GNU Emacs text editor" 
> <help-gnu-emacs@gnu.org>
> To: help-gnu-emacs@gnu.org
> Subject: Re: Passing values through a variable
>
> 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]