X-Git-Url: http://cgit.sxemacs.org/?a=blobdiff_plain;f=lisp%2Flegacy-gnus-agent.el;h=3b55220ace50d67c7dbd02ca7713c3d6e97c0368;hb=de091d488a09fe5125d556e824baecdfdc9d73f7;hp=a09bfa4986041364c1c8395db2d609273a110811;hpb=0bb378e2cd64af2fc60717345a75f018ab466bb1;p=gnus diff --git a/lisp/legacy-gnus-agent.el b/lisp/legacy-gnus-agent.el index a09bfa498..3b55220ac 100644 --- a/lisp/legacy-gnus-agent.el +++ b/lisp/legacy-gnus-agent.el @@ -1,16 +1,45 @@ +;;; gnus-agent.el --- Legacy unplugged support for Gnus + +;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + +;; Author: Kevin Greiner +;; Keywords: news + +;; This file is part of GNU Emacs. + +;; GNU Emacs is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see . + +;;; Commentary: + +;; Conversion functions for the Agent. + +;;; Code: (require 'gnus-start) (require 'gnus-util) (require 'gnus-range) (require 'gnus-agent) -; Oort Gnus v0.08 - This release updated agent to no longer use -; history file and to support a compressed alist. +;; Oort Gnus v0.08 - This release updated agent to no longer use +;; history file and to support a compressed alist. + +(defvar gnus-agent-compressed-agentview-search-only nil) (defun gnus-agent-convert-to-compressed-agentview (converting-to) "Iterates over all agentview files to ensure that they have been converted to the compressed format." - (let ((search-in '(gnus-agent-directory)) + (let ((search-in (list gnus-agent-directory)) here members member @@ -18,16 +47,25 @@ converted to the compressed format." (while (setq here (pop search-in)) (setq members (directory-files here t)) (while (setq member (pop members)) - (cond ((file-directory-p member) - (push member search-in)) + (cond ((string-match "/\\.\\.?$" member) + nil) + ((file-directory-p member) + (push member search-in)) ((equal (file-name-nondirectory member) ".agentview") - (setq converted-something + (setq converted-something (or (gnus-agent-convert-agentview member) converted-something)))))) (if converted-something (gnus-message 4 "Successfully converted Gnus %s offline (agent) files to %s" gnus-newsrc-file-version converting-to)))) +(defun gnus-agent-convert-to-compressed-agentview-prompt () + (catch 'found-file-to-convert + (let ((gnus-agent-compressed-agentview-search-only t)) + (gnus-agent-convert-to-compressed-agentview nil)))) + +(gnus-convert-mark-converter-prompt 'gnus-agent-convert-to-compressed-agentview 'gnus-agent-convert-to-compressed-agentview-prompt) + (defun gnus-agent-convert-agentview (file) "Load FILE and do a `read' there." (with-temp-buffer @@ -66,24 +104,24 @@ converted to the compressed format." (setq changed-version t))) (when changed-version + (when gnus-agent-compressed-agentview-search-only + (throw 'found-file-to-convert t)) + (erase-buffer) - (let ((compressed nil)) - (mapcar (lambda (pair) - (let* ((article-id (car pair)) - (day-of-download (cdr pair)) - (comp-list (assq day-of-download compressed))) - (if comp-list - (setcdr comp-list - (cons article-id (cdr comp-list))) - (setq compressed - (cons (list day-of-download article-id) - compressed))) - nil)) alist) - (mapcar (lambda (comp-list) - (setcdr comp-list - (gnus-compress-sequence - (nreverse (cdr comp-list))))) - compressed) + (let (article-id day-of-download comp-list compressed) + (while alist + (setq article-id (caar alist) + day-of-download (cdar alist) + comp-list (assq day-of-download compressed) + alist (cdr alist)) + (if comp-list + (setcdr comp-list (cons article-id (cdr comp-list))) + (push (list day-of-download article-id) compressed))) + (setq alist compressed) + (while alist + (setq comp-list (pop alist)) + (setcdr comp-list + (gnus-compress-sequence (nreverse (cdr comp-list))))) (princ compressed (current-buffer))) (insert "\n2\n") (write-file file) @@ -107,7 +145,7 @@ converted to the compressed format." (set-buffer buffer) (erase-buffer) (insert "The definition of gnus-agent-expire-days has been changed.\nYou currently have it set to the list:\n ") - (let (print-level print-length) (pp gnus-agent-expire-days (current-buffer))) + (gnus-pp gnus-agent-expire-days) (insert "\nIn order to use version '" converting-to "' of gnus, you will need to set\n") (insert "gnus-agent-expire-days to an integer. If you still wish to set different\n") @@ -148,7 +186,7 @@ converted to the compressed format." (when (eq 0 (string-match (caar days) group)) - (throw 'found (cadar days))) + (throw 'found (cadr (car days)))) (setq days (cdr days))) nil))) (when day @@ -161,7 +199,7 @@ converted to the compressed format." (t t)))))) (kill-buffer buffer)) - (error "Change gnus-agent-expire-days to an integer for gnus to start.")))) + (error "Change gnus-agent-expire-days to an integer for gnus to start")))) ;; The gnus-agent-unlist-expire-days has its own conversion prompt. ;; Therefore, hide the default prompt. @@ -184,8 +222,8 @@ possible that the hook was persistently saved." (when (cond ((eq (type-of func) 'compiled-function) ;; Search def. of compiled function for gnus-agent-do-once string - (let* (definition - print-level + (let* (definition + print-level print-length (standard-output (lambda (char) @@ -209,3 +247,7 @@ possible that the hook was persistently saved." ;; gnus-agent-unhook-expire-days is safe in that it does not modify ;; the .newsrc.eld file. (gnus-convert-mark-converter-prompt 'gnus-agent-unhook-expire-days t) + +(provide 'legacy-gnus-agent) + +;;; legacy-gnus-agent.el ends here