From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/56109 Path: main.gmane.org!not-for-mail From: Adrian Lanz Newsgroups: gmane.emacs.gnus.general Subject: [PROPOSAL] nnfolder-generate-active-file extension Date: Mon, 19 Jan 2004 22:54:49 +0100 Sender: ding-owner@lists.math.uh.edu Message-ID: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1074549339 16544 80.91.224.253 (19 Jan 2004 21:55:39 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 19 Jan 2004 21:55:39 +0000 (UTC) Original-X-From: ding-owner+M4649@lists.math.uh.edu Mon Jan 19 22:55:31 2004 Return-path: Original-Received: from malifon.math.uh.edu ([129.7.128.13]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1AihMp-0000MP-00 for ; Mon, 19 Jan 2004 22:55:31 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by malifon.math.uh.edu with smtp (Exim 3.20 #1) id 1AihMO-0000S9-00; Mon, 19 Jan 2004 15:55:04 -0600 Original-Received: from justine.libertine.org ([66.139.78.221] ident=postfix) by malifon.math.uh.edu with esmtp (Exim 3.20 #1) id 1AihME-0000S1-00 for ding@lists.math.uh.edu; Mon, 19 Jan 2004 15:54:54 -0600 Original-Received: from quimby.gnus.org (quimby.gnus.org [80.91.224.244]) by justine.libertine.org (Postfix) with ESMTP id 7E6603A0039 for ; Mon, 19 Jan 2004 15:54:54 -0600 (CST) Original-Received: from news by quimby.gnus.org with local (Exim 3.35 #1 (Debian)) id 1AihMD-0001BD-00 for ; Mon, 19 Jan 2004 22:54:53 +0100 Original-To: ding@gnus.org Original-Path: not-for-mail Original-Newsgroups: gnus.ding Original-Lines: 115 Original-NNTP-Posting-Host: 193.134.205.252 Original-X-Trace: quimby.gnus.org 1074549293 4538 193.134.205.252 (19 Jan 2004 21:54:53 GMT) Original-X-Complaints-To: usenet@quimby.gnus.org Original-NNTP-Posting-Date: Mon, 19 Jan 2004 21:54:53 +0000 (UTC) User-Agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (usg-unix-v) Cancel-Lock: sha1:B6B7K1fjArc6r4QfCuYtI6O5bUg= Precedence: bulk Xref: main.gmane.org gmane.emacs.gnus.general:56109 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:56109 BACKGROUND This is a proposal for solving a problem that has been addressed a couple times from different people, which create (typically through mail splitting rules) many nnfolder groups. MOTIVATION I personally create a nnfolder group for every reasonable (hopefully not spam) net address I get mail messages from. The result is, that I get an immediate overview over all new and "somehow important" (that is ticked) messages by person in the group buffer, and - as I split also outgoing messages by the net address of the receiver - I find the entire correspondence with that and only that person in a single group. Well this whole thing is probabely a matter of taste. I am just used to it for a long time now. 10 years ago, I actually thought of keeping at least the most important correspondence in archives collected this way, but this turned out to make little sense in the long run. At the moment, the archives are sorted by year and - for "historcal reasons" still by some important domain names of the senders or receivers net address. But searching is done over all archives through nnir with swish-e. PROBLEM The problem with such a setup is, that after a couple of weeks or years (in my case) and with mail expiry constantly doing its fine job in the background, most nnfolder groups are actualy empty. I could go through all groups to find out the empty ones and kill them "by hand" (gnus-group-delete-group), but this is not only boring, but also error-prone. SOLUTION The below patch implements a means to delete empty nnfolder groups in the process of generating a new active file for the nnfolder backend (by giving a prefix to function nnfolder-generate-active-file). REQUEST FOR COMMENTS The patch works for me as intended, but before asking to implemente the additional functionality in Gnus, it would be reasonable to discuss the utility and potential hazards and caveats on the list. Please do! Thanks, Adrian. diff -c tmp/old.el tmp/new.el *** tmp/old.el 2004-01-19 19:42:36.613419000 +0100 --- tmp/new.el 2004-01-19 21:28:55.763432000 +0100 *************** *** 1,6 **** ! (defun nnfolder-generate-active-file () ! "Look for mbox folders in the nnfolder directory and make them into groups. ! This command does not work if you use short group names." (interactive) (nnmail-activate 'nnfolder) (unless (or gnus-nov-is-evil nnfolder-nov-is-evil) --- 1,11 ---- ! (defun nnfolder-generate-active-file (&optional force) ! "Look for mbox folders in the nnfolder directory and make them ! into groups. If FORCE (the prefix) is non-nil, delete all groups ! in the nnfolder back end for which a corresponding file is found ! in the the nnfolder directory that does not folow the mbox ! format (typically an empty file corresponding to an empty group ! in the nnfolder back end). There is no undo. This command does ! not work if you use short group names." (interactive) (nnmail-activate 'nnfolder) (unless (or gnus-nov-is-evil nnfolder-nov-is-evil) *************** *** 16,33 **** (let ((files (directory-files nnfolder-directory)) file) (while (setq file (pop files)) ! (when (and (not (backup-file-name-p file)) ! (message-mail-file-mbox-p ! (nnheader-concat nnfolder-directory file))) ! (let ((oldgroup (assoc file nnfolder-group-alist))) ! (if oldgroup ! (nnheader-message 5 "Refreshing group %s..." file) ! (nnheader-message 5 "Adding group %s..." file)) ! (if oldgroup ! (setq nnfolder-group-alist ! (delq oldgroup (copy-sequence nnfolder-group-alist)))) ! (push (list file (cons 1 0)) nnfolder-group-alist) ! (nnfolder-possibly-change-folder file) ! (nnfolder-possibly-change-group file) ! (nnfolder-close-group file)))) (nnheader-message 5 ""))) --- 21,45 ---- (let ((files (directory-files nnfolder-directory)) file) (while (setq file (pop files)) ! (when (not (backup-file-name-p file)) ! (if (message-mail-file-mbox-p (nnheader-concat nnfolder-directory file)) ! (let ((oldgroup (assoc file nnfolder-group-alist))) ! (if oldgroup ! (nnheader-message 5 "Refreshing group %s..." file) ! (nnheader-message 5 "Adding group %s..." file)) ! (if oldgroup ! (setq nnfolder-group-alist ! (delq oldgroup (copy-sequence nnfolder-group-alist)))) ! (push (list file (cons 1 0)) nnfolder-group-alist) ! (nnfolder-possibly-change-folder file) ! (nnfolder-possibly-change-group file) ! (nnfolder-close-group file)) ! (let ((oldgroup (assoc file nnfolder-group-alist))) ! (when (and force oldgroup) ! (nnheader-message 5 "Removing group %s..." file) ! (nnfolder-possibly-change-folder file) ! (nnfolder-possibly-change-group file) ! (if (eq 0 (nth 7 (file-attributes (nnheader-concat nnfolder-directory file)))) ! (nnfolder-request-delete-group file t) ! (nnfolder-request-delete-group file))))))) (nnheader-message 5 ""))) Diff finished at Mon Jan 19 21:30:57