[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

girzel/gnus-headers 943011d 2/2: Fixes to gnus-agent-retrieve-headers

From: Eric Abrahamsen
Subject: girzel/gnus-headers 943011d 2/2: Fixes to gnus-agent-retrieve-headers
Date: Sat, 16 Jan 2021 21:40:34 -0500 (EST)

branch: girzel/gnus-headers
commit 943011de8e1fe0337a7b4b9a643fd647f00e0a84
Author: Eric Abrahamsen <eric@ericabrahamsen.net>
Commit: Eric Abrahamsen <eric@ericabrahamsen.net>

    Fixes to gnus-agent-retrieve-headers
    * lisp/gnus/gnus-agent.el (gnus-agent-retrieve-headers): The
    sort->append call was altering fetched-headers in-place. Also, we
    should explicitly sort-numeric-fields in this
    function. gnus-agent-check-overview-buffer will do this, but treats it
    as a failure mode and will make a backup of the overview file.
 lisp/gnus/gnus-agent.el | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/lisp/gnus/gnus-agent.el b/lisp/gnus/gnus-agent.el
index 97df48b..32d0a85 100644
--- a/lisp/gnus/gnus-agent.el
+++ b/lisp/gnus/gnus-agent.el
@@ -3627,7 +3627,7 @@ has been fetched."
          (when fetched-headers
            (setq headers
-                  (sort (append headers fetched-headers)
+                  (sort (append headers (copy-sequence fetched-headers))
                         (lambda (l r)
                           (< (mail-header-number l)
                              (mail-header-number r))))))
@@ -3636,8 +3636,14 @@ has been fetched."
            (let ((coding-system-for-write
              (with-current-buffer gnus-agent-overview-buffer
+               ;; We stick the new headers in at the end, then
+               ;; re-sort the whole buffer with
+               ;; `sort-numeric-fields'.  If this turns out to be
+               ;; slow, we could consider a loop to add the headers
+               ;; in sorted order to begin with.
                (goto-char (point-max))
                (mapc #'nnheader-insert-nov fetched-headers)
+               (sort-numeric-fields 1 (point-min) (point-max))
                (write-region (point-min) (point-max) file nil 'silent)
                (gnus-agent-update-view-total-fetched-for group t)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]