all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* colorization of mode contents
@ 2014-01-24 16:43 Haines Brown
  2014-01-25 14:14 ` Emanuel Berg
  0 siblings, 1 reply; 13+ messages in thread
From: Haines Brown @ 2014-01-24 16:43 UTC (permalink / raw)
  To: help-gnu-emacs

In LaTeX/PS mode, the \cite{key} command displays key values in green in
the raw .tex file. This makes it easy to spot the command in a block of
text.

Unfortunately, I'm using a cite command peculiar to the achicago style,
which is \citeNP{key}. Key values are no longer colored, but I would like
them to be. 

I get the impression highlighting of command is done with emacs' M-x
font-lock-mode RET. But AUCTeX apparently imposes its own scheme
activated by tex-font-setup. I don't know whether I need somehow to
configure AUCTeX or emacs. 

Since "citeNP" is unlikely to appear in other contexts, could I use a
setq statement in .emacs to highight it as a verbatim? Do I use the
LaTeX-verbatim-environments variable? I'm lost at this point.  

Haines Brown

  


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

* Re: colorization of mode contents
  2014-01-24 16:43 colorization of mode contents Haines Brown
@ 2014-01-25 14:14 ` Emanuel Berg
  2014-01-25 15:55   ` Haines Brown
                     ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Emanuel Berg @ 2014-01-25 14:14 UTC (permalink / raw)
  To: help-gnu-emacs

Haines Brown <haines@histomat.net> writes:

> In LaTeX/PS mode, the \cite{key} command displays key
> values in green in the raw .tex file. This makes it
> easy to spot the command in a block of text.

Try:

(font-lock-add-keywords
 'latex-mode
 '(("citeNP\{\\(.*\\)\}" (1 'font-lock-comment-face))))

If nothing happens, after eval, try (latex-mode) or
`M-x latex-mode'. (And change the face to whatever you
like.)

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


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

* Re: colorization of mode contents
  2014-01-25 14:14 ` Emanuel Berg
@ 2014-01-25 15:55   ` Haines Brown
  2014-01-25 17:15     ` Emanuel Berg
  2014-01-25 20:56   ` Haines Brown
  2014-01-25 21:27   ` Stefan Monnier
  2 siblings, 1 reply; 13+ messages in thread
From: Haines Brown @ 2014-01-25 15:55 UTC (permalink / raw)
  To: help-gnu-emacs

Emanuel Berg <embe8573@student.uu.se> writes:

> Haines Brown <haines@histomat.net> writes:
>
>> In LaTeX/PS mode, the \cite{key} command displays key
>> values in green in the raw .tex file. This makes it
>> easy to spot the command in a block of text.
>
> Try:
>
> (font-lock-add-keywords
>  'latex-mode
>  '(("citeNP\{\\(.*\\)\}" (1 'font-lock-comment-face))))

Unfortunately, nothing happened. 

> If nothing happens, after eval, 

Being a LISP ignoramus, I tried C-x C-e after each of the parentheses or
brackets. Starting at end (after "...))))" I got "nil", then simply an
echo of the string, then / is invalid function, then } is void variable.
Sorry. 

> try (latex-mode) 

I don't understand what you want. I tied replacing 'latex-mode with
'(latex-mode) to no avail. 

> or `M-x latex-mode'. 

Given my setup, this runs spell check, and the key values in
\citeNP{key} naturlly turn red as the result. When the cursor hits
them,the red turns off, but I return to black foreground color for the
{key} value, not the forest green I wanted.

Toggling M-x font-lock-mode didn't help any more than toggling M-x
latex-mode. 

I tried:

  (add-hook 'latex-mode
     (lambda ()
      (font-lock-add-keywords nil
        '(("citeNP\{\\(.*\\)\}" (1 'font-lock-constant-face))))))

and didn't do any better with it. I changed to constant-face because
my comment-face with command package is black foreground.

Haines


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

* Re: colorization of mode contents
  2014-01-25 15:55   ` Haines Brown
@ 2014-01-25 17:15     ` Emanuel Berg
  0 siblings, 0 replies; 13+ messages in thread
