[Mew-dist 15328] Re: thread
Shun-ichi TAHARA ( 田原 俊一 )
jado at example.com
2000年 12月 7日 (木) 14:33:55 JST
From: Shun-ichi TAHARA (田原 俊一) <jado at example.com>
Message-Id: <20001207.135504.596522004.z1980163 at example.com>
> > 最終パッチを下さいな。
>
> もう少しいじらせてください。
> 1時間以内に出します。
というわけで、素の b85/mew-thread.el に対するパッチです。
再帰を除去して、prefixまわりをごにょごにょしたら、かなり速くなりました。
手元では、再帰版のオリジナルthreadルーチンとほぼ互角レベルです。
# オリジナルの再帰を除去したらさらに速くなるのでしょうけど :-)
使用法は [Mew-dist 15298]/[Mew-dist 15299] と同様です。以下再掲。
----
(setq mew-use-fancy-thread t) としておくと、スレッドがツリーっぽい表示
になります。併せて mew-fancy-thread-indent-strings をチェックしてくだ
さい。変数名が変わっていますので要注意。
設定例:
(setq mew-use-fancy-thread t)
(setq mew-fancy-thread-indent-strings [" ┣" " ┗" " ┃" " "])
Mew起動後に mew-use-fancy-thread を切り替えたときは、mew-thread-setup
を呼んでやらないと、^ とか C-p とか C-n とかが誤動作します。
----
_______________________________
田原 俊一 jado at example.com, shunichi_tahara at example.com
http://flowernet.gr.jp/jado/
FingerPrint: 16 9E 70 3B 05 86 5D 08 - B8 4C 47 3A E7 E9 8E D9
 ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄
