3

I like to use highlighting when working with emacs. But I don't like some of the default settings. I recently installed emacs 24.4 on my iMac. I really don't like all the highlighting of math expressions such as

$5$

I used to do something like

(fset 'tex-font-lock-syntactice-face-function 'ignore)

or

(fset 'tex-math-face 'ignore)

but that no longer works.

How can I disable highlight for math expressions but keep most everything else?

  • I use a custom version of tex-mode.el and I commented out (,(concat "\\$\\$?\\(?:[^$\\{}]\\|\\\\.\\|{" (funcall inbraces-re (concat "{" (funcall inbraces-re "{[^}]*}") "*}")) "*}\\)+\\$?\\$") (0 tex-math-face)) in my own personal custom version because I don't use math. If you don't want to comment out the source, then you might be interested in coping the current setting of tex-font-lock-keywords-1, and commenting out that section and setting the new portion -- e.g., (setq tex-font-lock-keywords-1 [EVERYTHING EXCEPT WHAT SHOULD BE STRICKEN]) If you are using AUCTeX, I don't know. – lawlist Feb 27 '15 at 6:42
  • It is lines 503 to 507 in the public release of Emacs 24 within tex-mode.el Most people treat the source code as sacred and use things like (setq . . . instead of touching the source. I like to create my own libraries for things I use every day (like writing documents for business, etc.), starting by copying the source code, and then I modify the daylights out of the source. – lawlist Feb 27 '15 at 6:54
  • Are you using AUCTeX or the basic tex-mode? (To see that: press C-h m and see whether the mode is defined in tex-site (AUCTeX) or tex-mode (basic).) Do you want to turn off highlighting just for $…$ or for everything such as math environments? – Gilles 'SO- stop being evil' May 27 '15 at 12:08
1

You can change the highlighting using set-face-foreground (or more generally set-face-attribute. $..$ seems to be highlighted with font-latex-math-face, so to set the foreground to whatever the default is we can use (set-face-foreground 'font-latex-math-face nil). It's still "highlighted" but it will look identical to the surrounding text.

1

In the following I assume that you are using auctex.

Remove the syntax descriptor for ?$ from font-latex-syntax-alist after loading "font-latex" to avoid fontification of inline formulas delimited by $.

(eval-when '(compile)
  (require 'cl))

(eval-after-load "font-latex"
  '(setq font-latex-syntax-alist (cl-delete-if (lambda (pair) (eq (car pair) ?$)) font-latex-syntax-alist)))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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