2

I am trying to replicate http://endlessparentheses.com/improving-latex-equations-with-font-lock.html with no success, I get a "defface for ‘endless/unimportant-latex-face’ fails to specify containing group" error when I compile my init.el and it does nothing nevertheless.

I cite here the elisp code from http://endlessparentheses.com/improving-latex-equations-with-font-lock.html for reconstruction:

(defface endless/unimportant-latex-face
  '((t :height 0.7
       :inherit font-lock-comment-face))
  "Face used on less relevant math commands.")

(font-lock-add-keywords
 'latex-mode
 `((,(rx (or (and "\\" (or (any ",.!;")
                           (and (or "left" "right"
                                    "big" "Big")
                                symbol-end)))
             (any "_^")))
    0 'endless/unimportant-latex-face prepend))
 'end)
3
  • You don't show what you tried, so the question is unclear (useless for anyone other than you).
    – Drew
    Commented Jan 21, 2018 at 0:26
  • I just tried copying and pasting that. I don't get the sintax that the author used :( Commented Jan 21, 2018 at 6:31
  • That's not a recipe. Copying and pasting exactly what, and where? Starting with emacs -Q (no init file)?
    – Drew
    Commented Jan 21, 2018 at 15:36

2 Answers 2

3

The error message is quite descriptive. You are missing the containing customization group in defface.

The following code is working with GNU Emacs 25.1.50.2 (i686-pc-linux-gnu, GTK+ Version 3.10.8) of 2016-04-25 and auctex-11.

Note, I have just added :group 'LaTeX-math in defface but I copied the full code here to simplify copy-paste.

(defface endless/unimportant-latex-face
  '((t :height 0.7
       :inherit font-lock-comment-face))
  "Face used on less relevant math commands."
  :group 'LaTeX-math)

(font-lock-add-keywords
 'latex-mode
 `((,(rx (or (and "\\" (or (any ",.!;")
                           (and (or "left" "right"
                                    "big" "Big")
                                symbol-end)))
             (any "_^")))
    0 'endless/unimportant-latex-face prepend))
 'end)
1
  • Thanks, this worked, I was addind random groups with no success Commented Jan 21, 2018 at 16:33
2

Since you're using AUCTeX, you can customize font-latex-user-keyword-classes to achieve the effect you're looking for. With this code:

(defface endless/unimportant-latex-face
  '((t :height 0.7
       :inherit font-lock-comment-face))
  "Face used on less relevant math commands.")

(setq font-latex-user-keyword-classes
      '(("mathunimportant"
         ("left" "right" "big" "Big" "!")
         endless/unimportant-latex-face
         noarg)))

I get this result:

enter image description here

Check the documentation for details.

2
  • Any notable difference from the answer from Tobias? besides it is more simplified. Commented Jan 28, 2018 at 16:15
  • @k76u4vkweek547v7 - font-latex.el is the official interface of AUCTeX to font-lock, so chances are high that things like disabling fontification, using themes etc. work better if you use it. Besides, simplicity is always a plus. Commented Feb 3, 2018 at 21:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.