[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master da1974f: * lisp/gnus: Further reduce assumptions ab
From: |
Stefan Monnier |
Subject: |
[Emacs-diffs] master da1974f: * lisp/gnus: Further reduce assumptions about gnus-data format |
Date: |
Fri, 7 Jun 2019 15:44:56 -0400 (EDT) |
branch: master
commit da1974fabddda6fac029db6960110001c6472ddc
Author: Stefan Monnier <address@hidden>
Commit: Stefan Monnier <address@hidden>
* lisp/gnus: Further reduce assumptions about gnus-data format
* lisp/gnus/gnus-registry.el (gnus-registry-fetch-message-id-fast)
(gnus-registry-fetch-simplified-message-subject-fast)
(gnus-registry-fetch-sender-fast, gnus-registry-fetch-recipients-fast)
(gnus-registry--set/remove-mark): Don't hardcode assoc for
gnus-data-find-in.
* lisp/gnus/gnus-sum.el (gnus-data-update-list): Don't hardcode `nth 2`
for gnus-data-pos.
(gnus-summary-insert-old-articles, gnus-summary-insert-new-articles)
(gnus-summary-first-article-p): Don't hardcode `car` for `gnus-data-number`.
(gnus-summary-move-article, gnus-summary-expire-articles)
(gnus-summary-delete-article): Don't hardcode assoc for gnus-data-find-in.
* lisp/gnus/spam.el (spam-fetch-article-header): Don't hardcode `nth 3`
for gnus-data-header.
---
lisp/gnus/gnus-registry.el | 31 +++++++++++--------------------
lisp/gnus/gnus-sum.el | 27 +++++++++++++--------------
lisp/gnus/spam.el | 4 ++--
3 files changed, 26 insertions(+), 36 deletions(-)
diff --git a/lisp/gnus/gnus-registry.el b/lisp/gnus/gnus-registry.el
index 634cf92..6e549cf 100644
--- a/lisp/gnus/gnus-registry.el
+++ b/lisp/gnus/gnus-registry.el
@@ -799,11 +799,9 @@ Overrides existing keywords with FORCE set non-nil."
;; message field fetchers
(defun gnus-registry-fetch-message-id-fast (article)
- "Fetch the Message-ID quickly, using the internal gnus-data-list function."
- (if (and (numberp article)
- (assoc article (gnus-data-list nil)))
- (mail-header-id (gnus-data-header (assoc article (gnus-data-list nil))))
- nil))
+ "Fetch the Message-ID quickly, using the internal `gnus-data-find' function."
+ (when-let* ((data (and (numberp article) (gnus-data-find article))))
+ (mail-header-id (gnus-data-header data))))
(defun gnus-registry-extract-addresses (text)
"Extract all the addresses in a normalized way from TEXT.
@@ -830,23 +828,18 @@ Addresses without a name will say \"noname\"."
nil))
(defun gnus-registry-fetch-simplified-message-subject-fast (article)
- "Fetch the Subject quickly, using the internal gnus-data-list function."
- (if (and (numberp article)
- (assoc article (gnus-data-list nil)))
- (gnus-string-remove-all-properties
- (gnus-registry-simplify-subject
- (mail-header-subject (gnus-data-header
- (assoc article (gnus-data-list nil))))))
- nil))
+ "Fetch the Subject quickly, using the internal `gnus-data-find' function."
+ (when-let* ((data (and (numberp article) (gnus-data-find article))))
+ (gnus-string-remove-all-properties
+ (gnus-registry-simplify-subject
+ (mail-header-subject (gnus-data-header data))))))
(defun gnus-registry-fetch-sender-fast (article)
- (when-let* ((data (and (numberp article)
- (assoc article (gnus-data-list nil)))))
+ (when-let* ((data (and (numberp article) (gnus-data-find article))))
(mail-header-from (gnus-data-header data))))
(defun gnus-registry-fetch-recipients-fast (article)
- (when-let* ((data (and (numberp article)
- (assoc article (gnus-data-list nil))))
+ (when-let* ((data (and (numberp article) (gnus-data-find article)))
(extra (mail-header-extra (gnus-data-header data))))
(gnus-registry-sort-addresses
(or (cdr (assq 'Cc extra)) "")
@@ -887,9 +880,7 @@ FUNCTION should take two parameters, a mark symbol and the
cell value."
(gnus-message 9 "Applying mark %s to %d articles"
mark (length articles))
(dolist (article articles)
- (gnus-summary-update-article
- article
- (assoc article (gnus-data-list nil))))))
+ (gnus-summary-update-article article (gnus-data-find article)))))
;; This is ugly code, but I don't know how to do it better.
(defun gnus-registry-install-shortcuts ()
diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el
index 4c44452..8fdb766 100644
--- a/lisp/gnus/gnus-sum.el
+++ b/lisp/gnus/gnus-sum.el
@@ -3246,7 +3246,7 @@ The following commands are available:
"Add OFFSET to the POS of all data entries in DATA."
(setq gnus-newsgroup-data-reverse nil)
(while data
- (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
+ (cl-incf (gnus-data-pos (car data)) offset)
(setq data (cdr data))))
(defun gnus-summary-article-pseudo-p (article)
@@ -3574,7 +3574,7 @@ buffer that was in action when the last article was
fetched."
"Return whether ARTICLE is the first article in the buffer."
(if (not (setq article (or article (gnus-summary-article-number))))
nil
- (eq article (caar gnus-newsgroup-data))))
+ (eq article (gnus-data-number (car gnus-newsgroup-data)))))
(defun gnus-summary-last-article-p (&optional article)
"Return whether ARTICLE is the last article in the buffer."
@@ -4725,10 +4725,10 @@ If LINE, insert the rebuilt thread starting on line
LINE."
(push thr roots))
(setq thread (cdr thread)))
;; We now have all (unique) roots.
- (if (= (length roots) 1)
- ;; All the loose roots are now one solid root.
- (setq thread (car roots))
- (setq thread (cons subject (gnus-sort-threads roots))))))
+ (setq thread (if (= (length roots) 1)
+ ;; All the loose roots are now one solid root.
+ (car roots)
+ (cons subject (gnus-sort-threads roots))))))
(let (threads)
;; We then insert this thread into the summary buffer.
(when line
@@ -4738,6 +4738,7 @@ If LINE, insert the rebuilt thread starting on line LINE."
(if gnus-show-threads
(gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
(gnus-summary-prepare-unthreaded thread))
+ ;; FIXME: Why is this `nreverse' safe? Don't we need `reverse'
instead?
(setq data (nreverse gnus-newsgroup-data))
(setq threads gnus-newsgroup-threads))
;; We splice the new data into the data structure.
@@ -10170,7 +10171,7 @@ ACTION can be either `move' (the default), `crosspost'
or `copy'."
(run-hook-with-args 'gnus-summary-article-delete-hook
action
(gnus-data-header
- (assoc article (gnus-data-list nil)))
+ (gnus-data-find-in article (gnus-data-list nil)))
gnus-newsgroup-name nil
select-method)))
(t
@@ -10280,8 +10281,7 @@ ACTION can be either `move' (the default), `crosspost'
or `copy'."
;; run the move/copy/crosspost/respool hook
(run-hook-with-args 'gnus-summary-article-move-hook
action
- (gnus-data-header
- (assoc article (gnus-data-list nil)))
+ (gnus-data-header (gnus-data-find article))
gnus-newsgroup-name
to-newsgroup
select-method))
@@ -10524,7 +10524,7 @@ This will be the case if the article has both been
mailed and posted."
(run-hook-with-args
'gnus-summary-article-expire-hook
'delete
- (gnus-data-header (assoc article (gnus-data-list nil)))
+ (gnus-data-header (gnus-data-find article))
gnus-newsgroup-name
(cond
((stringp nnmail-expiry-target) nnmail-expiry-target)
@@ -10588,8 +10588,7 @@ confirmation before the articles are deleted."
(unless (memq (car articles) not-deleted)
(gnus-summary-mark-article (car articles) gnus-canceled-mark)
(let* ((article (car articles))
- (ghead (gnus-data-header
- (assoc article (gnus-data-list nil)))))
+ (ghead (gnus-data-header (gnus-data-find article))))
(run-hook-with-args 'gnus-summary-article-delete-hook
'delete ghead gnus-newsgroup-name nil
nil)))
@@ -13038,7 +13037,7 @@ If ALL is non-nil, already read articles become
readable.
If ALL is a number, fetch this number of articles."
(interactive "P")
(prog1
- (let ((old (sort (mapcar #'car gnus-newsgroup-data) #'<))
+ (let ((old (sort (mapcar #'gnus-data-number gnus-newsgroup-data) #'<))
older len)
(setq older
;; Some nntp servers lie about their active range. When
@@ -13108,7 +13107,7 @@ If ALL is a number, fetch this number of articles."
(defun gnus-summary-insert-new-articles ()
"Insert all new articles in this group."
(interactive)
- (let ((old (sort (mapcar #'car gnus-newsgroup-data) #'<))
+ (let ((old (sort (mapcar #'gnus-data-number gnus-newsgroup-data) #'<))
(old-high gnus-newsgroup-highest)
(nnmail-fetched-sources (list t))
(new-active (gnus-activate-group gnus-newsgroup-name 'scan))
diff --git a/lisp/gnus/spam.el b/lisp/gnus/spam.el
index 4d31d0a..d752bf0 100644
--- a/lisp/gnus/spam.el
+++ b/lisp/gnus/spam.el
@@ -1520,7 +1520,7 @@ In the case of mover backends, checks the setting of
;; nil)))
(defun spam-fetch-field-fast (article field &optional prepared-data-header)
- "Fetch a FIELD for ARTICLE with the internal `gnus-data-list' function.
+ "Fetch a FIELD for ARTICLE with the internal `gnus-data-find' function.
When PREPARED-DATA-HEADER is given, don't look in the Gnus data.
When FIELD is 'number, ARTICLE can be any number (since we want
to find it out)."
@@ -1586,7 +1586,7 @@ to find it out)."
(defun spam-fetch-article-header (article)
(with-current-buffer gnus-summary-buffer
(gnus-read-header article)
- (nth 3 (assq article gnus-newsgroup-data))))
+ (gnus-data-header (gnus-data-find article))))
;;}}}
;;{{{ Spam determination.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master da1974f: * lisp/gnus: Further reduce assumptions about gnus-data format,
Stefan Monnier <=