Announcements and discussions for Gnus, the GNU Emacs Usenet newsreader
 help / color / mirror / Atom feed
From: Jesper Harder <harder@myrealbox.com>
Subject: Re: sort by receiver
Date: Thu, 28 Nov 2002 03:11:12 +0100	[thread overview]
Message-ID: <m3fztml9z3.fsf@defun.localdomain> (raw)
In-Reply-To: <m3wun7c4kd.fsf@zeus.ece.cmu.edu>

Zero Void <hujingcao@hotmail.com> writes:

> Is there a way to sort the emails according to receiver? 

Nope, no pre-defined way.

> This will help me a lot when I want to check out an email in my
> "sent-mail" folder.

Yes, that would be nice.  Here's some code to do it.  

It binds `gnus-summary-sort-by-recipient' to `C-c C-s C-t'.  To use it
you also need to include "To" and "Newsgroups" in overview as described
in <info://gnus/To+From+Newsgroups>.


(defun gnus-thread-sort-by-recipient (h1 h2)
  "Sort threads by root recipient."
  (gnus-article-sort-by-recipient
   (gnus-thread-header h1)  (gnus-thread-header h2)))

(defun gnus-article-sort-by-recipient (h1 h2)
  "Sort articles by root recipient."
  (let* ((extra1 (mail-header-extra h1))
	 (extra2 (mail-header-extra h2))
	 (group1 (cdr (assq 'Newsgroups extra1)))
	 (group2 (cdr (assq 'Newsgroups extra2)))
	 (name1 (cdr (assq 'To extra1)))
	 (name2 (cdr (assq 'To extra2))))
    (string-lessp
     (or group1
	 (and name1
	      (gnus-summary-extract-address-component
	       (funcall gnus-decode-encoded-word-function name1)))
	 "")
     (or group2
	 (and name2
	      (gnus-summary-extract-address-component
		    (funcall gnus-decode-encoded-word-function name2)))
	 ""))))

(defun 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))

(define-key gnus-summary-mode-map "\C-c\C-s\C-t" 
  'gnus-summary-sort-by-recipient)


           reply	other threads:[~2002-11-28  2:11 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <m3wun7c4kd.fsf@zeus.ece.cmu.edu>]

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=m3fztml9z3.fsf@defun.localdomain \
    --to=harder@myrealbox.com \
    /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).