Commit 943011de authored by Eric Abrahamsen's avatar Eric Abrahamsen

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.
parent 84e80376
Pipeline #8780 failed with stage
in 61 minutes and 6 seconds
...@@ -3627,7 +3627,7 @@ has been fetched." ...@@ -3627,7 +3627,7 @@ has been fetched."
(when fetched-headers (when fetched-headers
(setq headers (setq headers
(delete-dups (delete-dups
(sort (append headers fetched-headers) (sort (append headers (copy-sequence fetched-headers))
(lambda (l r) (lambda (l r)
(< (mail-header-number l) (< (mail-header-number l)
(mail-header-number r)))))) (mail-header-number r))))))
...@@ -3636,8 +3636,14 @@ has been fetched." ...@@ -3636,8 +3636,14 @@ has been fetched."
(let ((coding-system-for-write (let ((coding-system-for-write
gnus-agent-file-coding-system)) gnus-agent-file-coding-system))
(with-current-buffer gnus-agent-overview-buffer (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)) (goto-char (point-max))
(mapc #'nnheader-insert-nov fetched-headers) (mapc #'nnheader-insert-nov fetched-headers)
(sort-numeric-fields 1 (point-min) (point-max))
(gnus-agent-check-overview-buffer) (gnus-agent-check-overview-buffer)
(write-region (point-min) (point-max) file nil 'silent) (write-region (point-min) (point-max) file nil 'silent)
(gnus-agent-update-view-total-fetched-for group t) (gnus-agent-update-view-total-fetched-for group t)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment