From: Richard Riley <rileyrg@googlemail.com>
To: info-gnus-english@gnu.org
Subject: Re: Change the color of article counts when equal to 0
Date: Tue, 12 Oct 2010 13:06:46 +0200 [thread overview]
Message-ID: <i91fg7$3q3$1@quimby.gnus.org> (raw)
In-Reply-To: <80iq17u1ff.fsf@mundaneum.com>
Sébastien Vauban <wxhgmqzgwmuf@spammotel.com> writes:
> Hello,
>
> I'm using 4 count numbers on every group line:
>
>
>
>
> --8<---------------cut here---------------start------------->8---
> ;; format of the group buffer
> (setq gnus-group-line-format (concat "%M%m%P "
> "%(%-39,39g%) "
> "%5{%3y Unread%} "
> "%6{(%3U Unseen)%} + "
> "%7{%3T Ticked%} < "
> "%6t Total Items"
> "\n"))
> --8<---------------cut here---------------end--------------->8---
>
>
>
> with these fonts:
>
>
>
>
> --8<---------------cut here---------------start------------->8---
> ;; create faces for article counts
> (defface my/unread-face
> '((t (:weight bold :foreground "black"))) "Ticked group face")
> (defface my/unseen-face
> '((t (:weight bold :foreground "blue"))) "Ticked group face")
> (defface my/ticked-face
> '((t (:weight bold :foreground "orange"))) "Ticked group face")
>
> (setq gnus-face-5 'my/unread-face)
> (setq gnus-face-6 'my/unseen-face)
> (setq gnus-face-7 'my/ticked-face)
> --8<---------------cut here---------------end--------------->8---
>
>
>
> I would like to see the numbers in very light gray when they're equal to 0,
> but can't figure out how -- or, even, if possible at all... Can you help me?
>
> Best regards,
> Seb
You need to use a user format function.
e.g here is one that I use to create a mailbox icon to replace the word "INBOX".
,----
| (defun gnus-user-format-function-g (headers) ;; gnus-group-line-format use %ug to call this func! e.g "%M%S%p%P%(%-40,40ug%)%-5uy %ud\n"
| ;; split full group protocol-server:group into three parts.
| (string-match "\\(^.*\\)\\+\\(.*\\):\\(.*\\)" gnus-tmp-group)
| ;; map the first two letters of the server name to a more friendly and cuddly display name
| (let* ((match-ok (match-string 2 gnus-tmp-group))
| (server-key (if (null match-ok) nil (upcase(substring match-ok 0 2)))))
| (if (zerop (length server-key))
| gnus-tmp-group
| ;; construct new group format line with a small envelope taking the place of any INBOX
| (concat
| (propertize
| (format "%-8s" (cdr (assoc server-key rgr/server-name-maps)))
| 'face (rgr/unread-face "my-group-server-face") 'face (rgr/unread-face (concat "my-group-server-face-" server-key)) 'gnus-face t)
| " - "
| (if (string-match "INBOX" (match-string 3 gnus-tmp-group) )
| (propertize "\x2709" 'face (rgr/unread-face "my-inbox-icon-face") 'gnus-face t)
| (propertize (match-string 3 gnus-tmp-group) 'face (rgr/unread-face "my-group-face") 'gnus-face t) )))))
`----
The important bits for you are the propertize cells setting a special
face for something : in your case the count value.
Here is my user function y which does this for count :-
,----
| (defun gnus-user-format-function-y (headers)
| "return string representation for unread articles"
| (concat
| (propertize (if (= (string-to-number gnus-tmp-number-of-unread) 0) "" "\x2709") 'face (rgr/unread-face "my-inbox-icon-face") 'gnus-face t)
| (propertize (if (= (string-to-number gnus-tmp-number-of-unread) 0) ""
| (concat " (" gnus-tmp-number-of-unread ")")) 'face (rgr/unread-face "my-unread-count-face") 'gnus-face t)))
`----
And here the group line format
,----
| gnus-group-line-format is a variable defined in `gnus-group.el'.
| Its value is
| "%M%S%p%P%-12uy%(%-60ug%)\n"
|
`----
Hope it sets you on the right way.
regards
r.
next parent reply other threads:[~2010-10-12 11:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <80iq17u1ff.fsf@mundaneum.com>
2010-10-12 11:06 ` Richard Riley [this message]
[not found] ` <80r5fvwrw2.fsf@mundaneum.com>
2010-10-12 12:05 ` Richard Riley
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='i91fg7$3q3$1@quimby.gnus.org' \
--to=rileyrg@googlemail.com \
--cc=info-gnus-english@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).