[Mew-dist 2524] Annotation on Mew

Kenji Gotsubo gotsubo at example.com
1997年 10月 16日 (木) 16:54:48 JST


五坪です。

Mewを使いはじめたのですが、私はどれにリプライしたかをすぐに忘れて
しまう鳥頭だったのを忘れていました。そこで、replied markを付ける機
能を作りました。

http://www.mew.org/info/info-j.html#SEC57
に書いてあるようなC-cC-qぐらいでは大丈夫ですが、出したメイルが相手
に届かなかった場合など、不完全なところもあります。
# ようするに、Error Mailのリカバリーはしていません。

imのannotate機能を使っていますので、
~/.im/Configに
Form=%5n %1x%m%d %-14A %S <<%b
Annotate=on
ScanSbr=scan.sbr
MsgDBFile=msgdb
などを記述する必要があります。

また、MsgDBを使っていますので、今までMsgDBを使ってなかった人は事前
に
% imhist --add=+inbox
とかしないと使えません。

mew-1.91にmew-anno.elを加えて、patchを当ててmake installして
(setq mew-annotation-use t)
をエバってお試し下さい。
手抜き実装なのはお許しを
# folder名に`,'使ってる人っていませんよね? (^^;;;

call-processしているので少し固まります。start-processに変えるのは
簡単なので、また後程要望があれば。

mew-anno.el
patch
scan.sbr
の順に添付しておきます。

  ()()    「顕微鏡なめてみていい?」
  ( ¨>・ 富士通株式会社 ソフトウェア事業本部
 〜( )    五坪 賢次 <gotsubo at example.com>
-------------- next part --------------
;;;			      mew-anno.el
;;;
;;;	      Copyright (C) 1997  Kenji Gotsubo
;;;
;;;		   This emacs lisp library conforms
;;;		GNU GENERAL PUBLIC LICENSE Version 2.
;;;
;;; Author:  Kenji Gotsubo <gotsubo at example.com>
;;; Created: Oct 14, 1997
;;; Revised: 
;;;

(defconst mew-anno-version "mew-anno.el version 0.1")

(require 'mew)

(defvar mew-imhist-buffer "*mew imhist*")
;; marks for annotation
(defvar mew-note-repl ?-)
;(defvar mew-note-forw ?F)
;(defvar mew-note-dist ?R)

(defvar mew-prog-imhist "imhist")

(defun mew-annotation (mark mid)
  (save-excursion
    (mapcar (function (lambda (a) (mew-annotate-mark-as mark a)))
	    (mew-get-consulting-message mid))))

(defun mew-get-consulting-message (mid)
  (let ((cbuf (current-buffer))
	(buf (set-buffer (get-buffer-create mew-imhist-buffer)))
	list)
    (mew-erase-buffer)
    (apply (function call-process) mew-prog-imhist nil buf nil
	   (list (format "--lookup=%s" mid)))
    (goto-char (point-min))
    (if (re-search-forward (format "^%s: " mew-prog-imhist) nil t)
	(progn
	  (set-buffer cbuf)
	  (kill-buffer buf))
      (goto-char (point-min))
      (while (re-search-forward "\\([-+=][^,]*\\)/\\([1-9]+[0-9]*\\)" nil t)
	(setq list (cons
		    (cons (buffer-substring (match-beginning 1)
					    (match-end 1))
			  (buffer-substring (match-beginning 2)
					    (match-end 2)))
		    list)))
;;	(sort list
;;	      (function (lambda (a b) (string< (car a) (car b)))))))))
      list)))

