Announcements and discussions for Gnus, the GNU Emacs Usenet newsreader
 help / color / mirror / Atom feed
From: Reiner Steib <4.uce.03.r.s@nurfuerspam.de>
Subject: Re: (gnus-summary-sort-by-recipient): new function
Date: Tue, 22 Jun 2004 14:21:27 +0200	[thread overview]
Message-ID: <v9llifg4vs.fsf@marauder.physik.uni-ulm.de> (raw)
In-Reply-To: <867jtz7uvq.fsf@mat.ucm.es>

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/


           reply	other threads:[~2004-06-22 12:21 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <867jtz7uvq.fsf@mat.ucm.es>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=v9llifg4vs.fsf@marauder.physik.uni-ulm.de \
    --to=4.uce.03.r.s@nurfuerspam.de \
    --cc=reiner.steib@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).