[Top][All Lists]

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

Re: Coloring pieces of messages in Gnus

From: Peter Anderson
Subject: Re: Coloring pieces of messages in Gnus
Date: Wed, 30 May 2012 15:14:46 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.94 (gnu/linux)

Okay -- I've made a little progress.  I now have this:

;; Custom colors
(defface my-group-face-1
  '((t (:foreground "Red" :bold t))) "First group face")
(defface my-group-face-2
  '((t (:foreground "Green" :bold t))) "Second group face")
(defface my-group-face-3
  '((t (:foreground "Green4" :bold t))) "Third group face")
(defface my-group-face-4
  '((t (:foreground "SteelBlue" :bold t))) "Fourth group face")
(defface my-group-face-5
  '((t (:foreground "Blue" :bold t))) "Fifth group face")

;; Apply custom colors dependent on regex matching
;; Need to limit to certain groups
(defun pja-gnus-git-color ()
  (highlight-regexp "^-.*" 'my-group-face-1)
  (highlight-regexp "^+.*" 'my-group-face-2))
(add-hook 'gnus-article-display-hook 'pja-gnus-git-color)

The first part defines new colors.  The second part applies them using
my defined function which is called with gnus-article-display-hook.
This all works like I want it to...sort of.  If I go to a message in my
Git commit group I see lines that start with "-" as red and "+" as
green.  But, it only works on the first message I view in that group.
If I hit "n" the next message doesn't have the highlighting.  If I hit
"P" to go back to where I just was, the highlighting isn't there now.
If I exit the group "q" and go back in the first message I view will
display the custom colors.

What am I missing?



Peter Anderson <> writes:

> I'm a noob.  I've looked around and think I've found parts of the answer
> but can't find any good examples.
> I want to use a regex to change the color of some aspects of articles.
> I have a group called git-commit.  For articles in that group I would
> like any line that starts with "---" to be red and any line that starts
> with "+++" to be green. (the whole line)
> Another group has Help-desk tickets in it and it will have line similar
> to:
>    blah blah blah Assigned: Peter
> I want to be able to make the word following "Assigned:" (in this case
> "Peter") stand out by changing its color or some attribute.
> I think I need to define a function and then use gnus-part-display-hook
> but the syntax of it all has eluded me so far.
> Thanks so much,
> Peter

reply via email to

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