[mew-dist 19749] Re: summary sort (message-count is not onn headers.)

Tatsuya Kinoshita tats at example.com
2001年 12月 1日 (土) 19:48:42 JST


In message [Mew-dist 16610], on Sun, 25 Feb 2001,
Kentaro Inagaki <inagaki at example.com> wrote:

> メーリングリストから来るメールのsummaryに付与されている番号
> を元にソートしたかったのですがデフォルトでできるのでしょうか?
> 
> X-SequenceとかX-Mail-Countとかがついていないメールだとどうに
> もうまくいかなかったのでいじってみたのですが。

> +    ("ml2"  mew-sort-key-ml2  mew-sort-number)

現状の"ml2"はうまく機能していないようです。"mlnum"という名前で実
装しなおしてみました。下記のような動作を想定しています。

-- before -- 
[ml-1:01000] bar
[ml-2 100] bacon
[ml-1:00999] foo
[ml-2 99] spam
---- 

`S subject:mlnum RET'

-- after -- 
[ml-1:00999] foo
[ml-1:01000] bar
[ml-2 99] spam
[ml-2 100] bacon
---- 

また、誤入力時のエラーを防ぐため、sort-key(mode)の入力チェックを
加えました。

-- 
木下達也
-------------- next part --------------

 This patch is written by Tatsuya Kinoshita.  Copyright is disclaimed.

diff -cr mew.orig/mew-minibuf.el mew/mew-minibuf.el
*** mew.orig/mew-minibuf.el	Wed Oct 31 23:41:49 2001
--- mew/mew-minibuf.el	Sat Dec  1 07:29:10 2001
***************
*** 169,178 ****
  
  (defvar mew-input-sort-key-hist nil)
  
  (defun mew-input-sort-key (key)
    (mew-input-clear)
    (setq mew-input-complete-function (function mew-complete-sort-key))
!   (let* ((field:mode (read-from-minibuffer
  		      (format "Sort by (%s)? : " key)
  		      ""
  		      mew-input-map
--- 169,194 ----
  
  (defvar mew-input-sort-key-hist nil)
  
+ (defun mew-sort-key-check ()
+   (let* ((field:mode (mew-buffer-substring 
+ 		      (save-excursion (beginning-of-line) (point))
+ 		      (point-max)))
+ 	 (mode (car (cdr (mew-split field:mode ?:))))
+ 	 err)
+     (if mode
+ 	(unless (member mode mew-sort-modes)
+ 	  (setq err mode)))
+     (if err
+         (progn
+           (mew-temp-minibuffer-message (format " [No match: %s]" err))
+           nil)
+       t)))
+ 
  (defun mew-input-sort-key (key)
    (mew-input-clear)
    (setq mew-input-complete-function (function mew-complete-sort-key))
!   (let* ((mew-exit-minibuffer-function (function mew-sort-key-check))
! 	 (field:mode (read-from-minibuffer
  		      (format "Sort by (%s)? : " key)
  		      ""
  		      mew-input-map
diff -cr mew.orig/mew-sort.el mew/mew-sort.el
*** mew.orig/mew-sort.el	Wed Oct 31 23:41:49 2001
--- mew/mew-sort.el	Sat Dec  1 07:09:25 2001
***************
*** 16,22 ****
  (defvar mew-sort-switch
    '(("text" mew-sort-key-text mew-sort-string)
      ("ml"   mew-sort-key-ml   mew-sort-string)
!     ("ml2"  mew-sort-key-ml2  mew-sort-number)
      ("date" mew-sort-key-date mew-sort-string)
      ("num"  mew-sort-key-num  mew-sort-number)
      ("postnum" mew-sort-key-postnum mew-sort-number)))
--- 16,22 ----
  (defvar mew-sort-switch
    '(("text" mew-sort-key-text mew-sort-string)
      ("ml"   mew-sort-key-ml   mew-sort-string)
!     ("mlnum" mew-sort-key-mlnum mew-sort-string)
      ("date" mew-sort-key-date mew-sort-string)
      ("num"  mew-sort-key-num  mew-sort-number)
      ("postnum" mew-sort-key-postnum mew-sort-number)))
***************
*** 32,44 ****
  	  (mew-subject-simplify ret nil 'no-replace))
        ret)))
  
! (defsubst mew-sort-key-ml2 (key folder msg)
!   (let ((ret (mew-subject-simplify key nil 'no-replace)))
!     (if (string-match "[[(][^])]+[: ]+([0-9]+)[])][ \t]+" key)
! 	(progn
! 	  (string-to-int (mew-match 0 key))
! 	  (mew-subject-simplify ret nil 'no-replace))
!       (string-to-int key))))
  
  (defsubst mew-sort-key-date (key folder msg)
    (if (string= key "")
--- 32,50 ----
  	  (mew-subject-simplify ret nil 'no-replace))
        ret)))
  
! (defsubst mew-sort-key-mlnum (key folder msg)
!   (let (mlname mlnum)
!     (cond
!      ((string-match "^\\([[(][^])]+\\)[: ]+\\([0-9]+\\)[])]" key)
!       (setq mlname (mew-match 1 key))
!       (setq mlnum (mew-match 2 key)))
!      ((string-match "^[0-9]+$" key)
!       (setq mlname "")
!       (setq mlnum (mew-match 0 key)))
!      (t
!       (setq mlname "")
!       (setq mlnum "0")))
!     (concat mlname (format "\000%010d" (string-to-int mlnum)))))
  
  (defsubst mew-sort-key-date (key folder msg)
    (if (string= key "")
diff -cr mew.orig/mew-vars.el mew/mew-vars.el
*** mew.orig/mew-vars.el	Fri Nov 23 16:54:44 2001
--- mew/mew-vars.el	Sat Dec  1 07:09:33 2001
***************
*** 1910,1921 ****
                 \"num\"  (by numerical order) or
                 \"postnum\" (by numerical order of postfix numeric) or
                 \"text\" (by alphabetical order) or
!                \"ml\"   (by alphabetical order with ml prefix removed).
  (nil means \"text\")."
    :group 'mew-summary
    :type 'sexp)
  
! (defvar mew-sort-modes '("date" "num" "postnum" "text" "ml"))
  
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;
--- 1910,1922 ----
                 \"num\"  (by numerical order) or
                 \"postnum\" (by numerical order of postfix numeric) or
                 \"text\" (by alphabetical order) or
!                \"ml\"   (by alphabetical order with ml prefix removed) or
!                \"mlnum\" (by numerical order of ml number).
  (nil means \"text\")."
    :group 'mew-summary
    :type 'sexp)
  
! (defvar mew-sort-modes '("date" "num" "postnum" "text" "ml" "mlnum"))
  
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;


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