Variable: font-latex-user-keyword-classes
font-latex-user-keyword-classes is a customizable variable defined in
font-latex.el.
Value
nil
Documentation
List of user-defined keyword classes for font locking.
Every keyword class consists of four parts, a name, a list of keywords, a face and a specifier for the type of macro to be highlighted.
When adding new entries, you have to use unique values for the class names, that is, they must not clash with names of the built-in keyword classes or other names given by you. Additionally the names must not contain spaces.
The list of keywords defines which commands and declarations
should be covered by the keyword class. A keyword can either be
a simple command name omitting the leading backslash or a list
consisting of the command name and a string specifying the syntax
of the command. The latter is useful if you want to match LaTeX
macros with arguments (see below). You can specify the occurence
and order of optional ("[") and mandatory ("{") arguments for
each keyword. For example for "documentclass" you'd use "[{"
because the macro has one optional followed by one mandatory
argument. Optionally starred macros can be indicated with "*".
In case an argument is an unbraced macro, use "\\". You can
also specify two alternative arguments by prefixing them with
"|". As an example, the specifier for \newcommand is
"*|{\\=\\[[{".
The face argument can either be an existing face or a face attribute.
There are three alternatives for the class type:
A value of command indicates commands with arguments
("\\foo[bar]{baz}"). The mandatory arguments in curly braces
will get the face you specified.
A value of declaration indicates declarations inside of TeX
groups ("{\\foo bar}"). The content inside the braces,
excluding the command, will get the face you specified. In case
the braces are missing, the face will be applied to the command
itself.
A value of noarg indicates commands without arguments
("\\foo"). The command itself will get the face you
specified.
Setting this variable directly does not take effect; restart Emacs.
Source Code
;; Defined in ~/.emacs.d/elpa/auctex-14.1.2/font-latex.el
(defcustom font-latex-user-keyword-classes nil
"List of user-defined keyword classes for font locking.
Every keyword class consists of four parts, a name, a list of
keywords, a face and a specifier for the type of macro to be
highlighted.
When adding new entries, you have to use unique values for the
class names, that is, they must not clash with names of the
built-in keyword classes or other names given by you.
Additionally the names must not contain spaces.
The list of keywords defines which commands and declarations
should be covered by the keyword class. A keyword can either be
a simple command name omitting the leading backslash or a list
consisting of the command name and a string specifying the syntax
of the command. The latter is useful if you want to match LaTeX
macros with arguments (see below). You can specify the occurence
and order of optional (\"[\") and mandatory (\"{\") arguments for
each keyword. For example for \"documentclass\" you'd use \"[{\"
because the macro has one optional followed by one mandatory
argument. Optionally starred macros can be indicated with \"*\".
In case an argument is an unbraced macro, use \"\\\". You can
also specify two alternative arguments by prefixing them with
\"|\". As an example, the specifier for \\newcommand is
\"*|{\\=\\[[{\".
The face argument can either be an existing face or a face
attribute.
There are three alternatives for the class type:
A value of `command' indicates commands with arguments
\(\"\\foo[bar]{baz}\"). The mandatory arguments in curly braces
will get the face you specified.
A value of `declaration' indicates declarations inside of TeX
groups (\"{\\foo bar}\"). The content inside the braces,
excluding the command, will get the face you specified. In case
the braces are missing, the face will be applied to the command
itself.
A value of `noarg' indicates commands without arguments
\(\"\\foo\"). The command itself will get the face you
specified.
Setting this variable directly does not take effect;
restart Emacs."
:group 'font-latex-keywords
:type '(repeat (list (string :tag "Name")
(choice (repeat :tag "Keywords" (string :tag "Keyword"))
(repeat
:tag "Keywords with specs"
(group (string :tag "Keyword")
(string :tag "Format specifier"))))
(choice (face :tag "Face name")
(custom-face-edit :tag "Face attributes"))
(choice :tag "Type"
;; Maps to
;;`font-latex-match-command-with-arguments'
(const :tag "Command with arguments"
command)
;; Maps to
;;`font-latex-match-command-in-braces'
(const :tag "Declaration inside TeX group"
declaration)
;; Maps to `re-search-forward'
(const :tag "Command without arguments"
noarg))))
:set (lambda (symbol value)
(dolist (item value)
(when (string-match " " (car item))
(error "No spaces allowed in name")))
(let (names names-uniq)
(dolist (item (append font-latex-built-in-keyword-classes value))
(setq names (append names (list (car item)))))
(setq names (TeX-sort-strings names))
(setq names-uniq (TeX-delete-duplicate-strings names))
(dotimes (i (safe-length names-uniq))
(unless (string= (nth i names) (nth i names-uniq))
(error "Name %S already exists" (nth i names)))))
(set-default symbol value)
(let ((prefix "font-latex-match-"))
(dolist (elt value)
(unless (boundp (intern (concat prefix (car elt))))
;; defvar font-latex-match-*
(eval `(defvar ,(intern (concat prefix (car elt))) nil
,(concat "Regular expression to match " (car elt)
" keywords.
Generated by `font-latex-user-keyword-classes'"))))
(let ((keywords (nth 1 elt))
single-char-macro-flag)
(setq keywords (if (listp (car keywords))
(mapcar #'car keywords)
keywords))
(catch 'single-char
(dolist (keyword keywords)
(unless (string-match "^[A-Za-z]" keyword)
(setq single-char-macro-flag t)
(throw 'single-char nil))))
(set (intern (concat prefix (car elt)))
(when (> (safe-length keywords) 0)
(concat "\\\\" (regexp-opt keywords t)
(unless single-char-macro-flag "\\>")))))))))