[Mew-dist 2794] Re: color of citation in Message buffer

SAKAI Kiyotaka ksakai at example.com
1997年 10月 29日 (水) 13:07:15 JST


>> In article <19971029101112K.kazu at example.com>, Kazu Yamamoto (山本和彦) <Kazu at example.com> writes:

>> それならば、機能だけは取り込んでおいて、デフォルトでオフにしておくだけ
>> でいいのではないでしょうか?
>> 
>> いくつかの変数の設定だけで使えるようにしておく方が user friendly かと
>> 思いますが、どうでしょうか。

> この意見自体には賛成です。

> しばらく、Kernel ハッカーに戻るので、だれかやってくれると嬉しいです。

contrib/mew-highlight-body.el 相当のものを作ってみました。
誰か試してもらえると助かります。
テストのために、mew-opt-highlight-body のデフォルト値は t にしてあります。

# 今のコードは n 個 regex が書いてあると、n 回 re-search-forward を実
# 行するようになっていますが、他にいいアルゴリズムがあればそちらを使い
# たいです。
-- 
酒井 清隆 (E-mail: ksakai at example.com)

 
Index: mew-highlight.el
===================================================================
RCS file: /home/cvsroot/mew-1.92.1/mew-highlight.el,v
retrieving revision 1.2
diff -u -r1.2 mew-highlight.el
--- mew-highlight.el	1997/10/28 10:40:43	1.2
+++ mew-highlight.el	1997/10/29 04:02:28
@@ -26,6 +26,8 @@
   "*Paint marked lines in Summary mode.")
 (defvar mew-opt-highlight-header t
   "*Paint header in Message and Draft mode.")
+(defvar mew-opt-highlight-body t
+  "*Paint body in Message mode.")
 (defvar mew-opt-highlight-url t
   "*Emphasize URL lines in Message mode.")
 (defvar mew-opt-highlight-url-regex
@@ -35,6 +37,8 @@
 (defvar mew-opt-highlight-x-face mew-xemacs-p
   "*Iconify X-Face: on XEmacs in Message mode.")
 
+(defvar mew-highlight-max-size 10000)
+
 ;;
 ;; Styles and colors
 ;;
@@ -82,6 +86,21 @@
 (defvar mew-highlight-header-color-marginal  "gray50")
 (defvar mew-highlight-header-color-xmew      "Red")
 
+(defvar mew-highlight-body-face-list
+  '(mew-highlight-body-face-quote
+    mew-highlight-body-face-comment)
+  "*A list of face symbol name to highlight body.
+Each name should be 'mew-highlight-body-face-xxx'.
+Each face will be created from 'mew-highlight-body-sytel-xxx' and
+'mew-highlight-body-color-xxx'. These faces can be used in
+'mew-highlight-body-keywords'.")
+
+(defvar mew-highlight-body-style-quote   'default)
+(defvar mew-highlight-body-style-comment 'default)
+
+(defvar mew-highlight-body-color-quote   "ForestGreen")
+(defvar mew-highlight-body-color-comment "gray50")
+
 ;; xxx hard coding...
 (defvar mew-highlight-mark-folder-list '("+inbox")
   "*A folder list to highligh marked lines.")
@@ -128,7 +147,15 @@
      mew-highlight-header-face-marginal))
   "*A list of (\"header-key-regex\" face-for-key face-for-value).
 This is used to highlight header.")
-  
+
+(defvar mew-highlight-body-keywords
+  '(("^[ \t]*\\(\\w*[A-Za-z0-9'-]*[>|>〉》≫|]+.*\\)"
+     mew-highlight-body-face-quote)
+    ("^[##]+.*"
+     mew-highlight-body-face-comment))
+  "*A list of (\"body-key-regex\" face-for-body).
+This is used to highlight body.")
+
 (defvar mew-highlight-mark-keywords
   (list 
    (cons mew-mark-review 'mew-highlight-mark-face-review)
@@ -245,6 +272,28 @@
 		    (mew-overlay-put overlay 'face (nth 2 assoc)))
 		(while (looking-at "[ \t]") (forward-line)))))))))
 
+(defun mew-highlight-body ()
+  "A function to highligh body in Message mode."
+  (if (and window-system mew-opt-highlight-body)
+      (save-excursion
+	(save-restriction
+	  (let ((buffer-read-only nil)
+		(p (point))
+		beg1 end1 overlay)
+	    (search-forward "\n\n" nil t)
+	    (narrow-to-region (point) (point-max))
+	    (mapcar
+	     (function
+	      (lambda (arg)
+		(goto-char p)
+		(while (re-search-forward (car arg) mew-highlight-max-size t)
+		  (setq beg1 (match-beginning 0))
+		  (setq end1 (match-end 0))
+		  (setq overlay (mew-overlay-make beg1 end1))
+		  (mew-overlay-put overlay 'face (cdr arg))
+		  (forward-line))))
+	     mew-highlight-body-keywords))))))
+
 ;;
 ;; X-Face:
 ;;
@@ -314,6 +363,7 @@
 	  (set-face-foreground fname (symbol-value color))))))
 
 (mew-highlight-face-setup mew-highlight-header-face-list)
+(mew-highlight-face-setup mew-highlight-body-face-list)
 (mew-highlight-face-setup mew-highlight-mark-face-list)
 
 (provide 'mew-highlight)
Index: mew-summary.el
===================================================================
RCS file: /home/cvsroot/mew-1.92.1/mew-summary.el,v
retrieving revision 1.3
diff -u -r1.3 mew-summary.el
--- mew-summary.el	1997/10/29 01:01:26	1.3
+++ mew-summary.el	1997/10/29 04:02:52
@@ -823,6 +823,7 @@
 	))
       (setq mew-decode-result nil)
       (mew-highlight-url)
+      (mew-highlight-body)
       (run-hooks 'mew-message-hook)
       )
     (set-buffer-modified-p nil)
@@ -910,6 +911,7 @@
     (if non-erase
 	()
       (mew-highlight-url)
+      (mew-highlight-body)
       (run-hooks 'mew-message-hook)
       (set-buffer-modified-p nil) ;; xxx message buffer
       )



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