Announcements and discussions for Gnus, the GNU Emacs Usenet newsreader
 help / color / mirror / Atom feed
* Coloring pieces of messages in Gnus
@ 2012-05-11 17:23 Peter Anderson
  2012-05-30 19:14 ` Peter Anderson
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Anderson @ 2012-05-11 17:23 UTC (permalink / raw)
  To: info-gnus-English


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

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

* Re: Coloring pieces of messages in Gnus
  2012-05-11 17:23 Coloring pieces of messages in Gnus Peter Anderson
@ 2012-05-30 19:14 ` Peter Anderson
  2012-05-31  8:03   ` Vagn Johansen
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Anderson @ 2012-05-30 19:14 UTC (permalink / raw)
  To: info-gnus-English


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 ()
  (interactive)
  (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?

Thanks,

Peter


Peter Anderson <peter.anderson@usg.edu> 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

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

* Re: Coloring pieces of messages in Gnus
  2012-05-30 19:14 ` Peter Anderson
@ 2012-05-31  8:03   ` Vagn Johansen
  0 siblings, 0 replies; 4+ messages in thread
From: Vagn Johansen @ 2012-05-31  8:03 UTC (permalink / raw)
  To: info-gnus-english

Peter Anderson <peter.anderson@usg.edu> writes:

> ;; Apply custom colors dependent on regex matching
> ;; Need to limit to certain groups

Take a look at the customize variable gnus-emphasis-alist

-- 
Vagn Johansen

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

* Coloring pieces of messages in Gnus
@ 2012-05-11 20:10 Peter Anderson
  0 siblings, 0 replies; 4+ messages in thread
From: Peter Anderson @ 2012-05-11 20:10 UTC (permalink / raw)
  To: info-gnus-english

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

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

end of thread, other threads:[~2012-05-31  8:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-11 17:23 Coloring pieces of messages in Gnus Peter Anderson
2012-05-30 19:14 ` Peter Anderson
2012-05-31  8:03   ` Vagn Johansen
2012-05-11 20:10 Peter Anderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).