Newsgroups: fj.editor.emacs
Path: galaxy.trc.rwcp.or.jp!jaist-news!cs.titech!wnoc-tyo-news!news.u-tokyo.ac.jp!news.tisn.ad.jp!s.u-tokyo!kuis!kurims!hattori
From: hattori@kurims.kyoto-u.ac.jp (Takashi Hattori)
Subject: Re: [Q] About VM
In-Reply-To: ono@toro.kuee.kyoto-u.ac.jp's message of Mon, 6 Dec 1993 11:17:30 GMT
Message-ID: <HATTORI.93Dec7192127@tanpopo.kurims.kyoto-u.ac.jp>
Lines: 134
Sender: news@kurims.kurims.kyoto-u.ac.jp
Nntp-Posting-Host: tanpopo
Organization: Research Institute for Mathematical Sciences, Kyoto, Japan.
References: <ONO.93Dec3193806@kohada.kuee.kyoto-u.ac.jp>
	<2duhqb$22o@dove.rst.ybp.fujixerox.co.jp>
	<ONO.93Dec6201730@toro.kuee.kyoto-u.ac.jp>
Distribution: fj
Date: Tue, 7 Dec 1993 10:21:27 GMT
Xref: galaxy.trc.rwcp.or.jp fj.editor.emacs:4250
X-originally-archived-at: http://galaxy.rwcp.or.jp/text/cgi-bin/newsarticle2?ng=fj.editor.emacs&nb=4250&hd=a
X-reformat-date: Mon, 18 Oct 2004 15:18:22 +0900
X-reformat-comment: Tabs were expanded into 4 column tabstops by the Galaxy's archiver. See http://katsu.watanabe.name/ancientfj/galaxy-format.html for more info.

$BI~It!w5~Bg$G$9!#(B

