(defun mew-mailhist ()
"Mew の Smtplog でまねっこ。Mew と MHC が必要"
(interactive)
(let ((logfile (read-file-name "Smtplog: " (file-name-as-directory mew-conf-path)
(expand-file-name mew-smtp-log-file mew-conf-path)
t mew-smtp-log-file))
(buff (get-buffer-create "*Mew MailHist*"))
(startdate "9999/99/99")
(enddate "0000/00/00")
(totalcount 0)
max sdate edate date date-alist match totaldate pdate)
(with-temp-buffer
(insert-file-contents (expand-file-name logfile))
(goto-char (point-min))
(while (not (eobp))
(when (looking-at "^\\([12][0-9][0-9][0-9]/[0-9]+/[0-9]+\\) ")
(setq date (match-string 1))
(setq totalcount (1+ totalcount))
(if (setq match (assoc date date-alist))
(setcdr match (1+ (cdr match)))
(setq date-alist (cons `(,date . 1) date-alist))
(when (string< date startdate)
(setq startdate date))
(when (string< enddate date)
(setq enddate date))))
(forward-line 1)))
(setq date-alist
(sort date-alist (lambda (x y) (> (cdr x) (cdr y)))))
(and (string-match "^\\([12][0-9][0-9][0-9]\\)/\\([0-9]+\\)/\\([0-9]+\\)"
startdate)
(setq sdate (mhc-date/absolute-from-epoch
(string-to-number (match-string 1 startdate))
(string-to-number (match-string 2 startdate))
(string-to-number (match-string 3 startdate)))))
(and (string-match "^\\([12][0-9][0-9][0-9]\\)/\\([0-9]+\\)/\\([0-9]+\\)"
enddate)
(setq edate (mhc-date/absolute-from-epoch
(string-to-number (match-string 1 enddate))
(string-to-number (match-string 2 enddate))
(string-to-number (match-string 3 enddate)))))
(setq totaldate (1+ (- edate sdate)))
(setq max (cdr (car date-alist)))
(pop-to-buffer buff)
(erase-buffer)
(insert (format "%s〜%s (%d日, %d通, Ave %.2f通/日)\n"
startdate enddate totaldate totalcount
(/ totalcount (float totaldate))))
(while (>= max 0)
(setq totalcount 0)
(while (setq match (rassq max date-alist))
(setq totalcount (1+ totalcount))
(setq date-alist (delq match date-alist)))
(setq totaldate (- totaldate totalcount))
(setq pdate (cons
(format "%4d通 %3d日 %s\n"
max
(if (zerop max) totaldate totalcount)
(make-string
(min 80 (if (zerop max) totaldate totalcount)) ?*))
pdate))
(setq max (1- max)))
(mapcar 'insert pdate)))
M-x mew-mailhist => ..../Smtplog 2003/04/21〜2003/06/10 (51日, 154通, Ave 3.02通/日) 0通 17日 ***************** 1通 6日 ****** 2通 6日 ****** 3通 2日 ** 4通 4日 **** 5通 7日 ******* 6通 4日 **** 7通 1日 * 8通 2日 ** 9通 0日 10通 0日 11通 0日 12通 0日 13通 0日 14通 1日 * 15通 0日 16通 0日 17通 0日 18通 1日 *
M-x mew-mailhist => ..../Smtplog.0 2001/07/13〜2003/04/18 (645日, 2860通, Ave 4.43通/日) 0通 254日 ******************************************************************************** 1通 20日 ******************** 2通 29日 ***************************** 3通 28日 **************************** 4通 34日 ********************************** 5通 45日 ********************************************* 6通 37日 ************************************* 7通 40日 **************************************** 8通 33日 ********************************* 9通 36日 ************************************ 10通 18日 ****************** 11通 17日 ***************** 12通 13日 ************* 13通 4日 **** 14通 6日 ****** 15通 5日 ***** 16通 9日 ********* 17通 3日 *** 18通 3日 *** 19通 5日 ***** 20通 0日 21通 0日 22通 0日 23通 1日 * 24通 2日 ** 25通 0日 26通 1日 * 27通 0日 28通 1日 * 29通 0日 <<中略>> 43通 0日 44通 1日 *