* gnus.el (gnus-variable-list): Add gnus-agent-covered-methods.
[gnus] / lisp / gnus-sum.el
index e2ad0c5..2c00b11 100644 (file)
@@ -143,7 +143,7 @@ Useful functions to put in this list include:
   :type '(repeat function))
 
 (defcustom gnus-simplify-ignored-prefixes nil
-  "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
+  "*Remove matches for this regexp from subject lines when simplifying fuzzily."
   :group 'gnus-thread
   :type '(choice (const :tag "off" nil)
                 regexp))
@@ -1043,7 +1043,6 @@ the MIME-Version header is missed."
 (defvar gnus-article-ignored-charsets nil)
 (defvar gnus-scores-exclude-files nil)
 (defvar gnus-page-broken nil)
-(defvar gnus-inhibit-mime-unbuttonizing nil)
 
 (defvar gnus-original-article nil)
 (defvar gnus-article-internal-prepare-hook nil)
@@ -2764,7 +2763,7 @@ The following commands are available:
 
 (defmacro gnus-summary-article-number ()
   "The article number of the article on the current line.
-If there isn's an article number here, then we return the current
+If there isn't an article number here, then we return the current
 article number."
   '(progn
      (gnus-summary-skip-intangible)
@@ -3412,7 +3411,7 @@ If NO-DISPLAY, don't generate a summary buffer."
              (let ((gnus-newsgroup-dormant nil))
                (gnus-summary-initial-limit show-all))
            (gnus-summary-initial-limit show-all))