>>>>> In article <ONO.93Dec6201730@toro.kuee.kyoto-u.ac.jp>,
>>>>> ono@toro.kuee.kyoto-u.ac.jp (Hideki Ono) writes:

 $B>.(B> VM$B$NOCBj$,$G$F$-$?$H$3$m$GJX>h<ALd$G$9$,!"(B
 $B>.(B> Summary $B%P%C%U%!$G(BG(vm-group-messages)$B$r$7$F!"(Bdate$B$G%=!<%H$7$h$&(B
 $B>.(B> $B$H$9$k$H(BDate:$B%X%C%@$N=q$-J}$,$$$m$$$m$"$C$F$-$A$s$H%=!<%H$5$l$^$;$s!#(B
[$BCf(B] vm-group-by-date-sent (in vm-group.el)$B$N;EMM$NLdBj$_$?$$$G$9$M!#J8;zNs(B
[$BCf(B] $B$NHf3S$@$1$G:Q$^$7$F$$$k$N$H!"(Btimezone $B$r8+$F$$$J$$$3$H$,LdBj$@$H;W$$(B
[$BCf(B] $B$^$9!#(B
 $B>.(B> gnu.emacs.vm.*$B$K$=$l$KBP=h$9$k%Q%C%A$,N.$l$F$$$J$+$C$?$+$J$H;W$$$^$7$F!#(B
 $B>.(B> gnu.emacs.vm.*$B$ON.$7FI$_$7$F$$$k$N$G!"8+Mn$H$7$?$+$J$"$H!#(B

$B0JA0$K(B gnu.emacs.sources $B$K<!$N$h$&$J$b$N$,N.$l$F$$$^$7$?!#(B 
vm-group-message $B$,D>$k$o$1$G$O$"$j$^$;$s$,!"0lEY$*;n$72<$5$$!#(B

$BI~It!w?t8&!%5~Bg(B

----------------------------------------------------------------------
From moore@src.bae.co.UK Fri Feb 21 18:46:55 1992
Newsgroups: gnu.emacs.sources
Distribution: gnu
Organization: Source only  Discussion and requests in gnu.emacs.help.
From: moore@src.bae.co.UK (Chris Moore)
Subject: Re: How can I chronologically sort a VM mail file?
Date: 15 Feb 92 15:42:47 GMT


>>>>> In article <JBW.92Feb7103246@bigbird.bu.edu>, jbw@bigbird.bu.edu (Joe Wells) writes:

> In article <9202061810.AA01317@sun19.src.bae.co.uk> moore@src.bae.co.UK (Chris Moore) writes:

>    
>    How can I chronologically sort the messages in a VM (unix format) mail
>    file?
>    
> Here's my bastardized sorting code for VM.  There are no guarantees that
> it works with any particular version or that it works at all.  I think it
> needs VM 5, but I can't remember for certain.

> Note that this doesn't change the physical order of the messages in the
> file, just the presentation order.  If you want to change the physical
> order permanently, you should save all the messages in the file to another
> file (in order).

(Which I can do easily by typing M m then M n s, right?)

The code appears to work by re-ordering the vm-message-pointer so that each
message points to the next one in chronological order.  Unfortunately, it doesn't
update the backwards links, so 'p'ing back through the list takes a pretty
strange route.

I added a call to vm-reverse-link-messages, so that the sorted list is
correctly linked in both directions.

I really wanted to be able to sort messages by time sent to the nearest
second, so that I can order mail which has been split(1) from a single
large file and mailed to me.  Generally, when lots a large files are mailed
in short succession, they become unordered during their journey to my
mailbox.  I modified the code you sent me so that it uses the excellent
timezone.el to sort mail by date accurately.

I hope this is useful to somebody.

Chris.
--
Chris Moore
Advanced Information Processing Dept
Sowerby Research Centre, British Aerospace PLC, FPC 267, P.O.Box 5, Filton
Bristol, BS12 7QW, UK.     Tel (0)272 363375 Fax(0)272 363733 Telex 449452
Email moore@src.bae.co.uk
----------------------------------------------------------------------
;; Created by: Joe Wells, jbw@folsom
;; Created on: Mon Jun  4 21:28:03 1990
;; Last modified by: Chris Moore
;; Last modified on: Sat Feb 15 15:33:20 1992
;; Filename: vm-sort.el
;; Purpose: sort folder by date-received
;; Change log: 
;; 
;; Mon Nov  5 19:10:31 1990  Joe Wells  (jbw at bucsf.bu.edu)
;; 
;; * Added sorting by size.
;; 
;; Sat Feb 15 15:30:43 1992  Chris Moore  (moore at src.bae.co.uk)
;; 
;; * Use timezone package for finer sort granularity.
;;* Call vm-reverse-link-messages after sort to fix reverse links
;; 

(autoload 'timezone-make-date-sortable "timezone")

(defun vm-make-date-sortable (date)
  "Make DATE sortable using the function string-lessp."
  ;; Assume the default time zone is GMT.
  (timezone-make-date-sortable date "GMT" "GMT"))

(defun vm-sort-by-date-sent-p (m1 m2)
  (string-lessp (vm-make-date-sortable (vm-get-header-contents m1 "Date"))
(vm-make-date-sortable (vm-get-header-contents m2 "Date"))))

(defun vm-sort-internal (predicate)
  (let ((curr (car vm-message-pointer))
(last (car vm-last-message-pointer)))
    (setq vm-message-list
  (sort vm-message-list predicate)
  vm-message-pointer vm-message-list
  vm-last-message-pointer vm-message-list)
    (cond (curr
   (while (and vm-message-pointer
       (not (eq (car vm-message-pointer) curr)))
     (setq vm-message-pointer (cdr vm-message-pointer)))))
    (cond (last
   (while (and vm-last-message-pointer
       (not (eq (car vm-last-message-pointer) last)))
     (setq vm-last-message-pointer (cdr vm-last-message-pointer))))))
  (vm-reverse-link-messages))

(defun vm-sort-by-size-p (m1 m2)
  (< (read (vm-su-byte-count m1)) (read (vm-su-byte-count m2))))

(defun vm-sort ()
  (interactive)
  (vm-select-folder-buffer)
  (vm-sort-internal 'vm-sort-by-date-sent-p)
  (setq vm-current-grouping "date-sent")
  (vm-number-messages)
  (if vm-summary-buffer
      (vm-do-summary))
  (cond (vm-message-pointer
 (vm-update-summary-and-mode-line)
 (vm-set-summary-pointer (car vm-message-pointer)))))
----------------------------------------------------------------------
