diff options
author | Alex Bochannek <alex@bochannek.com> | 2021-06-21 14:35:48 +0200 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2021-06-21 14:35:48 +0200 |
commit | 624c8613e791fb5134bf9c02ebd9b5755802e4f6 (patch) | |
tree | c5c2ed3d36e403fd82a5a4b8a6a3b23885961f7d /lisp | |
parent | 9068f8f10c55ccb6a434486daa8baf2c859beb8a (diff) | |
download | emacs-624c8613e791fb5134bf9c02ebd9b5755802e4f6.tar.gz |
Refactor gnus-article-sort-by-*
* lisp/gnus/gnus-sum.el (gnus-article-sort-extract-extra): New
function (bug#49081).
(gnus-article-sort-by-recipient): Use it.
(gnus-article-sort-by-newsgroups): Ditto.
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/gnus/gnus-sum.el | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el index 908c10c11d7..4bdc2023eb4 100644 --- a/lisp/gnus/gnus-sum.el +++ b/lisp/gnus/gnus-sum.el @@ -5083,17 +5083,17 @@ using some other form will lead to serious barfage." (gnus-article-sort-by-author (gnus-thread-header h1) (gnus-thread-header h2))) +(defsubst gnus-article-sort-extract-extra (name header) + (let ((extract + (funcall gnus-extract-address-components + (or (cdr (assq name (mail-header-extra header))) + "")))) + (or (car extract) (cadr extract)))) + (defsubst gnus-article-sort-by-recipient (h1 h2) "Sort articles by recipient." - (gnus-string< - (let ((extract (funcall - gnus-extract-address-components - (or (cdr (assq 'To (mail-header-extra h1))) "")))) - (or (car extract) (cadr extract))) - (let ((extract (funcall - gnus-extract-address-components - (or (cdr (assq 'To (mail-header-extra h2))) "")))) - (or (car extract) (cadr extract))))) + (let ((ex (lambda (h) (gnus-article-sort-extract-extra 'To h)))) + (gnus-string< (funcall ex h1) (funcall ex h2)))) (defun gnus-thread-sort-by-recipient (h1 h2) "Sort threads by root recipient." @@ -5188,15 +5188,9 @@ Unscored articles will be counted as having a score of zero." "Sort threads such that the thread with the most recently dated article comes first." (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2))) -(defun gnus-article-sort-by-newsgroups (h1 h2) +(defsubst gnus-article-sort-by-newsgroups (h1 h2) "Sort articles by newsgroups." - (let ((ex - (lambda (h) - (let ((extract - (funcall gnus-extract-address-components - (or (cdr (assq 'Newsgroups (mail-header-extra h))) - "")))) - (or (car extract) (cadr extract)))))) + (let ((ex (lambda (h) (gnus-article-sort-extract-extra 'Newsgroups h)))) (gnus-string< (funcall ex h1) (funcall ex h2)))) (defun gnus-thread-sort-by-newsgroups (h1 h2) @@ -5204,7 +5198,6 @@ Unscored articles will be counted as having a score of zero." (gnus-article-sort-by-newsgroups (gnus-thread-header h1) (gnus-thread-header h2))) - ; Since this is called not only to sort the top-level threads, but ; also in recursive sorts to order the articles within a thread, each ; article will be processed many times. Thus it speeds things up |