*** empty log message ***
[gnus] / lisp / gnus-sum.el
index 9489614..fe53b12 100644 (file)
@@ -738,6 +738,10 @@ mark:    The articles mark."
   :type '(repeat (cons (sexp :tag "Form" nil)
                       face)))
 
+(defcustom gnus-alter-header-function nil
+  "Function called to allow alteration of article header structures.
+The function is called with one parameter, the article header vector,
+which it may alter in any way.")
 
 ;;; Internal variables
 
@@ -2519,9 +2523,10 @@ If NO-DISPLAY, don't generate a summary buffer."
     (while (and group
                (null (setq result
                            (let ((gnus-auto-select-next nil))
-                             (gnus-summary-read-group-1
-                              group show-all no-article
-                              kill-buffer no-display))))
+                             (or (gnus-summary-read-group-1
+                                  group show-all no-article
+                                  kill-buffer no-display)
+                                 (setq show-all nil)))))
                (eq gnus-auto-select-next 'quietly))
       (set-buffer gnus-group-buffer)
       (if (not (equal group (gnus-group-group-name)))
@@ -2877,15 +2882,17 @@ If NO-DISPLAY, don't generate a summary buffer."
          (while (search-backward ">" nil t)
            (setq end (1+ (point)))
            (when (search-backward "<" nil t)
-             (push (list (incf generation)
-                         child (setq child (buffer-substring (point) end))
-                         subject)
-                   relations)))
+             (unless (string= (setq new-child (buffer-substring (point) end))
+                              child)
+               (push (list (incf generation)
+                           child (setq child new-child)
+                           subject)
+                     relations))))
          (push (list (1+ generation) child nil subject) relations)
          (erase-buffer)))
       (kill-buffer (current-buffer)))
     ;; Sort over trustworthiness.
-    (setq relations (sort relations (lambda (r1 r2) (< (car r1) (car r2)))))
+    (setq relations (sort relations 'car-less-than-car))
     (while (setq relation (pop relations))
       (when (if (boundp (setq cthread (intern (cadr relation) deps)))
                (unless (car (symbol-value cthread))
@@ -4079,13 +4086,10 @@ The resulting hash table is returned, or nil if no Xrefs were found."
                  (gnus-group-make-articles-read name idlist))))
         xref-hashtb)))))
 
