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

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

Colourising tex keywords


From: fatiparty
Subject: Colourising tex keywords
Date: Mon, 10 Jan 2022 15:37:59 +0100 (CET)

Have constructed a set of tex symbols stored in (defvar texcom-colour

I want to highlight tex commands such as \alpha using colour (using 
texcom-colour
for instance).  Although the beginning \ should not be highlighted.  But I am 
failing 
miserably to implement this.

(defface texcom-colour
  '( (default :inherit bold)
     ( ((class color) (background light)) :foreground "#00FF00" )
     ( ((class color) (background dark))  :foreground "#00FF00" )
     (t :inherit font-lock-builtin-face) )
  "User defined colour typeface for tex command keywords.")

(defface texcom-typeface
  '((t :inherit font-lock-keyword-face))
   "Colour typeface for tex command keywords.")

(defconst texcom-cluster
  `(  (,(rx "\\" word-start (group (or "alpha" "beta" "chi" "delta"))  word-end)
     (1 'texcom-typeface))  ))

(defun texcom-typeface-enable ()
  "Sets the highlight colour for tex commands."
  (font-lock-add-keywords nil texcom-cluster t)
  (font-lock-flush))

(defun texcom-typeface-disable ()
  "Clears the highlight colour for tex commands."
  (font-lock-remove-keywords nil texcom-cluster)
  (font-lock-flush))





reply via email to

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