[Mew-dist 15560] Re: friendly-addr
Shun-ichi TAHARA ( 田原 俊一 )
jado at example.com
2000年 12月 18日 (月) 12:56:46 JST
From: Shun-ichi TAHARA (田原 俊一) <jado at example.com>
Message-Id: <20001214.222821.35030751.jado at example.com>
> 以前、[Mew-dist 14438] あたりで、「mew-scan-form-friendly-addr」の抜き
> 出し規則を変えてほしいという話をしましたが、抜き出し規則をカスタマイズ
> 可能にしましたので、改めてパッチを投げます。
> ちなみに、(setq mew-scan-form-friendly-addr-rule nil) で、必ず From:
> がまるごと返るようになるので、実は mew-scan-form-from-name-only が要ら
> なくなるのかもしれません。というわけで、マージするのならこのあたりも整
> 理した方がいいかも。
ということで、整理してみました。
scan時の From: 表示の挙動は、mew-scan-form-extract-rule 1本で制御でき
ます(あ、あと mew-scan-form-from-me-prefix ですね)。
これには、name, comment, address, nickname のいずれかのシンボルか、正
規表現からなる文字列のリストを設定できます。どれにもひっかからなければ、
へッダの文字列がそのまま出ます。
mew-scan-form-from-name-only と mew-scan-form-from-addr-only は消えて
いて、それぞれ、下記のようなmew-scan-form-extract-ruleの値で置き換えら
れます(100%完全に同じ挙動というわけではありませんが)。
・デフォルト
(mew-scan-form-from-name-only, mew-scan-form-from-addr-onlyともnil)
→ '(nickname)
・mew-scan-form-from-addr-onlyがt
→ '(address)
・mew-scan-form-from-name-onlyがt
→ '(nickname name comment address)
_______________________________
田原 俊一 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 --------------
diff -rc -F^( mew-1.95b90.orig/mew-scan.el mew-1.95b90/mew-scan.el
*** mew-1.95b90.orig/mew-scan.el Fri Dec 15 15:13:28 2000
--- mew-1.95b90/mew-scan.el Mon Dec 18 12:23:18 2000
*************** (defun mew-scan-form-size ()
*** 118,136 ****
"0k"
(concat (int-to-string size) unit)))))
! (defun mew-scan-form-friendly-addr (addr)
! "Extract phrase part of ADDR if exists and returns it.
! Next, extract comment part if exists and returns it.
! Otherwise ADDR is returned."
! (cond
! ((string-match "\\([^<]+\\)<[^>]+>" addr)
! (mew-chop (mew-match 1 addr)))
! ((string-match "^[^(]+(\\(.+\\))" addr)
! ;; Removing comments even if recursive.
! (mew-chop (mew-match 1 addr)))
! ((string-match "^[ \t]*<\\([^>]+\\)>" addr)
! (mew-chop (mew-match 1 addr)))
! (t addr)))
(defun mew-scan-form-from ()
"A function to return an address.
--- 118,149 ----
"0k"
(concat (int-to-string size) unit)))))
! (defun mew-scan-form-extract-addr (addr)
! "Extract addr according to 'mew-scan-form-extract-rule'."
! (let* ((func (if mew-addrbook-for-summary
! (mew-addrbook-func mew-addrbook-for-summary)))
! (raw (or (mew-addrstr-parse-address addr) ""))
! (nickname (if func (funcall func raw))))
! (catch 'matched
! (mapcar
! '(lambda (rule)
! (cond
! ((and (eq rule 'name)
! (or (string-match "^\"\\([^\"]+\\)\"[ \t]*<[^>]+>" addr)
! (string-match "^\\([^<]+\\)<[^>]+>" addr)))
! (throw 'matched (mew-chop (mew-match 1 addr))))
! ((and (eq rule 'comment)
! (string-match "^[^(]+(\\(.+\\))" addr))
! (throw 'matched (mew-chop (mew-match 1 addr))))
! ((eq rule 'address)
! (throw 'matched raw))
! ((and (eq rule 'nickname) nickname)
! (throw 'matched nickname))
! ((and (stringp rule)
! (string-match rule addr))
! (throw 'matched (mew-chop (mew-match 1 addr))))))
! mew-scan-form-extract-rule)
! addr)))
(defun mew-scan-form-from ()
"A function to return an address.
*************** (defun mew-scan-form-from ()
*** 140,177 ****
Otherwise, an address on From: is returned.
! Addrbook is used to converted an address to be retuned if
! mew-addrbook-for-summary is defined."
! (let ((func (if mew-addrbook-for-summary
! (mew-addrbook-func mew-addrbook-for-summary)))
! (FROM (MEW-FROM)) (TO (MEW-TO))
! from to nickname ret)
! (if (string= FROM "")
! ""
! (setq from (or (mew-addrstr-parse-address FROM) ""))
! (cond
! ((and (stringp mew-scan-form-from-me-prefix)
! (not (string= TO ""))
! (mew-is-my-address mew-regex-my-address-list from))
! (setq to (or (mew-addrstr-parse-address TO) ""))
! (if mew-scan-form-from-addr-only
! (setq ret to)
! (if (and to func (setq nickname (funcall func to)))
! (setq ret nickname)
! (if mew-scan-form-from-name-only
! (setq ret (mew-scan-form-friendly-addr TO))
! (setq ret TO))))
! (mew-replace-white-space
! (concat mew-scan-form-from-me-prefix ret)))
! (t
! (if mew-scan-form-from-addr-only
! (setq ret from)
! (if (and from func (setq nickname (funcall func from)))
! (setq ret nickname)
! (if mew-scan-form-from-name-only
! (setq ret (mew-scan-form-friendly-addr FROM))
! (setq ret FROM))))
! (mew-replace-white-space ret))))))
(defun mew-scan-form-subj ()
"A function to return Subject:. Unnecessary white spaces are removed."
--- 153,172 ----
Otherwise, an address on From: is returned.
! Address is converted by 'mew-scan-form-extract-addr'. See also
! 'mew-scan-form-extract rule'."
! (let* ((FROM (MEW-FROM)) (TO (MEW-TO))
! (from (or (mew-addrstr-parse-address FROM) "")))
! (cond
! ((string= FROM "")
! "")
! ((and (stringp mew-scan-form-from-me-prefix)
! (not (string= TO ""))
! (mew-is-my-address mew-regex-my-address-list from))
! (mew-replace-white-space
! (concat mew-scan-form-from-me-prefix (mew-scan-form-extract-addr TO))))
! (t
! (mew-replace-white-space (mew-scan-form-extract-addr FROM))))))
(defun mew-scan-form-subj ()
"A function to return Subject:. Unnecessary white spaces are removed."
Only in mew-1.95b90: mew-scan.el~
diff -rc -F^( mew-1.95b90.orig/mew-vars.el mew-1.95b90/mew-vars.el
*** mew-1.95b90.orig/mew-vars.el Fri Dec 15 13:43:27 2000
--- mew-1.95b90/mew-vars.el Mon Dec 18 11:44:27 2000
*************** (defvar mew-scan-form-from-me-prefix "To
*** 505,521 ****
"*The prefix to be prepend to an destination address
if the message is originated by me.")
! (defvar mew-scan-form-from-name-only nil
! "*If non-nil, name or comment part is extracted from the From: field.
! E.g.
! \"Kazu Yamamoto <kazu at example.com>\" -> \"Kazu Yamamoto\"
! ")
! (defvar mew-scan-form-from-addr-only nil
! "*If non-nil, an address part is extracted from the From: field.
! E.g.
! \"Kazu Yamamoto <kazu at example.com>\" -> \"kazu at example.com\"
! ")
(defvar mew-scan-form-mark-delete nil
"*If non-nil, the 'D' mark automatically is put onto
--- 505,540 ----
"*The prefix to be prepend to an destination address
if the message is originated by me.")
! (defvar mew-scan-form-extract-rule '(nickname)
! "*A list to specify what part to extract from the From: field. Each
! element must be one of below symbols, or any regex.
! 'name Name part, if any
! A: Kazu Yamamoto
! B: (No match)
! C: Kazuhiko Yamamoto (Kazu)
! 'comment Comment part, if any
! A: (No match)
! B: Kazu Yamamoto
! C: (Kazu)
! 'address Address part
! A: kazu at example.com
! B: kazu at example.com
! C: kazu at example.com
! 'nickname Nickname converted with addrbook, if found
! and mew-addrbook-for-summary is defined
! (regex) The substring first matched, if matched
!
! \"A\", \"B\" and \"C\" listed above explains how the examples below are
! to be extracted:
!
! A: Kazu Yamamoto <kazu at example.com>
! B: kazu at example.com (Kazu Yamamoto)
! C: Kazuhiko Yamamoto (Kazu) <kazu at example.com>
!
! If a element does not match, the next element is applied. If no
! element matches to the From: field, or this value is nil, the whole
! of the From: field is used.")
(defvar mew-scan-form-mark-delete nil
"*If non-nil, the 'D' mark automatically is put onto
Only in mew-1.95b90: mew-vars.el~
Mew-dist メーリングリストの案内