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

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

Re: Auctex and highlight own command


From: Tassilo Horn
Subject: Re: Auctex and highlight own command
Date: Tue, 28 Jan 2014 11:12:14 +0100
User-agent: Gnus/5.130008 (Ma Gnus v0.8) Emacs/24.3.50 (gnu/linux)

Igor Sosa Mayor <joseleopoldo1792@gmail.com> writes:

Hi Igor,

> I want to do something relatively easy, but I'm not able to find the
> right solution.
>
> I have defined a very simple command to insert some comments I want to
> see in the final pdf:
> \newcommand*{\com}[1]{\textcolor{blue}{NOTA: #1}}
>
> Now I want auctex to highlight the content of the com-command.

Have a look at:

,----[ C-h v font-latex-user-keyword-classes RET ]
| font-latex-user-keyword-classes is a variable defined in `font-latex.el'.
| Its value is shown below.
| 
| 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, i.e. 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 font
| specification.  (The latter option is not available in XEmacs.)
| 
| 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;
| use M-x customize or restart Emacs.
| 
| You can customize this variable.
`----

Basically, what you want is something like this:

(setq font-latex-user-keyword-classes
      '(("make-it-outstanding" (("com" "{")) font-lock-warning-face command)
        ("shadow-hidden" (("hide" "{")) shadow command)
        ("shadow-comment" (("comment" "{")) shadow command)))

which would highlight the contents of \com{...} in
font-lock-warning-face, and the contents of \hide{...} and \comment{...}
in the shadow face.

Bye,
Tassilo



reply via email to

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