* Re: Change the color of article counts when equal to 0
[not found] <80iq17u1ff.fsf@mundaneum.com>
@ 2010-10-12 11:06 ` Richard Riley
[not found] ` <80r5fvwrw2.fsf@mundaneum.com>
0 siblings, 1 reply; 2+ messages in thread
From: Richard Riley @ 2010-10-12 11:06 UTC (permalink / raw)
To: info-gnus-english
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.
^ permalink raw reply [flat|nested] 2+ messages in thread