From: Emanuel Berg @ 2014-01-25 17:15 UTC (permalink / raw)
  To: help-gnu-emacs

Haines Brown <haines@histomat.net> writes:

> Being a LISP ignoramus, I tried C-x C-e after each of
> the parentheses or brackets. Starting at end (after
> "...))))" I got "nil"

Right, that's the first thing you should do (*one*
evaluation of that whole thing). Then, go to LaTeX mode
by also evaluating (latex-mode) the same way, *or*
hitting M-x and typing latex-mode and hitting return
(and you should do this regardless of what mode you
were in when you started, even if you are already in
LaTeX mode). Then, type

\citeNP{value}

It should look like this:

http://user.it.uu.se/~embe8573/tex_color.png

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


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

* Re: colorization of mode contents
  2014-01-25 14:14 ` Emanuel Berg
  2014-01-25 15:55   ` Haines Brown
@ 2014-01-25 20:56   ` Haines Brown
  2014-01-25 23:05     ` Emanuel Berg
  2014-01-25 21:27   ` Stefan Monnier
  2 siblings, 1 reply; 13+ messages in thread
From: Haines Brown @ 2014-01-25 20:56 UTC (permalink / raw)
  To: help-gnu-emacs

Emanuel, I very much appreciate your guidance, but so far I've not been
able to get things working. Just to be sure, let me go through the routine:

I have a tex  document (LaTeX, BibTeX), class article, and then 
  \usepackage[T1]{fontenc} %
  \usepackage{achicago}
    \bibliographystyle{achicago}
  \usepackage{times,comment,csquotes,lipsum,ragged2e,setspace,color,url} 
  ...

In my .emacs I have the stanza:

  (font-lock-add-keywords
   '(latex-mode)
     '(("citeNP\{\\(.*\\)\}" (1 'font-lock-comment-face))))

I open the article emacs and see that it is LaTeX/P Fly mode. I then do
M-x latex-mode on the file. 

In this article I type: \cite{value}. The "\cite" command is red and the
key word "value" is green. 

I next type \citeNP{value}, and both the command and the key word remain
black. Typing M-x latex-mode again after typing does not help.

Haines  


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

* Re: colorization of mode contents
  2014-01-25 14:14 ` Emanuel Berg
  2014-01-25 15:55   ` Haines Brown
  2014-01-25 20:56   ` Haines Brown
@ 2014-01-25 21:27   ` Stefan Monnier
  2 siblings, 0 replies; 13+ messages in thread
From: Stefan Monnier @ 2014-01-25 21:27 UTC (permalink / raw)
  To: help-gnu-emacs

> (font-lock-add-keywords
>  'latex-mode
>  '(("citeNP\{\\(.*\\)\}" (1 'font-lock-comment-face))))

If he uses AUCTeX, I think the mode name would be LaTeX-mode (tho you'd
have to check with M-: major-mode RET from within a buffer that's in
this mode).


        Stefan





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

* Re: colorization of mode contents
  2014-01-25 20:56   ` Haines Brown
@ 2014-01-25 23:05     ` Emanuel Berg
  2014-01-25 23:21       ` Emanuel Berg
  2014-01-26 12:35       ` Haines Brown
  0 siblings, 2 replies; 13+ messages in thread
From: Emanuel Berg @ 2014-01-25 23:05 UTC (permalink / raw)
  To: help-gnu-emacs

Haines Brown <haines@histomat.net> writes:

>   (font-lock-add-keywords '(latex-mode)
> (("citeNP\{\\(.*\\)\}" (1 'font-lock-comment-face))))

You didn't type that correctly.

'(latex-mode) should be 'latex-mode

And you forgot to quote the list (without it, that
shouldn't even evaluate).

Look below:

(font-lock-add-keywords
 'latex-mode
 '(("citeNP\{\\(.*\\)\}" (1 'font-lock-comment-face))))

It is probably easier at this stage to not mess around
with .emacs - just put the above code in a buffer, and
evaluate it, then put the buffer in latex-mode, then
type the citeNP stuff.

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


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

* Re: colorization of mode contents
  2014-01-25 23:05     ` Emanuel Berg