-       ;; When untreaded, all articles are always shown.
+       ;; When unthreaded, all articles are always shown.
        (setq gnus-newsgroup-limit
              (mapcar
               (lambda (header) (mail-header-number header))
@@ -6148,20 +6147,35 @@ displayed, no centering will be performed."
 
 (defun gnus-summary-toggle-truncation (&optional arg)
   "Toggle truncation of summary lines.
-With arg, turn line truncation on iff arg is positive."
+With arg, turn line truncation on if arg is positive."
   (interactive "P")
   (setq truncate-lines
        (if (null arg) (not truncate-lines)
          (> (prefix-numeric-value arg) 0)))
   (redraw-display))
 
+(defun gnus-summary-find-uncancelled ()
+  "Return the number of an uncancelled article.
+The current article is considered, then following articles, then previous
+articles.  If all articles are cancelled then return a dummy 0."
+  (let (found)
+    (dolist (rev '(nil t))
+      (unless found      ; don't demand the reverse list if we don't need it
+        (let ((data (gnus-data-find-list
+                     (gnus-summary-article-number) (gnus-data-list rev))))
+          (while (and data (not found))
+            (if (not (eq gnus-canceled-mark (gnus-data-mark (car data))))
+                (setq found (gnus-data-number (car data))))
+            (setq data (cdr data))))))
+    (or found 0)))
+
 (defun gnus-summary-reselect-current-group (&optional all rescan)
   "Exit and then reselect the current newsgroup.
 The prefix argument ALL means to select all articles."
   (interactive "P")
   (when (gnus-ephemeral-group-p gnus-newsgroup-name)
     (error "Ephemeral groups can't be reselected"))
-  (let ((current-subject (gnus-summary-article-number))
+  (let ((current-subject (gnus-summary-find-uncancelled))
        (group gnus-newsgroup-name))
     (setq gnus-newsgroup-begin nil)
     (gnus-summary-exit)
@@ -6506,7 +6520,7 @@ in."
    (list
     (when current-prefix-arg
       (completing-read
-       "Faq dir: " (and (listp gnus-group-faq-directory)
+       "FAQ dir: " (and (listp gnus-group-faq-directory)
                        (mapcar (lambda (file) (list file))
                                gnus-group-faq-directory))))))
   (let (gnus-faq-buffer)
@@ -7847,7 +7861,7 @@ of what's specified by the `gnus-refer-thread-limit' variable."
          (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
 
 (defun gnus-refer-article-methods ()
-  "Return a list of referrable methods."
+  "Return a list of referable methods."
   (cond
    ;; No method, so we default to current and native.
    ((null gnus-refer-article-method)
@@ -9385,7 +9399,7 @@ the actual number of articles marked is returned."
 If N is negative, mark backwards instead.  Mark with MARK, ?r by default.
 The difference between N and the actual number of articles marked is
 returned.
-Iff NO-EXPIRE, auto-expiry will be inhibited."
+If NO-EXPIRE, auto-expiry will be inhibited."
   (interactive "p")
   (gnus-summary-show-thread)
   (let ((backward (< n 0))
@@ -9448,7 +9462,8 @@ Iff NO-EXPIRE, auto-expiry will be inhibited."
            (gnus-error 1 "Can't mark negative article numbers")
            nil)
        (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
-       (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
+       (setq gnus-newsgroup-spam-marked
+             (delq article gnus-newsgroup-spam-marked))
        (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
        (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
        (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
@@ -9490,7 +9505,7 @@ Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
 If MARK is nil, then the default character `?r' is used.
 If ARTICLE is nil, then the article on the current line will be
 marked.
-Iff NO-EXPIRE, auto-expiry will be inhibited."
+If NO-EXPIRE, auto-expiry will be inhibited."
   ;; The mark might be a string.
   (when (stringp mark)
     (setq mark (aref mark 0)))
@@ -9615,7 +9630,8 @@ Iff NO-EXPIRE, auto-expiry will be inhibited."
                   (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
            ((= mark gnus-spam-mark)
             (setq gnus-newsgroup-spam-marked
-                  (gnus-add-to-sorted-list gnus-newsgroup-spam-marked article)))
+                  (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
+                                           article)))
            ((= mark gnus-dormant-mark)
             (setq gnus-newsgroup-dormant
                   (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
@@ -9875,7 +9891,9 @@ If ALL is non-nil, also mark ticked and dormant articles as read."
 
   (gnus-summary-position-point))
 (defun gnus-summary-catchup-all (&optional quietly)
-  "Mark all articles in this newsgroup as read."
+  "Mark all articles in this newsgroup as read.
+This command is dangerous.  Normally, you want \\[gnus-summary-catchup]
+instead, which marks only unread articles as read."
   (interactive "P")
   (gnus-summary-catchup t quietly))
 
@@ -9892,7 +9910,9 @@ If QUIETLY is non-nil, no questions will be asked."
       (gnus-summary-exit))))
 
 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
-  "Mark all articles in this newsgroup as read, and then exit."
+  "Mark all articles in this newsgroup as read, and then exit.
+This command is dangerous.  Normally, you want \\[gnus-summary-catchup-and-exit]
+instead, which marks only unread articles as read."
   (interactive "P")
   (gnus-summary-catchup-and-exit t quietly))
 
@@ -10861,32 +10881,44 @@ If REVERSE, save parts that do not match TYPE."
 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
 (defun gnus-summary-highlight-line ()
   "Highlight current line according to `gnus-summary-highlight'."
-  (let* ((list gnus-summary-highlight)
-        (beg (gnus-point-at-bol))
-        (article (gnus-summary-article-number))
-        (score (or (cdr (assq (or article gnus-current-article)
-                              gnus-newsgroup-scored))
-                   gnus-summary-default-score 0))
-        (mark (or (gnus-summary-article-mark) gnus-unread-mark))
-        (inhibit-read-only t)
-        (default gnus-summary-default-score)
-        (default-high gnus-summary-default-high-score)
-        (default-low gnus-summary-default-low-score)
-         (downloaded (and (boundp 'gnus-agent-article-alist)
-                          gnus-agent-article-alist
-                          ;; Optimized for when gnus-summary-highlight-line is called multiple times for articles in ascending order (i.e. initial generation of summary buffer).
-                          (progn 
-                            (if (and (eq gnus-summary-highlight-line-downloaded-alist gnus-agent-article-alist)
-                                     (<= (caar gnus-summary-highlight-line-downloaded-cached) article))
-                                nil
-                              (setq gnus-summary-highlight-line-downloaded-alist  gnus-agent-article-alist
-                                    gnus-summary-highlight-line-downloaded-cached gnus-agent-article-alist))
-                            (let (n)
-                              (while (and (< (caar gnus-summary-highlight-line-downloaded-cached) article)
-                                          (setq n (cdr gnus-summary-highlight-line-downloaded-cached)))
-                                (setq gnus-summary-highlight-line-downloaded-cached n)))
-                            (and (eq (caar gnus-summary-highlight-line-downloaded-cached) article)
-                                 (cdar gnus-summary-highlight-line-downloaded-cached))))))
+  (let*
+      ((list gnus-summary-highlight)
+       (beg (gnus-point-at-bol))
+       (article (gnus-summary-article-number))
+       (score (or (cdr (assq (or article gnus-current-article)
+                            gnus-newsgroup-scored))
+                 gnus-summary-default-score 0))
+       (mark (or (gnus-summary-article-mark) gnus-unread-mark))
+       (inhibit-read-only t)
+       (default gnus-summary-default-score)
+       (default-high gnus-summary-default-high-score)
+       (default-low gnus-summary-default-low-score)
+       (downloaded
+       (and
+        (boundp 'gnus-agent-article-alist)
+        gnus-agent-article-alist
+        (gnus-agent-group-covered-p gnus-newsgroup-name)
+        ;; Optimized for when gnus-summary-highlight-line is
+        ;; called multiple times for articles in ascending
+        ;; order (i.e. initial generation of summary buffer).
+        (progn 
+          (unless (and
+                   (eq gnus-summary-highlight-line-downloaded-alist
+                       gnus-agent-article-alist)
+                   (<= (caar gnus-summary-highlight-line-downloaded-cached)
+                       article))
+            (setq gnus-summary-highlight-line-downloaded-alist
+                  gnus-agent-article-alist)
+            (setq gnus-summary-highlight-line-downloaded-cached
+                  gnus-agent-article-alist))
+          (let (n)
+            (while (and (< (caar gnus-summary-highlight-line-downloaded-cached)
+                           article)
+                        (setq n (cdr gnus-summary-highlight-line-downloaded-cached)))
+              (setq gnus-summary-highlight-line-downloaded-cached n)))
+          (and (eq (caar gnus-summary-highlight-line-downloaded-cached)
+                   article)
+               (cdar gnus-summary-highlight-line-downloaded-cached))))))
     (let ((face (funcall (gnus-summary-highlight-line-0))))
       (unless (eq face (get-text-property beg 'face))
        (gnus-put-text-property-excluding-characters-with-faces
@@ -11174,34 +11206,32 @@ If ALL is a number, fetch this number of articles."
       (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
            older len)
        (setq older
-;;; Some nntp servers lie about their active range.  When this happens, the active range can be in the millions.  
-;;;          (gnus-sorted-difference
-;;;           (gnus-uncompress-range (list gnus-newsgroup-active))
-;;;           old)
-             (gnus-range-difference
-              (gnus-remove-from-range (list gnus-newsgroup-active) old))
-)
+             ;; Some nntp servers lie about their active range.  When this happens, the active
+             ;; range can be in the millions.
+             ;; Use a compressed range to avoid creating a huge list.
+             (gnus-range-difference (list gnus-newsgroup-active) old))
        (setq len (gnus-range-length older))
        (cond
         ((null older) nil)
         ((numberp all)
          (if (< all len)
-              (let ((older-range (nreverse older)))
-                (setq older nil)
-
-                (while (> all 0)
-                  (let* ((r (pop older-range))
-                         (min (if (numberp r) r (car r)))
-                         (max (if (numberp r) r (cdr r))))
-                    (while (and (<= min max)
-                                (> all 0))
-                      (push max older)
-                      (setq all (1- all)
-                            max (1- max))))))
-            (setq older (gnus-uncompress-range older))))
-        (all nil)
+             (let ((older-range (nreverse older)))
+               (setq older nil)
+
+               (while (> all 0)
+                 (let* ((r (pop older-range))
+                        (min (if (numberp r) r (car r)))
+                        (max (if (numberp r) r (cdr r))))
+                   (while (and (<= min max)
+                               (> all 0))
+                     (push max older)
+                     (setq all (1- all)
+                           max (1- max))))))
+           (setq older (gnus-uncompress-range older))))
+        (all
+         (setq older (gnus-uncompress-range older)))
         (t
-         (if (and (numberp gnus-large-newsgroup)
+         (when (and (numberp gnus-large-newsgroup)
                   (> len gnus-large-newsgroup))
              (let* ((cursor-in-echo-area nil)
                     (initial (gnus-parameter-large-newsgroup-initial
@@ -11220,19 +11250,19 @@ If ALL is a number, fetch this number of articles."
                (unless (string-match "^[ \t]*$" input)
                  (setq all (string-to-number input))
                  (if (< all len)
-                      (let ((older-range (nreverse older)))
-                        (setq older nil)
-
-                        (while (> all 0)
-                          (let* ((r (pop older-range))
-                                 (min (if (numberp r) r (car r)))
-                                 (max (if (numberp r) r (cdr r))))
-                            (while (and (<= min max)
-                                        (> all 0))
-                              (push max older)
-                              (setq all (1- all)
-                                    max (1- max))))))
-                    (setq older (gnus-uncompress-range older))))))))
+                     (let ((older-range (nreverse older)))
+                       (setq older nil)
+
+                       (while (> all 0)
+                         (let* ((r (pop older-range))
+                                (min (if (numberp r) r (car r)))
+                                (max (if (numberp r) r (cdr r))))
+                           (while (and (<= min max)
+                                       (> all 0))
+                             (push max older)
+                             (setq all (1- all)
+                                   max (1- max))))))))))
+         (setq older (gnus-uncompress-range older))))
        (if (not older)
            (message "No old news.")
          (gnus-summary-insert-articles older)