Synch to No Gnus 200403090710.
authoryamaoka <yamaoka>
Tue, 9 Mar 2004 07:16:04 +0000 (07:16 +0000)
committeryamaoka <yamaoka>
Tue, 9 Mar 2004 07:16:04 +0000 (07:16 +0000)
ChangeLog
lisp/ChangeLog
lisp/gnus-agent.el
lisp/gnus-int.el
lisp/gnus-start.el
lisp/legacy-gnus-agent.el [new file with mode: 0644]
make.bat

index 2f6dcbe..82b7a81 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,11 @@
+2004-03-08  Kevin Greiner <kgreiner@xpediantsolutions.com>
+
+       * make.bat: Make sure that gnus-load.el and sieve are writable to
+       avoid breakage.
+
 2004-03-04  KOSEKI Yoshinori  <kose@meadowy.org>
 
-       * gnus-namazu.el (gnus-namazu-command-prefix): New variable.
+       * lisp/gnus-namazu.el (gnus-namazu-command-prefix): New variable.
        (gnus-namazu-imap-group-prefix): Ditto.
        (gnus-namazu/directory-table-use): Ditto.
        (gnus-namazu/call-namazu): Use gnus-namazu-imap-group-prefix.
index 0d040ef..021c23d 100644 (file)
@@ -1,3 +1,26 @@
+2004-03-08  Kevin Greiner <kgreiner@xpediantsolutions.com>
+
+       * gnus-agent.el (gnus-agent-read-agentview): Removed support for
+       old file versions.
+       (gnus-group-prepare-hook): Removed function that converted list
+       form of gnus-agent-expire-days to group properties.
+
+       * gnus-int.el: Autoload gnus-agent-regenerate-group.
+       (gnus-request-accept-article): Re-indented.
+
+       * gnus-start.el (gnus-convert-old-newsrc): Registered new
+       converters to handle old agent file formats.  Added logic for a
+       "backup before upgrading warning".
+       (gnus-convert-mark-converter-prompt): Developers can mark
+       functions as needing (default), or not needing,
+       gnus-convert-old-newsrc's "backup before upgrading warning".
+       (gnus-convert-converter-needs-prompt): Tests whether the user
+       should be protected from potentially irreversable changes by the
+       function.
+
+       * legacy-gnus-agent.el (): New. Provides converters that are only
+       loaded when gnus-convert-old-newsrc needs to call them.
+       
 2004-03-08  Katsumi Yamaoka  <yamaoka@jpl.org>
 
        * mail-source.el (mail-source-touch-pop): Doc fix.
index ac2ea8b..0119432 100644 (file)
@@ -1747,7 +1747,8 @@ FILE and places the combined headers into `nntp-server-buffer'."
 (defun gnus-agent-read-agentview (file)
   "Load FILE and do a `read' there."
   (with-temp-buffer
-    (ignore-errors
+    (condition-case nil
+      (progn
         (nnheader-insert-file-contents file)
         (goto-char (point-min))
         (let ((alist (read (current-buffer)))
@@ -1756,6 +1757,8 @@ FILE and places the combined headers into `nntp-server-buffer'."
               changed-version)
 
           (cond
+           ((< version 2)
+            (error "gnus-agent-read-agentview no longer supports version %d.  Stop gnus, manually evaluate gnus-agent-convert-to-compressed-agentview, then restart gnus."))
            ((= version 0)
             (let ((inhibit-quit t)
                   entry)
@@ -1789,7 +1792,8 @@ FILE and places the combined headers into `nntp-server-buffer'."
           (when changed-version
             (let ((gnus-agent-article-alist alist))
               (gnus-agent-save-alist gnus-agent-read-agentview)))
-        alist))))
+          alist))
+      (file-error nil))))
 
 (defun gnus-agent-save-alist (group &optional articles state)
   "Save the article-state alist for GROUP."
@@ -3475,7 +3479,6 @@ If REREAD is not nil, downloaded articles are marked as unread."
                     (gnus-message 3 "Ignoring unexpected input")
                     (sit-for 1)
                     t)))))