-------------- next part --------------
*** mew-thread.el.orig Tue Dec 5 00:39:24 2000
--- mew-thread.el Thu Dec 7 14:23:32 2000
*************** (defvar mew-thread-indent-string " "
*** 53,58 ****
--- 53,85 ----
(defvar mew-thread-indent-array nil)
(defvar mew-thread-indent-array-size 33) ;; devide by 32
+ (defvar mew-use-fancy-thread nil
+ "*If non-nil, use fancy style thread visualization.
+ See also mew-fancy-thread-indent-strings.")
+
+ (defvar mew-fancy-thread-indent-strings
+ [" +" " +" " |" " "]
+ "*Vector of string to be used for indentation of fancy style thread.
+ Valid only if mew-use-fancy-thread is non-nil.
+
+ This is consist of four members; 1st member is to prefix the child
+ message that is not the last one, 2nd is to prefix the last child, 3rd
+ and 4th are to prefix grand-child thread tree, 4th is for the child
+ tree of the last chile message.
+ For example, [ \" +\" \" +\" \" |\" \" \" ] makes thread view below.
+
+ Message 1
+ +Message 2
+ | +Message 3
+ +Message 4
+ +Message 5
+
+ All members must have same lengths.")
+
+ (defvar mew-thread-indent-length nil)
+ (defvar mew-thread-indent-regex nil)
+ (defvar mew-thread-indent-lregex nil)
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Thread info macro
*************** (defmacro mew-thread-set-line (entry lin
*** 98,112 ****
;;;
(defun mew-thread-setup ()
! (let* ((i 0)
! (size mew-thread-indent-array-size)
! (array (make-vector size nil))
! (indent ""))
! (while (< i size)
! (aset array i indent)
! (setq i (1+ i))
! (setq indent (concat indent mew-thread-indent-string)))
! (setq mew-thread-indent-array array)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
--- 125,169 ----
;;;
(defun mew-thread-setup ()
! (cond
! (mew-use-fancy-thread
! (let ((idt1 (aref mew-fancy-thread-indent-strings 0))
! (idt2 (aref mew-fancy-thread-indent-strings 1))
! (idt3 (aref mew-fancy-thread-indent-strings 2))
! (idt4 (aref mew-fancy-thread-indent-strings 3)))
! (if (and (= (length idt1) (length idt2))
! (= (length idt2) (length idt3))
! (= (length idt3) (length idt4)))
! ()
! (error
! "\
! All members of mew-fancy-thread-indent-strings must have same lengths."))
! (setq mew-thread-indent-length (length idt1))
! (setq mew-thread-indent-regex
! (concat "\\(" (regexp-quote idt1) "\\|" (regexp-quote idt2)
! "\\|" (regexp-quote idt3) "\\|" (regexp-quote idt4) "\\)"))
! (setq mew-thread-indent-lregex
! (concat "[^"
! (regexp-quote
! (format "%c%c%c%c"
! (aref idt1 0) (aref idt2 0)
! (aref idt3 0) (aref idt4 0))) "]"))))
! (t
! (let* ((i 0)
! (size mew-thread-indent-array-size)
! (array (make-vector size nil))
! (indent ""))
! (while (< i size)
! (aset array i indent)
! (setq i (1+ i))
! (setq indent (concat indent mew-thread-indent-string)))
! (setq mew-thread-indent-array array))
! (setq mew-thread-indent-length (length mew-thread-indent-string))
! (setq mew-thread-indent-regex (regexp-quote mew-thread-indent-string))
! (setq mew-thread-indent-lregex
! (concat "[^"
! (regexp-quote
! (format "%c" (aref mew-thread-indent-string 0))) "]")))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
*************** (defun mew-summary-thread-region (beg en
*** 259,267 ****
(setq tm4 (current-time))
(message "Displaying thread ... ")
(setq tm5 (current-time))
! (mew-summary-thread-print-loop
! mew-virtual-buffer-thread-top 0 folder
! (mew-summary-scan-form folder 'column))
(setq tm6 (current-time))
;;
(if mark (mew-mark-undo-marks (list mew-mark-review)))
--- 316,330 ----
(setq tm4 (current-time))
(message "Displaying thread ... ")
(setq tm5 (current-time))
! (cond
! (mew-use-fancy-thread
! (mew-summary-fancy-thread-print-top
! mew-virtual-buffer-thread-top folder
! (mew-summary-scan-form folder 'column)))
! (t
! (mew-summary-thread-print-loop
! mew-virtual-buffer-thread-top 0 folder
! (mew-summary-scan-form folder 'column))))
(setq tm6 (current-time))
;;
(if mark (mew-mark-undo-marks (list mew-mark-review)))
*************** (defun mew-summary-thread-print (me leve
*** 312,317 ****
--- 375,436 ----
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
+ ;;; Visualizing thread (fancy style)
+ ;;;
+
+ (defun mew-summary-fancy-thread-print-top (top folder column)
+ (while top
+ (let* ((me (car top))
+ (cld (mew-thread-get-child me)))
+ (mew-elet
+ (insert (mew-thread-get-line me))
+ (forward-line -1)
+ (move-to-column column)
+ (if (search-forward "\r" nil t)
+ (insert " " folder " " (mew-thread-get-msg me)))
+ (forward-line))
+ (if cld
+ (mew-summary-fancy-thread-print-tree cld folder column))
+ (setq top (cdr top)))))
+
+ (defun mew-summary-fancy-thread-print-tree (tree folder column)
+ (let ((tree-stack nil)
+ (prefix "")
+ (level 0))
+ (while tree
+ (let* ((me (car tree))
+ (next (cdr tree))
+ (cld (mew-thread-get-child me)))
+ (mew-elet
+ (insert (mew-thread-get-line me))
+ (forward-line -1)
+ (move-to-column column)
+ (if next
+ (insert prefix (aref mew-fancy-thread-indent-strings 0))
+ (insert prefix (aref mew-fancy-thread-indent-strings 1)))
+ (if (search-forward "\r" nil t)
+ (insert " " folder " " (mew-thread-get-msg me)))
+ (forward-line))
+ (setq tree next)
+ (cond
+ (cld
+ (if next
+ (setq prefix
+ (concat prefix (aref mew-fancy-thread-indent-strings 2)))
+ (setq prefix
+ (concat prefix (aref mew-fancy-thread-indent-strings 3))))
+ (setq tree-stack (cons tree tree-stack))
+ (setq tree cld)
+ (setq level (1+ level)))
+ (t
+ (while (and (null tree) tree-stack)
+ (setq prefix (substring prefix 0 (- mew-thread-indent-length)))
+ (setq tree (car tree-stack))
+ (setq tree-stack (cdr tree-stack))
+ (setq level (1- level)))))))))
+
+ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+ ;;;
;;; Thread utilities
;;;
*************** (defun mew-summary-mark-select-thread ()
*** 320,335 ****
(interactive)
(let* ((folder (mew-summary-folder-name))
(column (mew-summary-scan-form folder 'column))
- (len (length mew-thread-indent-string))
- (fregex (regexp-quote mew-thread-indent-string))
(regex ""))
(save-excursion
(move-to-column column)
! (while (looking-at fregex)
! (setq regex (concat regex mew-thread-indent-string))
! (forward-char len))
! (setq regex (concat regex mew-thread-indent-string))
! (setq regex (regexp-quote regex))
(mew-summary-review-one 'no-msg)
(forward-line)
(catch 'loop
--- 439,451 ----
(interactive)
(let* ((folder (mew-summary-folder-name))
(column (mew-summary-scan-form folder 'column))
(regex ""))
(save-excursion
(move-to-column column)
! (while (looking-at mew-thread-indent-regex)
! (setq regex (concat regex mew-thread-indent-regex))
! (forward-char mew-thread-indent-length))
! (setq regex (concat regex mew-thread-indent-regex))
(mew-summary-review-one 'no-msg)
(forward-line)
(catch 'loop
*************** (defun mew-summary-thread-up ()
*** 347,360 ****
(mew-virtual-only
(let* ((folder (substring (mew-summary-folder-name 'ext) 1))
(column (mew-summary-scan-form folder 'column))
- (regex (regexp-quote mew-thread-indent-string))
here)
(save-excursion
(forward-line -1)
(catch 'loop
(while (not (bobp))
(move-to-column column)
! (if (looking-at regex)
(forward-line -1)
(throw 'loop (setq here (point)))))))
(if here
--- 463,475 ----
(mew-virtual-only
(let* ((folder (substring (mew-summary-folder-name 'ext) 1))
(column (mew-summary-scan-form folder 'column))
here)
(save-excursion
(forward-line -1)
(catch 'loop
(while (not (bobp))
(move-to-column column)
! (if (looking-at mew-thread-indent-regex)
(forward-line -1)
(throw 'loop (setq here (point)))))))
(if here
*************** (defun mew-summary-thread-down ()
*** 370,383 ****
(mew-virtual-only
(let* ((folder (substring (mew-summary-folder-name 'ext) 1))
(column (mew-summary-scan-form folder 'column))
- (regex (regexp-quote mew-thread-indent-string))
here)
(save-excursion
(forward-line)
(catch 'loop
(while (not (eobp))
(move-to-column column)
! (if (looking-at regex)
(forward-line)
(throw 'loop (setq here (point)))))))
(if here
--- 485,497 ----
(mew-virtual-only
(let* ((folder (substring (mew-summary-folder-name 'ext) 1))
(column (mew-summary-scan-form folder 'column))
here)
(save-excursion
(forward-line)
(catch 'loop
(while (not (eobp))
(move-to-column column)
! (if (looking-at mew-thread-indent-regex)
(forward-line)
(throw 'loop (setq here (point)))))))
(if here
*************** (defun mew-summary-thread-parent ()
*** 393,413 ****
(mew-virtual-only
(let* ((folder (mew-summary-folder-name))
(column (mew-summary-scan-form folder 'column))
- (len (length mew-thread-indent-string))
- (fregex (regexp-quote mew-thread-indent-string))
(regex "") lregex movep)
(save-excursion
(move-to-column column)
! (if (not (looking-at fregex))
()
(setq movep t)
! (forward-char len)
! (while (looking-at fregex)
! (setq regex (concat regex mew-thread-indent-string))
! (forward-char len))))
! (setq lregex (concat (regexp-quote regex)
! (format "[^%c]" (aref mew-thread-indent-string 0))))
! (setq regex (regexp-quote regex))
(if movep
(catch 'loop
(while t
--- 507,523 ----
(mew-virtual-only
(let* ((folder (mew-summary-folder-name))
(column (mew-summary-scan-form folder 'column))
(regex "") lregex movep)
(save-excursion
(move-to-column column)
! (if (not (looking-at mew-thread-indent-regex))
()
(setq movep t)
! (forward-char mew-thread-indent-length)
! (while (looking-at mew-thread-indent-regex)
! (setq regex (concat regex mew-thread-indent-regex))
! (forward-char mew-thread-indent-length))))
! (setq lregex (concat regex mew-thread-indent-lregex))
(if movep
(catch 'loop
(while t
Mew-dist メーリングリストの案内