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 04:39:06 +0100

Does anybody know how to use "font-lock-add-keywords" to
highlight keywords?  Have tried as follows.

(defface texcmd-colour
  '( (default :inherit bold)
     ( ((class color) (min-colors 88) (background light))
       :foreground "#FF0000" )
     ( ((class color) (min-colors 88) (background dark))
       :foreground "#FF0000" )
     (t :inherit font-lock-builtin-face) )
  "Typeface for sutting colour to tex commands.")

(defvar-local stdhl 1
  "Uses standard highlighting for keywords when set to 1.
When stdhl is 0, the leading backslash is also highlighted.")

(defconst comseq-list
  `(
    ;; Greek.
    (,(rx "\\" word-start (group (or "alpha" "beta" "chi" "delta"
          "Delta" "epsilon" "varepsilon" "eta" "gamma" "Gamma" "iota"
          "kappa" "lambda" "Lambda" "mu" "nu" "omega" "Omega" "phi"
          "varphi" "Phi" "pi" "varpi" "Pi" "psi" "Psi" "rho" "varrho"
          "sigma" "varsigma" "Sigma" "tau" "theta" "vartheta" "Theta"
          "upsilon" "Upsilon" "xi" "Xi" "zeta")) word-end)
     (stdhl 'colour-texcmd))
"Fontification for letters and symbols.")

(font-lock-add-keywords nil comseq-list t)


> Sent: Sunday, February 14, 2021 at 1:46 PM
> From: michael-franzese@gmx.com
> To: "Help Gnu Emacs" <help-gnu-emacs@gnu.org>
> Subject: Passing values through a variable
>
> I want to change the expression (1 'texcmd-colour) so that
> the value 1 can be set through a variable (e.g. stdhl).
>
> Can I just do
>
> (defvar-local stdhl 1
>   "Uses standard highlighting for keywords when set to 1.
> When stdhl is 0, the leading backslash is also highlighted.")
>
> (defconst tex-keywords
>   `(
>     ;; Greek.  Use (0 'texcmd-colour) to highlight the leading "\".
>     (,(rx "\\" word-start (group (or "alpha" "beta" "chi" "delta"
>           "Delta" "epsilon" "varepsilon" "eta" "gamma" "Gamma" "iota"
>           "kappa" "lambda" "Lambda" "mu" "nu" "omega" "Omega" "phi"
>           "varphi" "Phi" "pi" "varpi" "Pi" "psi" "Psi" "rho" "varrho"
>           "sigma" "varsigma" "Sigma" "tau" "theta" "vartheta" "Theta"
>           "upsilon" "Upsilon" "xi" "Xi" "zeta")) word-end)
>      (stdhl 'texcmd-colour))
>
> (font-lock-add-keywords nil comseq-crucible t)
>
>
> Below is the original code
>
> (defconst tex-keywords
>   `(
>     ;; Greek.  Use (0 'colour-tex-cruc) to highlight the leading "\".
>     (,(rx "\\" word-start (group (or "alpha" "beta" "chi" "delta"
>           "Delta" "epsilon" "varepsilon" "eta" "gamma" "Gamma" "iota"
>           "kappa" "lambda" "Lambda" "mu" "nu" "omega" "Omega" "phi"
>           "varphi" "Phi" "pi" "varpi" "Pi" "psi" "Psi" "rho" "varrho"
>           "sigma" "varsigma" "Sigma" "tau" "theta" "vartheta" "Theta"
>           "upsilon" "Upsilon" "xi" "Xi" "zeta")) word-end)
>      (1 'texcmd-colour))
>
> (font-lock-add-keywords nil tex-keywords t)
>
>



reply via email to

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