Subject: Re: bug#49081: 28.0.50; [PATCH] Feature suggestion, Gnus summary mode sorting for extra headers

From: Lars Ingebrigtsen <[email-masked]>
Date: Sat, 19 Jun 2021 15:14:15 +0200

Alex Bochannek <[email-masked]> writes:

> Since I was able to get the Newsgroups extra header working for
> `nnvirtual' groups, I would like to not only limit, but also sort by the
> extra headers.

Looks good; applied with one minor tweak:

> +(defun gnus-article-sort-by-newsgroups (h1 h2)
> +  "Sort articles by newsgroups."
> +  (gnus-string<
> +   (let ((extract (funcall
> +		   gnus-extract-address-components
> +		   (or (cdr (assq 'Newsgroups (mail-header-extra h1))) ""))))
> +     (or (car extract) (cadr extract)))
> +   (let ((extract (funcall
> +		   gnus-extract-address-components
> +		   (or (cdr (assq 'Newsgroups (mail-header-extra h2))) ""))))
> +     (or (car extract) (cadr extract)))))

I rewrote that to:

(defun 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))))))
    (gnus-string< (funcall ex h1) (funcall ex h2))))

To avoid the duplication -- let me know if I messed up that bit.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no