From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/37235 Path: main.gmane.org!not-for-mail From: Lloyd Zusman Newsgroups: gmane.emacs.gnus.general Subject: Re: Packing nnml folders... Date: 29 Jul 2001 15:01:29 -0400 Organization: FreeBSD/Linux Hippopotamus Preserve Sender: Lloyd Zusman Message-ID: References: NNTP-Posting-Host: coloc-standby.netfonds.no Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1035172686 12806 80.91.224.250 (21 Oct 2002 03:58:06 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 21 Oct 2002 03:58:06 +0000 (UTC) Return-Path: Return-Path: Original-Received: (qmail 16537 invoked from network); 29 Jul 2001 19:01:46 -0000 Original-Received: from home.ljz.net (216.27.138.217) by gnus.org with SMTP; 29 Jul 2001 19:01:46 -0000 Original-Received: by home.ljz.net (Postfix, from userid 2001) id 9E1F319F7C; Sun, 29 Jul 2001 15:01:29 -0400 (EDT) Original-To: ding@gnus.org X-Face: "!ga1s|?LNLE3MeeeEYs(%LIl9q[xV9!j4#xf4!**BFW_ihlOb;:Slb>)vy>CJM (Lloyd Zusman's message of "28 Jul 2001 22:18:34 -0400") User-Agent: Gnus/5.090004 (Oort Gnus v0.04) XEmacs/21.4 (Academic Rigor) Original-Lines: 95 Xref: main.gmane.org gmane.emacs.gnus.general:37235 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:37235 Lloyd Zusman writes: > [ ... ] > > But for the time being, I've hacked out a function that will renumber > and repack an nnml group. You can see it below. Here's a new-and-improved version. It's more efficient, and there are a couple of subtle bugs that were fixed. However, it's still expermental, and it's very light on error checking. Therefore, don't forget to back up everything before you play with this. ;; Helper function: return a unique, temporary group name ;; that's based on a specified nnml group name. (defun create-temp-nnml-group-name (group) (let ((method (gnus-find-method-for-group group)) (temp-name-pattern (concat group "-temp-%d")) (n 0) temp-name group-dir) (unless (eq (car method) 'nnml) (error "Not an nnml group: %s" group)) (setq group-dir (expand-file-name (nth 1 (nth 2 method)))) ;; Uniqueness test: 1. make sure that no group exists ;; with the same name ;; 2. make sure that there's no ;; nnml directory for a group ;; of this name (such a directory ;; might still exist if a group ;; with the specified name was ;; previously deleted) (while (or (gnus-gethash (setq temp-name (format temp-name-pattern n)) gnus-newsrc-hashtb) (file-directory-p (nnmail-group-pathname (gnus-group-real-name temp-name) group-dir))) (setq n (1+ n))) temp-name)) ;; Repack and renumber an nnml group. I only allow this to work ;; if it's invoked from within the Group buffer. (defun repack-and-renumber-nnml-group (group) (interactive (progn (unless (eq (current-buffer) (get-buffer gnus-group-buffer)) (error "This function should only be invoked from within the %s buffer." gnus-group-buffer)) (list (gnus-completing-read (gnus-group-group-name) "Group:" gnus-active-hashtb nil 'require-match)))) ;; Make sure that `gnus-large-newsgroup' is nil; ;; also, get a unique temporary group name. We ;; have to be inside of an nnml group in order ;; for us to get a proper temporary name. (let* ((gnus-large-newsgroup nil) (temp-group (create-temp-nnml-group-name group))) ;; First, rename the group. For some reason, it's ;; necessary to list all the groups before either ;; renaming or deleting. (gnus-group-list-groups gnus-level-unsubscribed t) (gnus-group-rename-group group temp-group) ;; Enter this new group, with all articles visible. (gnus-group-read-group t t temp-group) ;; Mark every article (gnus-uu-mark-all) ;; Move the articles to the new group. If ;; you aren't confident about moving them, ;; un-comment out the first line and comment ;; out the second. ;;;(gnus-summary-copy-article nil group) (gnus-summary-move-article nil group) ;; Get back to the Group buffer (gnus-summary-exit) ;; Make sure that the newly created group is ;; at the same level as the original; also, ;; position the new group right next to the ;; original. (gnus-group-change-level group (gnus-group-level temp-group) (gnus-group-level group) temp-group) ;; Make sure that the new group has the same ;; customization parameters as the original. (gnus-group-set-info (gnus-info-params (gnus-get-info temp-group)) group 'params) ;; Delete the original group, which has already ;; been renamed. You'll be prompted for this. (gnus-group-list-groups gnus-level-unsubscribed t) (when (yes-or-no-p (format "Delete empty group %s? " temp-group)) (gnus-group-delete-group temp-group t t)))) -- Lloyd Zusman ljz@asfast.com