[Mew-dist 1179] mew-sort.el ver 0.05 and patch for 1.85

Takashi P.KATOH p-katoh at example.com
1997年 7月 3日 (木) 17:22:41 JST


かとぺ@東北大です。
# Perl のインストールで随分てまどってしまった...

mew-sort.el の version 0.05 です。

変更点は
  Mew-1.85 に *のみ* 対応した
です。
要するに mew の仕様変更に伴う変更です。

機能的には何も変わっていません。

-- 
  東北大学大学院 情報科学研究科 白鳥研究室    加藤 貴司
  p-katoh at example.com / Takashi P.KATOH
  http://www.shiratori.riec.tohoku.ac.jp/~p-katoh/MAIL/
-------------- next part --------------
;;;			     mew-sort.el
;;;
;;;	     Copyright (C) 1996 and 1997  Takashi P.KATOH
;;;
;;;		   This emacs lisp library confirms
;;;		GNU GENERAL PUBLIC LICENSE Version 2.
;;;
;;; Author:  Takashi P.KATOH <p-katoh at example.com>
;;;          Kazuhiko Yamamoto <kazu at example.com>
;;; Created: Febraury  6, 1996
;;; Revised: July      3, 1997
;;;

(defconst mew-sort-version "mew-sort.el version 0.05")

