Source Syntax Emacs Auctex

I want to highlight the new command that I created in LaTeX:

\newcommand{\conceito}[3]{
  \subsection{#1} (Original: \textit{#2} #3).
}

I use this code as follows:

\conceito{Foo}{Bar}{Bla}

I followed the manual and put this code in mine ~/.emacs, but it didn't work:

(add-hook 'LaTeX-mode-hook
    (lambda ()
        (font-lock-add-keywords nil
          '((""\\<\\(\\conceito)\\>"" 1 font-lock-warning-face t)))))

What's wrong?

+5
source share
2 answers

EDIT: Deokhwan Kim initially pointed out that your regular expression contains two consecutive double quotes and that the closing bracket )must be escaped with double quotes:

(add-hook 'LaTeX-mode-hook
    (lambda ()
        (font-lock-add-keywords nil
          '(("\\<\\(\\conceito\\)\\>" 1 font-lock-warning-face t)))))

In addition to the points marked by Deokhwan Kim, there are also the following two questions:

  • You need four backslashes instead of two before the "hidden": \\\\conceito

  • \\< , LaTeX , \\< .

:

(add-hook 'LaTeX-mode-hook
    (lambda ()
        (font-lock-add-keywords nil
            '(("\\(\\\\conceito\\)\\>" 1 font-lock-warning-face t)))

EDIT: , Deokhwan Kim, , , . , :

'(("\\\\conceito\\>" 0 font-lock-warning-face t)))))

, , { "". , , , :

(add-hook 'LaTeX-mode-hook
    (lambda ()
        (font-lock-add-keywords nil
            '(("\\(\\\\conceito\\)\\s-*{" 1 font-lock-warning-face t)))

, {, "" ( ), \\>.

, M-x re-builder : , , .

+6

GNU AUCTeX . font-latex-user-keyword-classes AUCTeX.

( ):

(setq font-latex-user-keyword-classes
      '(("shadow-hidden"    (("hide" "{"))      shadow command)
        ("shadow-mycomment" (("mycomment" "{")) shadow command)
        ("shadow-comment"   (("comment" "{"))   shadow command)))

\hide {},\mycomment {} \comment {} .

+2

All Articles