2004-03-03 Per Abrahamsen <abraham@dina.kvl.dk>
[gnus] / lisp / gnus-agent.el
index 1c54c9e..a565146 100644 (file)
@@ -1,5 +1,5 @@
 ;;; gnus-agent.el --- unplugged support for Gnus
-;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
+;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
 ;;        Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
@@ -144,9 +144,9 @@ If this is `ask' the hook will query the user."
   :group 'gnus-agent)
 
 (defcustom gnus-agent-consider-all-articles nil
-  "When non-`nil', the agent will let the agent predicate decide
+  "When non-nil, the agent will let the agent predicate decide
 whether articles need to be downloaded or not, for all articles.  When
-`nil', the default, the agent will only let the predicate decide
+nil, the default, the agent will only let the predicate decide
 whether unread articles are downloaded or not.  If you enable this,
 groups with large active ranges may open slower and you may also want
 to look into the agent expiry settings to block the expiration of
@@ -189,9 +189,9 @@ See Info node `(gnus)Server Buffer'."
   :group 'gnus-agent)
 
 (defcustom gnus-agent-queue-mail t
-  "Whether and when outgoing mail should be queued by the agent.  When
-`always', always queue outgoing mail.  When `nil', never queue.
-Otherwise, queue if and only if unplugged."
+  "Whether and when outgoing mail should be queued by the agent.
+When `always', always queue outgoing mail.  When nil, never
+queue.  Otherwise, queue if and only if unplugged."
   :group 'gnus-agent
   :type '(radio (const :format "Always" always)
                (const :format "Never" nil)
@@ -961,11 +961,9 @@ article's mark is toggled."
              (setq gnus-newsgroup-downloadable
                    (delq article gnus-newsgroup-downloadable))
              (gnus-article-mark article))
-         (progn
-           (setq gnus-newsgroup-downloadable
-                 (gnus-add-to-sorted-list gnus-newsgroup-downloadable article))
-           gnus-downloadable-mark)
-         )
+        (setq gnus-newsgroup-downloadable
+              (gnus-add-to-sorted-list gnus-newsgroup-downloadable article))
+        gnus-downloadable-mark)
        'unread))))
 
 (defun gnus-agent-get-undownloaded-list ()
@@ -1854,54 +1852,56 @@ modified) original contents, they are first saved to their own file."
 
 (defun gnus-agent-read-local (file)
   "Load FILE and do a `read' there."
-  (let ((obarray (gnus-make-hashtable (count-lines (point-min) (point-max))))
+  (let ((my-obarray (gnus-make-hashtable (count-lines (point-min) 
+                                                      (point-max))))
         (line 1))
-        (with-temp-buffer
-          (condition-case nil
-              (nnheader-insert-file-contents file)
-            (file-error))
+    (with-temp-buffer
+      (condition-case nil
+          (nnheader-insert-file-contents file)
+        (file-error))
 
-          (goto-char (point-min))
-          ;; Skip any comments at the beginning of the file (the only place where they may appear)
-          (while (= (following-char) ?\;)
-            (forward-line 1)
-            (setq line (1+ line)))
-
-          (while (not (eobp))
-            (condition-case err
-                (let (group 
-                      min
-                      max
-                      (cur (current-buffer)))
-                  (setq group (read cur)
-                        min (read cur)
-                        max (read cur))
-
-                  (when (stringp group)
-                    (setq group (intern group obarray)))
-
-                  ;; NOTE: The '+ 0' ensure that min and max are both numerics.
-                  (set group (cons (+ 0 min) (+ 0 max))))
-              (error
-               (gnus-message 3 "Warning - invalid agent local: %s on line %d: " file line (error-message-string err))))
-            (forward-line 1)
-            (setq line (1+ line))))
+      (goto-char (point-min))
+      ;; Skip any comments at the beginning of the file (the only place where they may appear)
+      (while (= (following-char) ?\;)
+        (forward-line 1)
+        (setq line (1+ line)))
+
+      (while (not (eobp))
+        (condition-case err
+            (let (group 
+                  min
+                  max
+                  (cur (current-buffer)))
+              (setq group (read cur)
+                    min (read cur)
+                    max (read cur))
+
+              (when (stringp group)
+                (setq group (intern group my-obarray)))
+
+              ;; NOTE: The '+ 0' ensure that min and max are both numerics.
+              (set group (cons (+ 0 min) (+ 0 max))))
+          (error
+           (gnus-message 3 "Warning - invalid agent local: %s on line %d: "
+                         file line (error-message-string err))))
+        (forward-line 1)
+        (setq line (1+ line))))
       
-    (set (intern "+dirty" obarray) nil)
-    (set (intern "+method" obarray) gnus-command-method)
-    obarray))
+    (set (intern "+dirty" my-obarray) nil)
+    (set (intern "+method" my-obarray) gnus-command-method)
+    my-obarray))
 
 (defun gnus-agent-save-local (&optional force)
   "Save gnus-agent-article-local under it method's agent.lib directory."
-  (let ((obarray gnus-agent-article-local))
-    (when (and obarray
-               (or force (symbol-value (intern "+dirty" obarray))))
-      (let* ((gnus-command-method (symbol-value (intern "+method" obarray)))
+  (let ((my-obarray gnus-agent-article-local))
+    (when (and my-obarray
+               (or force (symbol-value (intern "+dirty" my-obarray))))
+      (let* ((gnus-command-method (symbol-value (intern "+method" my-obarray)))
              ;; NOTE: gnus-command-method is used within gnus-agent-lib-file.
              (dest (gnus-agent-lib-file "local")))
         (gnus-make-directory (gnus-agent-lib-file ""))
         (with-temp-file dest
-          (let ((gnus-command-method (symbol-value (intern "+method" obarray)))
+          (let ((gnus-command-method (symbol-value (intern "+method" my-obarray)))
                 (file-name-coding-system nnmail-pathname-coding-system)
                 (coding-system-for-write
                  gnus-agent-file-coding-system)
@@ -1919,7 +1919,8 @@ modified) original contents, they are first saved to their own file."
                                  (princ (car range))
                                  (princ " ")
                                  (princ (cdr range))
-                                 (princ "\n"))))))))))))
+                                 (princ "\n"))))) 
+                      my-obarray)))))))
 
 (defun gnus-agent-get-local (group)
   (let* ((gmane (gnus-group-real-name group))
@@ -3514,12 +3515,11 @@ If REREAD is not nil, downloaded articles are marked as unread."
  entries contained line that did not begin with an article number.  Deleted\
  line.")
                        (gnus-delete-line))))
-              (if load
-                  (progn
-                    (gnus-message 5 "gnus-agent-regenerate-group: Sorting NOV\
+              (when load
+               (gnus-message 5 "gnus-agent-regenerate-group: Sorting NOV\
  entries into ascending order.")
-                    (sort-numeric-fields 1 (point-min) (point-max))
-                    (setq nov-arts nil)))))
+               (sort-numeric-fields 1 (point-min) (point-max))
+               (setq nov-arts nil))))
           (gnus-agent-check-overview-buffer)
 
           ;; Construct a new article alist whose nodes match every header