From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/84944 Path: news.gmane.org!not-for-mail From: Vegard Vesterheim Newsgroups: gmane.emacs.gnus.general Subject: Re: IMAP Folder hierarchy -> Topics Date: Mon, 15 Sep 2014 12:55:13 +0200 Organization: UNINETT. Message-ID: <1s4mw9886m.fsf@voll2.uninett.no> References: <1spq3462vw.fsf@voll.uninett.no> <1sk3tc60en.fsf@voll.uninett.no> <874njb7395.fsf@gnus.org> <87fw2v8hpe.fsf@lifelogs.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1410778509 31985 80.91.229.3 (15 Sep 2014 10:55:09 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 15 Sep 2014 10:55:09 +0000 (UTC) To: ding@gnus.org Original-X-From: ding-owner+M33188@lists.math.uh.edu Mon Sep 15 12:55:02 2014 Return-path: Envelope-to: ding-account@gmane.org Original-Received: from util0.math.uh.edu ([129.7.128.18]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XTTvx-0001zP-AP for ding-account@gmane.org; Mon, 15 Sep 2014 12:55:01 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by util0.math.uh.edu with smtp (Exim 4.63) (envelope-from ) id 1XTTve-0002uZ-Va; Mon, 15 Sep 2014 05:54:43 -0500 Original-Received: from mx1.math.uh.edu ([129.7.128.32]) by util0.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1XTTvd-0002uM-L8 for ding@lists.math.uh.edu; Mon, 15 Sep 2014 05:54:41 -0500 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx1.math.uh.edu with esmtps (TLSv1:AES128-SHA:128) (Exim 4.76) (envelope-from ) id 1XTTvP-00084y-W6 for ding@lists.math.uh.edu; Mon, 15 Sep 2014 05:54:41 -0500 Original-Received: from epost.uninett.no ([158.38.180.100]) by quimby.gnus.org with esmtp (Exim 4.80) (envelope-from ) id 1XTTvN-0001KN-Ui for ding@gnus.org; Mon, 15 Sep 2014 12:54:25 +0200 Original-Received: from voll2.uninett.no (unknown [IPv6:2001:700:1:0:ec75:392c:be82:4068]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by epost.uninett.no (Postfix) with ESMTPSA id E326C33639B for ; Mon, 15 Sep 2014 12:54:19 +0200 (CEST) X-Face: Vl8-zx%G~!/rC5W!BM+T]w:k.[$Zqh. Q'Af|}oZ6JAhaysP"/43eD<|.BoMETII (Ted Zlatanov's message of "Mon, 24 Dec 2012 12:48:13 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) X-Spam-Score: -2.6 (--) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:84944 Archived-At: On Mon, 24 Dec 2012 12:48:13 -0500 Ted Zlatanov wrote: > On Mon, 24 Dec 2012 18:45:42 +0100 Lars Ingebrigtsen wrote: > > LI> Vegard Vesterheim writes: >>> 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) ))