* 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
* Re: Change the color of article counts when equal to 0
[not found] ` <80r5fvwrw2.fsf@mundaneum.com>
@ 2010-10-12 12:05 ` Richard Riley
0 siblings, 0 replies; 2+ messages in thread
From: Richard Riley @ 2010-10-12 12:05 UTC (permalink / raw)
To: info-gnus-english
Sébastien Vauban <wxhgmqzgwmuf@spammotel.com> writes:
> Hi Richard,
>
> Richard Riley wrote:
>> Sébastien Vauban <wxhgmqzgwmuf@spammotel.com> writes:
>>> I'm using 4 count numbers on every group line.
>>>
>>> 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?
>>
>> You need to use a user format function.
>>
>> 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)))
>> `----
>
> This helped me a lot. I could remove the count of unread messages when it's
> equal to 0, with the following:
>
>
>
>
> --8<---------------cut here---------------start------------->8---
> (defun gnus-user-format-function-y (headers)
> "return string representation for unread articles"
> (propertize (if (= (string-to-number gnus-tmp-number-of-unread) 0)
> " "
> (concat gnus-tmp-number-of-unread " Unread"))
> 'face 'my/unread-face))
>
> ;; format of the group buffer
> (setq gnus-group-line-format (concat "%7{%M%}"
> "%8{%m%}"
> "%P "
> "%(%-39,39g%) "
> "%6{%3U Unseen%} + "
> "%5{%10uy%} "
> "%7{%3T Ticked%} < "
> "%6t Total Items"
> "\n"))
> --8<---------------cut here---------------end--------------->8---
>
>
>
> Though, I would like to do the same with the counts of unseen or ticked
> messages, but the variable `gnus-tmp-number-of-unread' does not
> exist. Any
Did you mean -ticked or something else rather than -unread?
As a note I wouldnt put that fixed length empty string in - rather try
and use padding formatting in the format string if its possible.
> idea on how to do such?
It's a cross fingers and hope for the best when hacking gnus ;) I only
found that var by googling and staring at other similar examples. There
often seems no rhyme nor reason to what is available but there
invairably is ;) I asked a couple of times about how to determine what
is available but didn't get much success. Digging in the code is the
best advice I can give.
best of luck!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-10-12 12:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <80iq17u1ff.fsf@mundaneum.com>
2010-10-12 11:06 ` Change the color of article counts when equal to 0 Richard Riley
[not found] ` <80r5fvwrw2.fsf@mundaneum.com>
2010-10-12 12:05 ` Richard Riley
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).