@ 2014-01-25 23:21       ` Emanuel Berg
  2014-01-26 12:35       ` Haines Brown
  1 sibling, 0 replies; 13+ messages in thread
From: Emanuel Berg @ 2014-01-25 23:21 UTC (permalink / raw)
  To: help-gnu-emacs

Emanuel Berg <embe8573@student.uu.se> writes:

> And you forgot to quote the list (without it, that
> shouldn't even evaluate).
>
> Look below:
>
> (font-lock-add-keywords 'latex-mode
> (("citeNP\{\\(.*\\)\}" (1 'font-lock-comment-face))))

What the ...!?

OK, so you didn't do that (the second) mistake I said
you did, that quote is somehow lost when I receive
messages - perhaps something I did to Gnus or the
message mode... (?)

Anyway, that makes sense, because like I said, if it
wasn't there, that "list" would have produced an error
when evaluated in your .emacs.

So the only thing you should change is '(latex-mode) to
'latex-mode. Then it should work. If you actually use
another mode for LaTeX, that shouldn't matter for this
demo as long as you have the mode I use as well. If you
want to change, just change 'latex-mode to the mode you
use, and then, of course, invoke the command to put a
buffer in *that* mode instead.

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


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

* Re: colorization of mode contents
  2014-01-25 23:05     ` Emanuel Berg
  2014-01-25 23:21       ` Emanuel Berg
@ 2014-01-26 12:35       ` Haines Brown
  2014-01-26 15:51         ` Emanuel Berg
  1 sibling, 1 reply; 13+ messages in thread
From: Haines Brown @ 2014-01-26 12:35 UTC (permalink / raw)
  To: help-gnu-emacs

Emanuel Berg <embe8573@student.uu.se> writes:

> You didn't type that correctly.

Unfortunately I copied an experiment, and this parenthesis not the
problem.

> It is probably easier at this stage to not mess around
> with .emacs - just put the above code in a buffer, and
> evaluate it, then put the buffer in latex-mode, then
> type the citeNP stuff.

Your suggested procedure shed some light on the issue. I put the code
into a buffer, put the buffer into latex-mode, and the code worked,
turning the key value for \citeNP{} red. After some further
experimentation I discovered that the achicago package somehow
overwrites the added citeNP keyword. That is, if I put the line
"\usepackage{achicago}" in the buffer, the key word in \citeNP{} turns
black.

Haines


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

* Re: colorization of mode contents
  2014-01-26 12:35       ` Haines Brown
@ 2014-01-26 15:51         ` Emanuel Berg
  2014-01-27 15:49           ` Haines Brown
  0 siblings, 1 reply; 13+ messages in thread
From: Emanuel Berg @ 2014-01-26 15:51 UTC (permalink / raw)
  To: help-gnu-emacs

Haines Brown <haines@histomat.net> writes:

>> You didn't type that correctly.
>
> Unfortunately I copied an experiment, and this
> parenthesis not the problem.

If you quote a left paren, that means the following is
read as it is, as data, or a *list* (with only one
'(element) in you case, but nonetheless a list).

Try evaluating the expressions below. If you understand
how that works, you are halfway into Lisp. But of
course, the final 5% will require more work than the
first 50%...

'(+ 1 2) ; list: (+ 1 2)
(+ 1 2)  ; procedure and arguments : 3

> Your suggested procedure shed some light on the
> issue. I put the code into a buffer, put the buffer
> into latex-mode, and the code worked, turning the key
> value for \citeNP{} red.

That's another good point, if you try to get something
to work, isolate it from everything else. This
particular case (achicago) I would never have guessed,
but that method is general, so you don't have to.

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


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

* Re: colorization of mode contents
  2014-01-26 15:51         ` Emanuel Berg
@ 2014-01-27 15:49           ` Haines Brown
  2014-01-27 16:56             ` Emanuel Berg
  0 siblings, 1 reply; 13+ messages in thread
From: Haines Brown @ 2014-01-27 15:49 UTC (permalink / raw)
  To: help-gnu-emacs

Emanuel Berg <embe8573@student.uu.se> writes:

> If you quote a left paren, that means the following is
> read as it is, as data, or a *list* (with only one
> '(element) in you case, but nonetheless a list).

Ah! That explains the meaning of "list", which I had found confusing. 

> That's another good point, if you try to get something
> to work, isolate it from everything else. This
> particular case (achicago) I would never have guessed,
> but that method is general, so you don't have to.

So you are apparently saying that the achicago LaTeX style overrides
whatver citeNP keyword attributes might be specified in .emacs. It seems
that to define the keyword colors it will have to be done in the peamble
of the .tex file itself (properly the concern of a different news
group).

Thanks,

Haines



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

* Re: colorization of mode contents
  2014-01-27 15:49           ` Haines Brown
@ 2014-01-27 16:56             ` Emanuel Berg
  2014-01-27 19:36               ` Haines Brown
  0 siblings, 1 reply; 13+ messages in thread
From: Emanuel Berg @ 2014-01-27 16:56 UTC (permalink / raw)
  To: help-gnu-emacs

Haines Brown <haines@histomat.net> writes:

> So you are apparently saying that the achicago LaTeX
> style overrides whatver citeNP keyword attributes
> might be specified in .emacs.

No, I'm not saying that, you are saying that :) I'm
saying, *if true*, we could have been analyzing
ourselves to death without thinking of it. But by
isolating the code which "should" work, and it does,
means we don't have to bother with that anymore - the
error is somewhere else, and to find it we have to
search elsewhere. And you did (I hope) find it! As for
me I have done lots of LaTeX but I have no in-depth
knowledge and most certainly not with respect to the
zillion packages out there. So I can't confirm your
hypothesis.

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


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

* Re: colorization of mode contents
  2014-01-27 16:56             ` Emanuel Berg
@ 2014-01-27 19:36               ` Haines Brown
  0 siblings, 0 replies; 13+ messages in thread
From: Haines Brown @ 2014-01-27 19:36 UTC (permalink / raw)
  To: help-gnu-emacs

Emanuel Berg <embe8573@student.uu.se> writes:

> But by isolating the code which "should" work, and it does, means we
> don't have to bother with that anymore - the error is somewhere else,
> and to find it we have to search elsewhere.

That, in my clumbsy way, was what I was trying to say ;-). 

> And you did (I hope) find it! As for me I have done lots of LaTeX but
> I have no in-depth knowledge and most certainly not with respect to
> the zillion packages out there. So I can't confirm your hypothesis.

Well, I looked into the achicago.sty file and the achicago manual, and
find that neither defines colors. So if a color definition in .emacs
works, but gets overwritten, it looks like the problem lies somewhere
between .emacs and the achicago style, which may be AUCTeX. To ensure
portability, however, I may have to insert a color scheme for
\citeNP{key} into my tex file preable.

Thanks again (including for your patience for my bringing up material that
turns not appropriate to the emacs group).

Haines
 


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

end of thread, other threads:[~2014-01-27 19:36 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-24 16:43 colorization of mode contents Haines Brown
2014-01-25 14:14 ` Emanuel Berg
2014-01-25 15:55   ` Haines Brown
2014-01-25 17:15     ` Emanuel Berg
2014-01-25 20:56   ` Haines Brown
2014-01-25 23:05     ` Emanuel Berg
2014-01-25 23:21       ` Emanuel Berg
2014-01-26 12:35       ` Haines Brown
2014-01-26 15:51         ` Emanuel Berg
2014-01-27 15:49           ` Haines Brown
2014-01-27 16:56             ` Emanuel Berg
2014-01-27 19:36               ` Haines Brown
2014-01-25 21:27   ` Stefan Monnier

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.