-(defun gnus-group-make-articles-read (group articles)
-  "Update the info of GROUP to say that ARTICLES are read."
-  (let* ((num 0)
-        (entry (gnus-gethash group gnus-newsrc-hashtb))
+(defun gnus-compute-read-articles (group articles)
+  (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
         (info (nth 2 entry))
-        (active (gnus-active group))
-        range)
+        (active (gnus-active group)))
     (when entry
       ;; First peel off all illegal article numbers.
       (when active
@@ -4106,6 +4110,25 @@ The resulting hash table is returned, or nil if no Xrefs were found."
            (when (or (> id (cdr active))
                      (< id (car active)))
              (setq articles (delq id articles))))))
+      ;; If the read list is nil, we init it.
+      (if (and active
+              (null (gnus-info-read info))
+              (> (car active) 1))
+         (setq ninfo (cons 1 (1- (car active))))
+       (setq ninfo (gnus-info-read info)))
+      ;; Then we add the read articles to the range.
+      (gnus-add-to-range
+       ninfo (setq articles (sort articles '<))))))
+  
+(defun gnus-group-make-articles-read (group articles)
+  "Update the info of GROUP to say that ARTICLES are read."
+  (let* ((num 0)
+        (entry (gnus-gethash group gnus-newsrc-hashtb))
+        (info (nth 2 entry))
+        (active (gnus-active group))
+        range)
+    (when entry
+      (setq range (gnus-compute-read-articles group articles))
       (save-excursion
        (set-buffer gnus-group-buffer)
        (gnus-undo-register
@@ -4114,17 +4137,8 @@ The resulting hash table is returned, or nil if no Xrefs were found."
             (gnus-info-set-read ',info ',(gnus-info-read info))
             (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
             (gnus-group-update-group ,group t))))
-      ;; If the read list is nil, we init it.
-      (and active
-          (null (gnus-info-read info))
-          (> (car active) 1)
-          (gnus-info-set-read info (cons 1 (1- (car active)))))
-      ;; Then we add the read articles to the range.
-      (gnus-info-set-read
-       info
-       (setq range
-            (gnus-add-to-range
-             (gnus-info-read info) (setq articles (sort articles '<)))))
+      ;; Add the read articles to the range.
+      (gnus-info-set-read info range)
       ;; Then we have to re-compute how many unread
       ;; articles there are in this group.
       (when active
@@ -4268,6 +4282,12 @@ The resulting hash table is returned, or nil if no Xrefs were found."
                   (nnheader-header-value)))))
          (when (equal id ref)
            (setq ref nil))
+
+         (when gnus-alter-header-function
+           (funcall gnus-alter-header-function header)
+           (setq id (mail-header-id header)
+                 ref (gnus-parent-id (mail-header-references header))))
+    
          ;; We do the threading while we read the headers.  The
          ;; message-id and the last reference are both entered into
          ;; the same hash table.  Some tippy-toeing around has to be
@@ -4345,11 +4365,10 @@ The resulting hash table is returned, or nil if no Xrefs were found."
          (setq header
                (vector
                 number                 ; number
-                ;; 1997/5/4 by MORIOKA Tomohiko <morioka@jaist.ac.jp>
                 (funcall
                  gnus-unstructured-field-decoder (gnus-nov-field)) ; subject
                 (funcall
-                 gnus-structured-field-decoder (gnus-nov-field))   ; from
+                 gnus-structured-field-decoder (gnus-nov-field)) ; from
                 (gnus-nov-field)       ; date
                 (setq id (or (gnus-nov-field)
                              (nnheader-generate-fake-message-id))) ; id
@@ -4372,6 +4391,11 @@ The resulting hash table is returned, or nil if no Xrefs were found."
 
       (widen))
 
+    (when gnus-alter-header-function
+      (funcall gnus-alter-header-function header)
+      (setq id (mail-header-id header)
+           ref (gnus-parent-id (mail-header-references header))))
+    
     ;; We build the thread tree.
     (when (equal id ref)
       ;; This article refers back to itself.  Naughty, naughty.
@@ -5693,21 +5717,25 @@ Return nil if there are no articles."
       (gnus-summary-goto-subject article))))
 
 (defun gnus-summary-goto-article (article &optional all-headers force)
-  "Fetch ARTICLE and display it if it exists.
+  "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
 If ALL-HEADERS is non-nil, no header lines are hidden."
   (interactive
    (list
-    (string-to-int
-     (completing-read
-      "Article number: "
-      (mapcar (lambda (number) (list (int-to-string number)))
-             gnus-newsgroup-limit)))
+    (completing-read
+     "Article number or Message-ID: "
+     (mapcar (lambda (number) (list (int-to-string number)))
+            gnus-newsgroup-limit))
     current-prefix-arg
     t))
   (prog1
-      (if (gnus-summary-goto-subject article force)
-         (gnus-summary-display-article article all-headers)
-       (gnus-message 4 "Couldn't go to article %s" article) nil)
+      (if (and (stringp article)
+              (string-match "@" article))
+         (gnus-summary-refer-article article)
+       (when (stringp article)
+         (setq article (string-to-number article)))
+       (if (gnus-summary-goto-subject article force)
+           (gnus-summary-display-article article all-headers)
+         (gnus-message 4 "Couldn't go to article %s" article) nil))
     (gnus-summary-position-point)))
 
 (defun gnus-summary-goto-last-article ()
@@ -8692,7 +8720,7 @@ save those articles instead."
          (funcall gnus-summary-highlight-line-function article face))))
     (goto-char p)))
 
-(defun gnus-update-read-articles (group unread)
+(defun gnus-update-read-articles (group unread &optional compute)
   "Update the list of read articles in GROUP."
   (let* ((active (or gnus-newsgroup-active (gnus-active group)))
         (entry (gnus-gethash group gnus-newsrc-hashtb))
@@ -8724,20 +8752,22 @@ save those articles instead."
        (setq unread (cdr unread)))
       (when (<= prev (cdr active))
        (push (cons prev (cdr active)) read))
-      (save-excursion
-       (set-buffer gnus-group-buffer)
-       (gnus-undo-register
-         `(progn
-            (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
-            (gnus-info-set-read ',info ',(gnus-info-read info))
-            (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
-            (gnus-group-update-group ,group t))))
-      ;; Enter this list into the group info.
-      (gnus-info-set-read
-       info (if (> (length read) 1) (nreverse read) read))
-      ;; Set the number of unread articles in gnus-newsrc-hashtb.
-      (gnus-get-unread-articles-in-group info (gnus-active group))
-      t)))
+      (if compute
+         (if (> (length read) 1) (nreverse read) read)
+       (save-excursion
+         (set-buffer gnus-group-buffer)
+         (gnus-undo-register
+           `(progn
+              (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
+              (gnus-info-set-read ',info ',(gnus-info-read info))
+              (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
+              (gnus-group-update-group ,group t))))
+       ;; Enter this list into the group info.
+       (gnus-info-set-read
+        info (if (> (length read) 1) (nreverse read) read))
+       ;; Set the number of unread articles in gnus-newsrc-hashtb.
+       (gnus-get-unread-articles-in-group info (gnus-active group))
+       t))))
 
 (defun gnus-offer-save-summaries ()
   "Offer to save all active summary buffers."