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

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

Re: Custom colour for a custom command


From: Sharon Kimble
Subject: Re: Custom colour for a custom command
Date: Fri, 02 Oct 2015 20:13:53 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5.50 (gnu/linux)

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

> Sharon Kimble <boudiccas@skimble.plus.com> writes:
>
>> I have a latex command called "\myparencite{foo}"
>> which has the same colour as the surrounding text.
>
> (font-lock-add-keywords 'latex-mode
>  '(("\\(myparencite\\){\\(.*\\)}" (1 font-lock-constant-face)
>                                   (2 font-lock-doc-face) )))

This is working well, except in this situation -

--8<---------------cut here---------------start------------->8---
 \myparencite{1767}[18] and N-methyl-serotonin \parencite{ }[19]. 
--8<---------------cut here---------------end--------------->8---

where the green colouration continues after \myparencite into the
following text, and even colouring the \parencite which has not yet been
worked on.

These two lines are from my theme, if its relevant, -

--8<---------------cut here---------------start------------->8---
 '(font-lock-constant-face ((t (:foreground "#A6E22E"))))
 '(font-lock-doc-face ((t (:foreground "#EEDC82"))))
--8<---------------cut here---------------end--------------->8---

But it is usable so thanks very much. 

Thanks
Sharon.

>
> Note: If you open a file.tex, you might end up in
> TeX-mode or some other mode to do (La)TeX. So, first
> see if it works (after evaluation) with
>
>     M-x latex-mode RET
>
> then, if your mode isn't that, make the substitution
> in the code.
>
>> How can I have a colour of :foreground "green"
>> :background "black" for it in my theme please?
>
> As you see in the code, use the font-lock-*
> faces instead. I'm sure one of yours is green, so
> use that.
>
> One way of finding out which one is green is putting
> point at a char that has a green face and then invoke
> this:
>
> (defun what-face (pos)
>   (interactive "d")
>   (let((face (or (get-char-property pos 'face)
>                  (get-char-property pos 'read-cf-name) )))
>     (message " Face: %s" (or face "(no face!)")) ))
>
> Source: http://user.it.uu.se/~embe8573/conf/emacs-init/faces.el

-- 
A taste of linux = http://www.sharons.org.uk
TGmeds = http://www.tgmeds.org.uk
Debian 8.0, fluxbox 1.3.7, emacs 24.5.50.3

Attachment: signature.asc
Description: PGP signature


reply via email to

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