(require 'mew)

(defvar mew-summary-sort-fields
  '(("date" . t) ("subject") ("from") ("to") ("newsgroups") ("posted" . t))
  "*List of fields for `mew-summary-sort'.
Each element is (FIELD-NAME) or (FIELD-NAME . DATE-P).
If DATE-P is non-nil, messages will be sorted by chronological order.")

(defvar mew-summary-sort-last-field "date")

(defun mew-summary-sort-subr (msgs &optional method)
  (let* ((folder (buffer-name))
	 (msgs (if (listp msgs) msgs (list msgs)))
	 (completion-ignore-case t)
	 (field
	  (completing-read
	   (concat "Sort " method (if method " ") "by?"
		   (if mew-summary-sort-last-field
		       (concat " (default " mew-summary-sort-last-field "): ")
		     ": ")) mew-summary-sort-fields)))
    (setq field
	  (downcase
	   (if (string-equal field "") mew-summary-sort-last-field field))
	  mew-summary-sort-last-field field)
    (if (not (mew-summary-exclusive-p))
	(message "Try later")
      (mew-mark-clean-up)
      (setq mew-summary-buffer-process t)
      (message "Sorting %s by %s ... " folder field)
      (if (cdr (assoc field mew-summary-sort-fields))
	  (apply 'call-process mew-prog-sortm nil nil nil
		 (append (list folder) msgs (list "-datefield" field)))
	(apply 'call-process mew-prog-sortm nil nil nil
	       (append (list folder)
		       msgs
		       (list "-textfield" field "-limit" "0"))))
      (message "Sorting %s by %s ... done" folder field)
      (setq mew-summary-buffer-process nil)
      (let ((buffer-read-only nil)) (erase-buffer));; for update
      (mew-summary-scan-body mew-prog-imls
			     'mew-summary-mode
			     folder
			     mew-cs-scan
			     (mew-input-range folder))
      )
    ))

(defun mew-summary-sort (&optional arg)
  (interactive "P")
  (if arg
      (mew-summary-sort-region (region-beginning) (region-end) "region")
    (mew-summary-sort-region (point-min) (point-max))))

(defun mew-summary-sort-region (r1 r2 &optional method)
  (interactive "r")
  (let (from to msgs)
    (save-excursion
      (goto-char r1)
      (setq from
	    (or (mew-summary-message-number)
		(progn
		  (re-search-backward mew-summary-message-regex nil t nil)
		  (mew-summary-message-number))))
      (goto-char r2)
      (setq to
	    (or (mew-summary-message-number)
		(progn
		  (re-search-backward mew-summary-message-regex nil t nil)
		  (mew-summary-message-number))))
      (if (< (string-to-int from) (string-to-int to))
	  (mew-summary-sort-subr (concat from "-" to) method)
	(mew-summary-sort-subr (concat to "-" from) method)))))

(defun mew-summary-mark-sort (&optional r1 r2)
  (interactive)
  (mew-summary-sort-subr
   (mew-summary-mark-collect
    mew-mark-hop (or r1 (point-min)) (or r2 (point-max)))
   "marked messages"))

(provide 'mew-sort)
-------------- next part --------------
diff -ur mew-1.85.orig/mew-summary.el mew-1.85/mew-summary.el
--- mew-1.85.orig/mew-summary.el	Tue Jul  1 10:15:52 1997
+++ mew-1.85/mew-summary.el	Thu Jul  3 14:06:35 1997
@@ -34,6 +34,7 @@
     ["Refile" mew-summary-refile (equal major-mode 'mew-summary-mode)]
     ["Mark mark" mew-summary-mark-mark t]
     ["Mark hop" mew-summary-mark-hop t]
+    ["Sort marked msgs" mew-summary-mark-sort t]
     ["Undo" mew-summary-undo t]
     ["Undo all" mew-summary-undo-all t]
     ["Execute" mew-summary-exec (equal major-mode 'mew-summary-mode)]
@@ -159,6 +160,7 @@
   (define-key mew-summary-mode-map "mr"   'mew-summary-mark-regexp)
   (define-key mew-summary-mode-map "ma"   'mew-summary-mark-all)
   (define-key mew-summary-mode-map "mu"   'mew-summary-mark-undo-all)
+  (define-key mew-summary-mode-map "mS"   'mew-summary-mark-sort)
   (define-key mew-summary-mode-map "\C-c\C-k" 'mew-summary-kill-subprocess)
   ;;
   (if mew-xemacs-p
@@ -283,6 +285,7 @@
 m*	Change mark \"@\" into mark \"*\".
 m@	Change mark \"*\" into mark \"@\".
 ms	Swap mark \"@\" and \"*\".
+mS	Sort messages whose marks are \"*\".
 
 C-cC-s	Incremental search forward on the message buffer.
 C-cC-r	Incremental search backward on the message buffer.
@@ -1502,27 +1505,27 @@
 ;;; Sorting and Packing
 ;;;
 
-(defun mew-summary-sort ()    
-  (interactive)
-  (let ((folder (buffer-name)))
-    (if (not (mew-summary-exclusive-p))
-	(message "Try later")
-      (mew-mark-clean-up)
-      (if (not (mew-y-or-n-p "Sort %s ? " folder))
-	  ()
-	(setq mew-summary-buffer-process t)
-	(message "Sorting %s ... " folder)
-	(call-process mew-prog-sortm nil nil nil folder)
-	(message "Sorting %s ... done" folder)
-	(setq mew-summary-buffer-process nil)
-	(let ((buffer-read-only nil)) (erase-buffer))  ;; for update
-	(mew-summary-scan-body mew-prog-imls
-			       'mew-summary-mode
-			       folder
-			       mew-cs-scan
-			       (mew-input-range folder))
-	))
-    ))
+;(defun mew-summary-sort ()    
+;  (interactive)
+;  (let ((folder (buffer-name)))
+;    (if (not (mew-summary-exclusive-p))
+;	(message "Try later")
+;      (mew-mark-clean-up)
+;      (if (not (mew-y-or-n-p "Sort %s ? " folder))
+;	  ()
+;	(setq mew-summary-buffer-process t)
+;	(message "Sorting %s ... " folder)
+;	(call-process mew-prog-sortm nil nil nil folder)
+;	(message "Sorting %s ... done" folder)
+;	(setq mew-summary-buffer-process nil)
+;	(let ((buffer-read-only nil)) (erase-buffer))  ;; for update
+;	(mew-summary-scan-body mew-prog-imls
+;			       'mew-summary-mode
+;			       folder
+;			       mew-cs-scan
+;			       (mew-input-range folder))
+;	))
+;    ))
 
 (defun mew-summary-pack ()    
   (interactive)
diff -ur mew-1.85.orig/mew.el mew-1.85/mew.el
--- mew-1.85.orig/mew.el	Tue Jul  1 10:27:19 1997
+++ mew-1.85/mew.el	Thu Jul  3 14:07:26 1997
@@ -950,6 +950,7 @@
 (require 'mew-refile)
 (require 'mew-ext)
 (require 'mew-fib)
+(require 'mew-sort)
 ;;;
 ;;; End of Mew
 ;;;


Mew-dist メーリングリストの案内