(defun mew-annotate-mark-as (mark cmsg)
  "Annotate mark this message"
    (let ((folder (car cmsg)))
      (cond ((get-buffer folder)
	     (set-buffer folder)
	     (let ((current (point))
		   (buffer-read-only nil))
	       (if (eq (mew-summary-jump-message (cdr cmsg)) t)
		   (progn
		     (beginning-of-line)
		     (re-search-forward (concat mew-summary-message-regex "."))
		     (delete-char 1)
		     (insert (char-to-string mark))
		     (if (eq major-mode 'mew-summary-mode)
			 (mew-decode-syntax-delete))
		     (mew-summary-folder-cache-save)
		     (goto-char current)))))
	    (t
	     (set-buffer (get-buffer-create folder))
	     (mew-set-file-coding-system mew-cs-scan mew-cs-scan)
	     (let ((cache (mew-expand-folder folder mew-summary-cache-file)))
	       (if (and mew-summary-cache-use (file-exists-p cache))
		   (progn
		     (insert-file-contents cache)
		     (mew-annotate-mark-as mark cmsg)))))
	    (kill-buffer folder))))

(provide 'mew-anno)
;; END
-------------- next part --------------
diff -r -c mew-1.91.OLD/mew-draft.el mew-1.91/mew-draft.el
*** mew-1.91.OLD/mew-draft.el	Thu Sep 18 10:27:20 1997
--- mew-1.91/mew-draft.el	Wed Oct 15 09:35:45 1997
***************
*** 604,609 ****
--- 604,610 ----
    (let* ((mimefolder (mew-draft-to-mime (buffer-name)))
  	 (mimedir (mew-expand-folder mimefolder))
  	 (msg (file-name-nondirectory (buffer-file-name)))
+ 	 (refmid (and mew-annotation-use (mew-header-get-value "References:")))
  	 (process-connection-type mew-connection-type1)
  	 (delete nil))
      (set-buffer-modified-p t)		; Make sure buffer is written
***************
*** 620,625 ****
--- 621,630 ----
  	    (set-window-configuration (mew-current-get 'window))
  	    (mew-current-set 'window nil))))
      (set-buffer (generate-new-buffer mew-buffer-watch))
+     ;; for annotation
+     (make-local-variable 'mew-consulting-message)
+     (setq mew-consulting-message (and refmid (cons mew-note-repl refmid)))
+ 
      ;; watch buffer
      (setq mew-watch-buffer-process
  	  (start-process "Send" (current-buffer)
***************
*** 657,662 ****
--- 662,672 ----
      (goto-char (point-min))
      (if (null (re-search-forward (format "^%s: ERROR:" mew-prog-imput) nil t))
  	(progn
+ 	  ;; for annotation
+ 	  (if mew-consulting-message
+ 	      (mew-annotation (car mew-consulting-message)
+ 			      (cdr mew-consulting-message)))
+ 
  	  (set-buffer cbuf)  ;; to avoid cursor-in-echo-area bug
  	  (kill-buffer kbuf) ;; set-buffer before kill-buffer
  	  )
diff -r -c mew-1.91.OLD/mew-summary.el mew-1.91/mew-summary.el
*** mew-1.91.OLD/mew-summary.el	Thu Sep 18 10:31:11 1997
--- mew-1.91/mew-summary.el	Wed Oct 15 08:39:43 1997
***************
*** 1776,1782 ****
       (t 
        (goto-char (point-min))
        (if (re-search-forward (format "^[ ]*%s[^0-9]+" msg) nil t) ;; xxx regex?
! 	  (beginning-of-line)
  	(goto-char here))))
      ))
  
--- 1776,1784 ----
       (t 
        (goto-char (point-min))
        (if (re-search-forward (format "^[ ]*%s[^0-9]+" msg) nil t) ;; xxx regex?
! 	  (progn
! 	    (beginning-of-line)
! 	    t)
  	(goto-char here))))
      ))
  
diff -r -c mew-1.91.OLD/mew.el mew-1.91/mew.el
*** mew-1.91.OLD/mew.el	Thu Sep 18 10:31:38 1997
--- mew-1.91/mew.el	Wed Oct 15 15:37:05 1997
***************
*** 117,122 ****
--- 117,124 ----
  (defvar mew-break-pages t)
  (defvar mew-page-delimiter "^\^L")
  
+ (defvar mew-annotation-use nil
+   "*If non-nil, mark replied mail")
  ;;
  ;; Highlight
  ;;
***************
*** 968,973 ****
--- 970,976 ----
  (require 'mew-ext)
  (require 'mew-fib)
  (require 'mew-sort)
+ (require 'mew-anno)
  ;;;
  ;;; End of Mew
  ;;;
-------------- next part --------------
$symbol_table{'x'} = 'anno:';
#$NEEDSAFE_HASH{'anno:} = 1;	# if the field contains JIS characters

sub scan_sub {
	local ($href) = shift;

	if (${$href}{'replied'} ne '') {
		${$href}{'anno:'} = '-';
#	} elsif (${$href}{'forwarded'} ne '') {
#		${$href}{'anno:'} = 'F';
#	} elsif (${$href}{'resent'} ne '') {
#		${$href}{'anno:'} = 'R';
	} else {
		${$href}{'anno:'} = ' ';
	}
}


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