all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Auctex and highlight own command
@ 2014-01-27 20:17 Igor Sosa Mayor
  2014-01-28 10:12 ` Tassilo Horn
  0 siblings, 1 reply; 9+ messages in thread
From: Igor Sosa Mayor @ 2014-01-27 20:17 UTC (permalink / raw)
  To: lista-emacs

Hi,

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. In
internet there is some solutions, for instance this one:
http://stackoverflow.com/questions/11844936/emacs-auctex-custom-syntax-highlight

But even this example does not work for me (that is, if I use the same
command and the solutions there, I see no differences)...

I can imagine, I should do something like this:

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

But, as I said, this has no effect...

many thanks in advance!

-- 
:: Igor Sosa Mayor     :: joseleopoldo1792@gmail.com ::
:: GnuPG: 0x1C1E2890   :: http://www.gnupg.org/      ::
:: jabberid: rogorido  ::                            ::



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Auctex and highlight own command
       [not found] <mailman.12978.1390853889.10748.help-gnu-emacs@gnu.org>
@ 2014-01-28  3:23 ` Emanuel Berg
  2014-01-28  7:34   ` Igor Sosa Mayor
                     ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Emanuel Berg @ 2014-01-28  3:23 UTC (permalink / raw)
  To: help-gnu-emacs

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

> (add-hook 'LaTeX-mode-hook (lambda ()
> (font-lock-add-keywords nil '(("\\(\\\\com\\)\\s-*{"

How does the com command look when used? (Just the
letters.)

-- 
underground experts united:
http://user.it.uu.se/~embe8573


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Auctex and highlight own command
  2014-01-28  3:23 ` Auctex and highlight own command Emanuel Berg
@ 2014-01-28  7:34   ` Igor Sosa Mayor
  2014-01-28  8:44   ` Igor Sosa Mayor
       [not found]   ` <mailman.13007.1390898732.10748.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 9+ messages in thread
From: Igor Sosa Mayor @ 2014-01-28  7:34 UTC (permalink / raw)
  To: help-gnu-emacs

Am Tue, Jan 28, 2014 at 04:23:52AM +0100, Emanuel Berg wrote:

> How does the com command look when used? (Just the
> letters.)

light grey.

-- 
:: Igor Sosa Mayor     :: joseleopoldo1792@gmail.com ::
:: GnuPG: 0x1C1E2890   :: http://www.gnupg.org/      ::
:: jabberid: rogorido  ::                            ::



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Auctex and highlight own command
  2014-01-28  3:23 ` Auctex and highlight own command Emanuel Berg
  2014-01-28  7:34   ` Igor Sosa Mayor
@ 2014-01-28  8:44   ` Igor Sosa Mayor
       [not found]   ` <mailman.13007.1390898732.10748.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 9+ messages in thread
From: Igor Sosa Mayor @ 2014-01-28  8:44 UTC (permalink / raw)
  To: help-gnu-emacs

Am Tue, Jan 28, 2014 at 04:23:52AM +0100, Emanuel Berg wrote:
> How does the com command look when used? (Just the
> letters.)

as I said, light grey, and that means, there are no changes whether I
put this piece of lisp code or not.

-- 
:: Igor Sosa Mayor     :: joseleopoldo1792@gmail.com ::
:: GnuPG: 0x1C1E2890   :: http://www.gnupg.org/      ::
:: jabberid: rogorido  ::                            ::



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Auctex and highlight own command
  2014-01-27 20:17 Igor Sosa Mayor
@ 2014-01-28 10:12 ` Tassilo Horn
  2014-01-28 10:32   ` Igor Sosa Mayor
  0 siblings, 1 reply; 9+ messages in thread
From: Tassilo Horn @ 2014-01-28 10:12 UTC (permalink / raw)
  To: lista-emacs

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



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Auctex and highlight own command
  2014-01-28 10:12 ` Tassilo Horn
@ 2014-01-28 10:32   ` Igor Sosa Mayor
  2014-01-31 22:57     ` Tassilo Horn
  0 siblings, 1 reply; 9+ messages in thread
From: Igor Sosa Mayor @ 2014-01-28 10:32 UTC (permalink / raw)
  To: help-gnu-emacs

Am Tue, Jan 28, 2014 at 11:12:14AM +0100, Tassilo Horn wrote:
> Have a look at:
> [...]
> 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)))
> 

wonderful! It's working perfectly! Many thanks again!

-- 
:: Igor Sosa Mayor     :: joseleopoldo1792@gmail.com ::
:: GnuPG: 0x1C1E2890   :: http://www.gnupg.org/      ::
:: jabberid: rogorido  ::                            ::



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Auctex and highlight own command
       [not found]   ` <mailman.13007.1390898732.10748.help-gnu-emacs@gnu.org>
@ 2014-01-28 18:00     ` Emanuel Berg
  2014-01-28 21:29       ` Igor Sosa Mayor
  0 siblings, 1 reply; 9+ messages in thread
From: Emanuel Berg @ 2014-01-28 18:00 UTC (permalink / raw)
  To: help-gnu-emacs

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

>> How does the com command look when used? (Just the
>> letters.)
>
> as I said, light grey, and that means, there are no
> changes whether I put this piece of lisp code or not.

No, I meant *in writing*, because I had a hard time
translating from the regular expression. But I see you
already solved this problem, so all well.

-- 
underground experts united:
http://user.it.uu.se/~embe8573


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Auctex and highlight own command
  2014-01-28 18:00     ` Emanuel Berg
@ 2014-01-28 21:29       ` Igor Sosa Mayor
  0 siblings, 0 replies; 9+ messages in thread
From: Igor Sosa Mayor @ 2014-01-28 21:29 UTC (permalink / raw)
  To: help-gnu-emacs

Am Tue, Jan 28, 2014 at 07:00:54PM +0100, Emanuel Berg wrote:
> No, I meant *in writing*, because I had a hard time
> translating from the regular expression. But I see you
> already solved this problem, so all well.

yes, it is already solved! Thanks in any case!

-- 
:: Igor Sosa Mayor     :: joseleopoldo1792@gmail.com ::
:: GnuPG: 0x1C1E2890   :: http://www.gnupg.org/      ::
:: jabberid: rogorido  ::                            ::



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Auctex and highlight own command
  2014-01-28 10:32   ` Igor Sosa Mayor
@ 2014-01-31 22:57     ` Tassilo Horn
  0 siblings, 0 replies; 9+ messages in thread
From: Tassilo Horn @ 2014-01-31 22:57 UTC (permalink / raw)
  To: help-gnu-emacs

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

>> 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)))
>> 
>
> wonderful! It's working perfectly! Many thanks again!

You're welcome!

Bye,
Tassilo



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-01-31 22:57 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.12978.1390853889.10748.help-gnu-emacs@gnu.org>
2014-01-28  3:23 ` Auctex and highlight own command Emanuel Berg
2014-01-28  7:34   ` Igor Sosa Mayor
2014-01-28  8:44   ` Igor Sosa Mayor
     [not found]   ` <mailman.13007.1390898732.10748.help-gnu-emacs@gnu.org>
2014-01-28 18:00     ` Emanuel Berg
2014-01-28 21:29       ` Igor Sosa Mayor
2014-01-27 20:17 Igor Sosa Mayor
2014-01-28 10:12 ` Tassilo Horn
2014-01-28 10:32   ` Igor Sosa Mayor
2014-01-31 22:57     ` Tassilo Horn

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.