-
   (when group
       (gnus-message 5 "Regenerating in %s" group)
       (let* ((gnus-command-method (or gnus-command-method
@@ -3710,49 +3713,6 @@ If CLEAN, obsolete (ignore)."
 (defun gnus-agent-group-covered-p (group)
   (gnus-agent-method-p (gnus-group-method group)))
 
-(add-hook 'gnus-group-prepare-hook
-          (lambda ()
-            'gnus-agent-do-once
-
-            (when (listp gnus-agent-expire-days)
-              (beep)
-              (beep)
-              (gnus-message 1 "WARNING: gnus-agent-expire-days no longer\
- supports being set to a list.")(sleep-for 3)
-              (gnus-message 1 "Change your configuration to set it to an\
- integer.")(sleep-for 3)
-              (gnus-message 1 "I am now setting group parameters on each\
- group to match the configuration that the list offered.")
-
-              (save-excursion
-                (let ((groups (gnus-group-listed-groups)))
-                  (while groups
-                    (let* ((group (pop groups))
-                           (days gnus-agent-expire-days)
-                           (day (catch 'found
-                                  (while days
-                                    (when (eq 0 (string-match
-                                                 (caar days)
-                                                 group))
-                                      (throw 'found (cadar days)))
-                                    (setq days (cdr days)))
-                                  nil)))
-                      (when day
-                        (gnus-group-set-parameter group 'agent-days-until-old
-                                                  day))))))
-
-              (let ((h gnus-group-prepare-hook))
-                (while h
-                  (let ((func (pop h)))
-                    (when (and (listp func)
-                               (eq (cadr (caddr func)) 'gnus-agent-do-once))
-                      (remove-hook 'gnus-group-prepare-hook func)
-                      (setq h nil)))))
-
-              (gnus-message 1 "I have finished setting group parameters on\
- each group. You may now customize your groups and/or topics to control the\
- agent."))))
-
 (provide 'gnus-agent)
 
 ;;; gnus-agent.el ends here
index c25727c..96694cb 100644 (file)
@@ -34,6 +34,7 @@
 (require 'gnus-range)
 
 (autoload 'gnus-agent-expire "gnus-agent")
+(autoload 'gnus-agent-regenerate-group "gnus-agent")
 (autoload 'gnus-agent-read-servers-validate-native "gnus-agent")
 
 (defcustom gnus-open-server-hook nil
@@ -586,10 +587,12 @@ If GROUP is nil, all groups on GNUS-COMMAND-METHOD are scanned."
     (insert "\n"))
   (let ((gnus-command-method (or gnus-command-method
                                 (gnus-find-method-for-group group)))
-    (result (funcall (gnus-get-function gnus-command-method 'request-accept-article)
-            (if (stringp group) (gnus-group-real-name group) group)
-            (cadr gnus-command-method)
-            last)))
+       (result 
+        (funcall 
+         (gnus-get-function gnus-command-method 'request-accept-article)
+         (if (stringp group) (gnus-group-real-name group) group)
+         (cadr gnus-command-method)
+         last)))
     (when (and gnus-agent (gnus-agent-method-p gnus-command-method))
       (gnus-agent-regenerate-group group (list (cdr result))))
     result))
index 7db9bb9..4e154d6 100644 (file)
@@ -2235,7 +2235,8 @@ If FORCE is non-nil, the .newsrc file is read."
                  (gnus-continuum-version gnus-newsrc-file-version))))
     (when fcv
       ;; A .newsrc.eld file was loaded.
-      (let ((converters
+      (let (prompt-displayed
+            (converters
              (sort
               (mapcar (lambda (date-func)
                         (cons (gnus-continuum-version (car date-func))
@@ -2249,47 +2250,68 @@ If FORCE is non-nil, the .newsrc file is read."
                       ;; doesn't change with each release) and the
                       ;; function that must be applied to convert the
                       ;; previous version into the current version.
-                      '(("September Gnus v0.1" nil gnus-convert-old-ticks)))
+                      '(("September Gnus v0.1" nil 
+                         gnus-convert-old-ticks)
+                        ("Oort Gnus v0.08"     "legacy-gnus-agent"
+                         gnus-agent-convert-to-compressed-agentview)
+                        ("No Gnus v0.2"        "legacy-gnus-agent"
+                         gnus-agent-unlist-expire-days)
+                        ("No Gnus v0.2"        "legacy-gnus-agent" 
+                         gnus-agent-unhook-expire-days)))
               #'car-less-than-car)))
         ;; Skip converters older than the file version
         (while (and converters (>= fcv (caar converters)))
           (pop converters))
 
         ;; Perform converters to bring older version up to date.
-        (when (and converters 
-                   (< fcv (caar converters)))
-          (while (let (c
-                       (cursor-in-echo-area t)
-                       (echo-keystrokes 0))
-                   (message "Convert newsrc from version '%s' to '%s'? (n/y/?)"
-                            gnus-newsrc-file-version gnus-version)
-                   (setq c (read-char-exclusive))
-
-                   (cond ((or (eq c ?n) (eq c ?N))
-                          (error "Can not start gnus using old (unconverted) newsrc"))
-                         ((or (eq c ?y) (eq c ?Y))
-                          nil)
-                         ((eq c ?\?)
-                          (message "This conversion is irreversible. \
- You should backup your files before proceeding.")
-                          (sit-for 5)
-                          t)
-                         (t
-                          (gnus-message 3 "Ignoring unexpected input")
-                          (sit-for 3)
-                          t))))
-          (while (and converters (< fcv (caar converters)))
-            (let* ((converter  (pop converters))
-                   (convert-to (nth 1 converter))
-                   (load-from  (nth 2 converter))
-                   (func       (nth 3 converter)))
+        (while (and converters (< fcv (caar converters)))
+            (let* ((converter-spec  (pop converters))
+                   (convert-to      (nth 1 converter-spec))
+                   (load-from       (nth 2 converter-spec))
+                   (func            (nth 3 converter-spec)))
               (when (and load-from
                          (not (fboundp func)))
                 (load load-from t))
+              
+              (or prompt-displayed
+                  (not (gnus-convert-converter-needs-prompt func))
+                  (while (let (c
+                               (cursor-in-echo-area t)
+                               (echo-keystrokes 0))
+                           (message "Convert newsrc from version '%s' to '%s'? (n/y/?)"
+                                    gnus-newsrc-file-version gnus-version)
+                           (setq c (read-char-exclusive))
+
+                           (cond ((or (eq c ?n) (eq c ?N))
+                                  (error "Can not start gnus using old (unconverted) newsrc"))
+                                 ((or (eq c ?y) (eq c ?Y))
+                                  (setq prompt-displayed t)
+                                  nil)
+                                 ((eq c ?\?)
+                                  (message "This conversion is irreversible. \
+ You should backup your files before proceeding.")
+                                  (sit-for 5)
+                                  t)
+                                 (t
+                                  (gnus-message 3 "Ignoring unexpected input")
+                                  (sit-for 3)
+                                  t)))))
+
               (funcall func convert-to)))
           (gnus-dribble-enter 
            (format ";Converted newsrc from version '%s' to '%s'? (n/y/?)"
-                   gnus-newsrc-file-version gnus-version)))))))
+                   gnus-newsrc-file-version gnus-version))))))
+
+(defun gnus-convert-mark-converter-prompt (converter no-prompt)
+  (setplist converter
+            (let* ((symbol 'gnus-convert-no-prompt)
+                   (value (delq symbol (symbol-plist converter))))
+            (if no-prompt
+                (cons symbol value)
+              value))))
+
+(defun gnus-convert-converter-needs-prompt (converter)
+  (not (memq 'gnus-convert-no-prompt (symbol-plist converter))))
 
 (defun gnus-convert-old-ticks (converting-to)
   (let ((newsrc (cdr gnus-newsrc-alist))
diff --git a/lisp/legacy-gnus-agent.el b/lisp/legacy-gnus-agent.el
new file mode 100644 (file)
index 0000000..a09bfa4
--- /dev/null
@@ -0,0 +1,211 @@
+(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.
+
+(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))
+        here
+        members
+        member
+        converted-something)
+    (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))
+              ((equal (file-name-nondirectory member) ".agentview")
+               (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-agentview (file)
+  "Load FILE and do a `read' there."
+  (with-temp-buffer
+      (nnheader-insert-file-contents file)
+      (goto-char (point-min))
+      (let ((inhibit-quit t)
+            (alist (read (current-buffer)))
+            (version (condition-case nil (read (current-buffer))
+                       (end-of-file 0)))
+            changed-version
+            history-file)
+
+        (cond
+        ((= version 0)
+         (let (entry
+                (gnus-command-method nil))
+            (mm-disable-multibyte) ;; everything is binary
+            (erase-buffer)
+            (insert "\n")
+            (let ((file (concat (file-name-directory file) "/history")))
+              (when (file-exists-p file)
+                (nnheader-insert-file-contents file)
+                (setq history-file file)))
+
+           (goto-char (point-min))
+           (while (not (eobp))
+             (if (and (looking-at
+                       "[^\t\n]+\t\\([0-9]+\\)\t\\([^ \n]+\\) \\([0-9]+\\)")
+                      (string= (gnus-agent-article-name ".agentview" (match-string 2))
+                               file)
+                      (setq entry (assoc (string-to-number (match-string 3)) alist)))
+                 (setcdr entry (string-to-number (match-string 1))))
+             (forward-line 1))
+           (setq changed-version t)))
+        ((= version 1)
+         (setq changed-version t)))
+
+        (when changed-version
+          (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)
+            (princ compressed (current-buffer)))
+          (insert "\n2\n")
+          (write-file file)
+          (when history-file
+            (delete-file history-file))
+          t))))
+
+;; End of Oort Gnus v0.08 updates
+
+;; No Gnus v0.3 - This release provides a mechanism for upgrading gnus
+;;                from previous versions.  Therefore, the previous
+;;                hacks to handle a gnus-agent-expire-days that
+;;                specifies a list of values can be removed.
+
+(defun gnus-agent-unlist-expire-days (converting-to)
+  (when (listp gnus-agent-expire-days)
+    (let (buffer)
+      (unwind-protect
+          (save-window-excursion
+            (setq buffer (gnus-get-buffer-create " *Gnus agent upgrade*"))
+            (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)))
+
+            (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")
+            (insert "expiration days to individual groups, you must instead set the\n")
+            (insert "'agent-days-until-old group and/or topic parameter.\n")
+            (insert "\n")
+            (insert "If you would like, gnus can iterate over every group comparing its name to the\n")
+            (insert "regular expressions that you currently have in gnus-agent-expire-days.  When\n")
+            (insert "gnus finds a match, it will update that group's 'agent-days-until-old group\n")
+            (insert "parameter to the value associated with the regular expression.\n")
+            (insert "\n")
+            (insert "Whether gnus assigns group parameters, or not, gnus will terminate with an\n")
+            (insert "ERROR as soon as this function completes.  The reason is that you must\n")
+            (insert "manually edit your configuration to either not set gnus-agent-expire-days or\n")
+            (insert "to set it to an integer before gnus can be used.\n")
+            (insert "\n")
+            (insert "Once you have successfully edited gnus-agent-expire-days, gnus will be able to\n")
+            (insert "execute past this function.\n")
+            (insert "\n")
+            (insert "Should gnus use gnus-agent-expire-days to assign\n")
+            (insert "agent-days-until-old parameters to individual groups? (Y/N)")
+
+            (switch-to-buffer buffer)
+            (beep)
+            (beep)
+
+            (let ((echo-keystrokes 0)
+                  c)
+              (while (progn (setq c (read-char-exclusive))
+                            (cond ((or (eq c ?y) (eq c ?Y))
+                                         (save-excursion
+                                           (let ((groups (gnus-group-listed-groups)))
+                                             (while groups
+                                               (let* ((group (pop groups))
+                                                      (days gnus-agent-expire-days)
+                                                      (day (catch 'found
+                                                             (while days
+                                                               (when (eq 0 (string-match
+                                                                            (caar days)
+                                                                            group))
+                                                                 (throw 'found (cadar days)))
+                                                               (setq days (cdr days)))
+                                                             nil)))
+                                                 (when day
+                                                   (gnus-group-set-parameter group 'agent-days-until-old
+                                                                             day))))))
+                                   nil
+                                   )
+                                  ((or (eq c ?n) (eq c ?N))
+                                   nil)
+                                  (t
+                                   t))))))
+        (kill-buffer buffer))
+      (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.
+(gnus-convert-mark-converter-prompt 'gnus-agent-unlist-expire-days t)
+
+(defun gnus-agent-unhook-expire-days (converting-to)
+  "Remove every lambda from gnus-group-prepare-hook that mention the
+symbol gnus-agent-do-once in their definition.  This should NOT be
+necessary as gnus-agent.el no longer adds them.  However, it is
+possible that the hook was persistently saved."
+    (let ((h t)) ; iterate from bgn of hook
+      (while h
+        (let ((func (progn (when (eq h t)
+                             ;; init h to list of functions
+                             (setq h (cond ((listp gnus-group-prepare-hook)
+                                            gnus-group-prepare-hook)
+                                           ((boundp 'gnus-group-prepare-hook)
+                                            (list gnus-group-prepare-hook)))))
+                           (pop h))))
+
+          (when (cond ((eq (type-of func) 'compiled-function)
+                       ;; Search def. of compiled function for gnus-agent-do-once string
+                       (let* (definition 
+                               print-level 
+                               print-length
+                               (standard-output
+                                (lambda (char)
+                                  (setq definition (cons char definition)))))
+                         (princ func) ; populates definition with reversed list of characters
+                         (let* ((i (length definition))
+                                (s (make-string i 0)))
+                           (while definition
+                             (aset s (setq i (1- i)) (pop definition)))
+
+                           (string-match "\\bgnus-agent-do-once\\b" s))))
+                      ((listp func)
+                       (eq (cadr (nth 2 func)) 'gnus-agent-do-once) ; handles eval'd lambda
+                       ))
+
+            (remove-hook 'gnus-group-prepare-hook func)
+            ;; I don't what remove-hook is going to actually do to the
+            ;; hook list so start over from the beginning.
+            (setq h t))))))
+
+;; 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)
index 75418da..dae69a8 100755 (executable)
--- a/make.bat
+++ b/make.bat
@@ -70,6 +70,7 @@ goto lisp
 :lisp\r
 set EMACSBATCH=call %1\%EMACS% %EMACS_ARGS%\r
 cd lisp\r
+attrib -r gnus-load.el\r
 if exist gnus-load.el del gnus-load.el\r
 echo.\r
 echo Stand by while generating autoloads.\r
@@ -97,7 +98,9 @@ goto infotest
 \r
 :infotest\r
 cd ..\texi\r
+attrib -r sieve\r
 if exist sieve del sieve\r
+\r
 makeinfo sieve.texi\r
 if exist sieve goto minfo\r
 REM It seems that makeinfo isn't available\r