Discussion:
IMAP Folder hierarchy -> Topics
Vegard Vesterheim
2012-11-23 10:16:03 UTC
Permalink
I find it convenient to arrange my IMAP folders in a hierarchy on my
IMAP server. I use procmail to presort incoming mail to IMAP folders.
This allows me maintain some structure in my mail without depending on
a specific IMAP client.

In GNUS this folder-structure is by default flattened. Is there a
convenient way to let GNUS reflect this structure in the Group buffer?

Currently I use Topics for this, but I have to administer this
manually. This is cumbersome, I tend to use different Gnusae on
different computers and therefore I need to reestablish my Topics
structure on each of them. I would like to have a simple way to tell
GNUS to generate the Topic hierarchy from the IMAP Folder hierarchy
automatically. Has anyone done something like this?

- Vegard V -
Steinar Bang
2012-11-23 10:47:32 UTC
Permalink
Post by Vegard Vesterheim
I find it convenient to arrange my IMAP folders in a hierarchy on my
IMAP server. I use procmail to presort incoming mail to IMAP folders.
This allows me maintain some structure in my mail without depending on
a specific IMAP client.
In GNUS this folder-structure is by default flattened.
Not sure what you mean by flattened...? If the hierarchy is reflected
in the folder name, it will be reflected in the nnimap group name.

But if you mean that a group cannot be a child of another group, then
that's correct.
Vegard Vesterheim
2012-11-23 11:09:36 UTC
Permalink
Post by Steinar Bang
Post by Vegard Vesterheim
I find it convenient to arrange my IMAP folders in a hierarchy on my
IMAP server. I use procmail to presort incoming mail to IMAP folders.
This allows me maintain some structure in my mail without depending on
a specific IMAP client.
In GNUS this folder-structure is by default flattened.
Not sure what you mean by flattened...? If the hierarchy is reflected
in the folder name, it will be reflected in the nnimap group name.
Yes, but GNUS has no idea about the hierarchy. I am unable to manipulate
the parent folders as a unit. Contrast this to the way topics can be
expanded/collapsed.
Post by Steinar Bang
But if you mean that a group cannot be a child of another group, then
that's correct.
Right, so I guess the only feasible way to handle this is using
topics. That is why I asked if someone had written some elisp to
automatically generate the Topic structure from the IMAP Folder
structure.

- Vegard V -
Lars Ingebrigtsen
2012-12-24 17:45:42 UTC
Permalink
Post by Vegard Vesterheim
Right, so I guess the only feasible way to handle this is using
topics. That is why I asked if someone had written some elisp to
automatically generate the Topic structure from the IMAP Folder
structure.
I haven't heard of anybody doing so...
--
(domestic pets only, the antidote for overdose, milk.)
http://lars.ingebrigtsen.no * Lars Magne Ingebrigtsen
Ted Zlatanov
2012-12-24 17:48:13 UTC
Permalink
Post by Vegard Vesterheim
Right, so I guess the only feasible way to handle this is using
topics. That is why I asked if someone had written some elisp to
automatically generate the Topic structure from the IMAP Folder
structure.
LI> I haven't heard of anybody doing so...

If you were interested in pursuing this further, gnus-sync.el has code
to create topics and move groups to them programmatically.

Ted
Vegard Vesterheim
2014-09-15 10:55:13 UTC
Permalink
Post by Ted Zlatanov
Post by Vegard Vesterheim
Right, so I guess the only feasible way to handle this is using
topics. That is why I asked if someone had written some elisp to
automatically generate the Topic structure from the IMAP Folder
structure.
LI> I haven't heard of anybody doing so...
If you were interested in pursuing this further, gnus-sync.el has code
to create topics and move groups to them programmatically.
This is an old thread. With my limited elisp skills, I took a stab at
solving this problem.

Here is a function which seems to work, using dovecot as IMAP
server. Each IMAP server gets its own main topic, and the IMAP folder
hierarchy is used to create a corresponding topic structure. Setting the
variable gnus-browse-subscribe-newsgroup-method to
gnus-subscribe-create-topic, I can simply subscribe the folders in the
server buffer (pressing 'u') and have GNUS create the appropriate topic
structure automatically. Hopefully someone with better elisp knowledge
can verify and clean up this code, and add it to GNUS.

(defun gnus-subscribe-create-topic (group)
"Subscribe new NEWSGROUP and create a topics structure reflecting the IMAP folder structure."
(interactive)
(let ((nextpos 0) ;; next position when parsing IMAP folder structure
(server)
(topic-name)
(parent-topic "Gnus")
(topicl))
(string-match "\\(.*\\):" group)
(setq server (match-string 1 group))
(setq nextpos (match-end 0))
(ignore-errors
(progn
(gnus-topic-kill-group)))
(unless (gnus-topic-find-topology server)
(gnus-topic-create-topic server parent-topic nil))
(setq parent-topic server)
(setq topic-name server)
;; Loop throuch IMAP folder structure, creating subtopics as necessary
(while (string-match "\\([^\\.]+\\)\\." group nextpos)
(setq nextpos (match-end 1))
(setq topic-name (concat parent-topic "." (match-string 1 group)))
(ignore-errors
(gnus-topic-create-topic topic-name parent-topic nil))
(setq parent-topic topic-name)
)
(gnus-subscribe-newsgroup group)
(setq topicl (assoc (gnus-group-topic group) gnus-topic-alist))
(if topicl ; Delete group from existing topic
(gnus-delete-first group topicl))
;; Add the group to the topic.
(nconc (assoc topic-name gnus-topic-alist) (list group))
(message "Subscribed group %s to topic %s" group topic-name)
))
Lars Ingebrigtsen
2015-01-27 04:53:08 UTC
Permalink
Post by Vegard Vesterheim
Here is a function which seems to work, using dovecot as IMAP
server. Each IMAP server gets its own main topic, and the IMAP folder
hierarchy is used to create a corresponding topic structure. Setting the
variable gnus-browse-subscribe-newsgroup-method to
gnus-subscribe-create-topic, I can simply subscribe the folders in the
server buffer (pressing 'u') and have GNUS create the appropriate topic
structure automatically. Hopefully someone with better elisp knowledge
can verify and clean up this code, and add it to GNUS.
Sounds like a good idea. I don't have mail box hierarchies on any IMAP
servers, so I can't test this. Perhaps somebody else who does feels
inspired to take the idea and install it in Gnus?
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog http://lars.ingebrigtsen.no/
Loading...