Announcements and discussions for Gnus, the GNU Emacs Usenet newsreader
 help / color / mirror / Atom feed
* Re: (gnus-summary-sort-by-recipient): new function
       [not found] <867jtz7uvq.fsf@mat.ucm.es>
@ 2004-06-22 12:21 ` Reiner Steib
  0 siblings, 0 replies; only message in thread
From: Reiner Steib @ 2004-06-22 12:21 UTC (permalink / raw)


On Tue, Jun 22 2004, Uwe Brauer wrote:

> I sometimes  find in handy  to sort my  mail (in the mail sent group),
> by the recipient, which is  defined in the *to* field.
[...]
> Has anybody tried to write such a function.

Maybe like this:

--8<---------------cut here---------------start------------->8---
(defun rs-gnus-summary-sort-by-recipient (&optional reverse)
  "Sort the summary buffer by recipient name alphabetically.
If `case-fold-search' is non-nil, case of letters is ignored.
Argument REVERSE means reverse order."
  (interactive "P")
  (gnus-summary-sort 'recipient reverse))

(defsubst rs-gnus-article-sort-by-recipient (h1 h2)
  "Sort articles by recipient."
  (string-lessp
   (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)))))

;; Not using my own namespace prefix because `gnus-summary-sort' wants
;; "gnus-article-sort-by-%s":
(require 'gnus-sum)
(unless (fboundp 'gnus-article-sort-by-recipient)
  (defalias 'gnus-article-sort-by-recipient
    'rs-gnus-article-sort-by-recipient))
--8<---------------cut here---------------end--------------->8---

Bye, Reiner.
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo--- PGP key available via WWW   http://rsteib.home.pages.de/


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-06-22 12:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <867jtz7uvq.fsf@mat.ucm.es>
2004-06-22 12:21 ` (gnus-summary-sort-by-recipient): new function Reiner Steib

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).