Question

I'm trying to set the color for the topic name in gnus-group-mode. I've tried to look up the face name so I can set the color property, but I get default or ascii character as the face name depending on what letter of the topic i'm looking up.

Looking up the source code of gnus I came up with this function. However I'm unsure how to assign a face to a function (if this is the right way to do things) after reading the face section of the docs.

(defun gnus-group-topic-name ()
 "The name of the topic on the current line."
 (let ((topic (get-text-property (point-at-bol) 'gnus-topic)))
    (and topic (symbol-name topic))))
Was it helpful?

Solution

There seems to be no face defined for topics out of the box. This little snippet from http://www.emacswiki.org/emacs/GnusFormatting tries to work around that, and also introduces separate faces for empty and non-empty topics:

(setq gnus-topic-line-format "%i[ %u&topic-line; ] %v\n")

;; this corresponds to a topic line format of "%n %A"
(defun gnus-user-format-function-topic-line (dummy)
  (let ((topic-face (if (zerop total-number-of-articles)
                        'my-gnus-topic-empty-face
                      'my-gnus-topic-face)))
    (propertize
     (format "%s %d" name total-number-of-articles)
     'face topic-face)))

That page also notes that you have to replace my-gnus-topic-empty-face and my-gnus-topic-face with some appropriate faces or create your own.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top