Changing the display name of a GNUS group
Asked Answered
B

1

9

Is there any way to change the name displayed for a group in GNUS without actually renaming the group? I read my email off of an IMAP server, and the group names are pretty ugly (e.g. nnimap+uwindsor:INBOX.) I tried using the command gnus-group-rename-group but that attempts to change the name on the actual server. Is there any way to simply map the actual name to some local display name, to make my group buffer a little bit more readable?

Beekeeper answered 3/3, 2014 at 15:31 Comment(5)
I expect that the parameter does not affect this particular problem, but the (banner . REGEXP) group parameter will strip any matches to REGEXP from an article...Frymire
Hrm yeah that doesn't seem like it will do. I don't need to change the text in the articles, but the names of the groups themselves.Beekeeper
Also the (variable form) found on this page lists ways of removing tags and such...Frymire
Have you adjusted the gnus-group-line-format variable? Note this page, especially the NAMESPACE section where the "user format function" is discussed.Frymire
Oh wow, thanks. That's actually really helpful. I'll hack up some elisp later on to just map the real names to "prettier" ones, with the %uG technique described there.Beekeeper
B
9

So here's how I solved the problem. First off, many thanks to abiessu for pointing me in the right direction through his comments.

(setq gnus-group-line-format "%M%S%5y/%-5t: %uG %D\n")
(defun gnus-user-format-function-G (arg)
  (let ((mapped-name (assoc gnus-tmp-group group-name-map)))
    (if (null mapped-name)
        gnus-tmp-group
      (cdr mapped-name))))

This little function simply looks up the current group name in a map I define, and if there is a "translation" it displays that instead of the actual name. Some examples that I'm using in my config are:

(setq group-name-map '(("nnimap+uwindsor:INBOX" . "School-Inbox")
                       ("nnimap+uwindsor:[Gmail]/Starred" . "School-Starred")
                       ("nnimap+uwindsor:[Gmail]/Sent Mail" . "School-Sent")))

Using just an alist is nice because I can create the mappings anyway I want to, without having to resort to regexes, patterns, etc.

Beekeeper answered 3/3, 2014 at 16:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.