2012年7月 6日

Re: Duplicate In-Reply-To entries in reply buffer

Hi,

> If I use "a" in the Summary buffer it sets up a draft buffer with the
> In-Reply-To field already correctly set. But if I then do "C-c C-y" in
> the draft buffer, an extry copy of the same message id gets appended
> onto the In-Reply-To field.
>
> It's possible that this has something to do with line wrapping and the

> unusual length of message-id's that our email system often
> generates.

The attached patch would fix handling of folded Message-ID: header.
But the patch is little tested (and not at all in some part).

--
Kazuhiro Ito

Content-Type: application/octet-stream; name="wl.diff"; type=patch
Content-Disposition: attachment; filename="wl.diff"
Content-Transfer-Encoding: 7bit

diff --git a/elmo/elmo-util.el b/elmo/elmo-util.el
index c4c821a..aea91bd 100644
--- a/elmo/elmo-util.el
+++ b/elmo/elmo-util.el
@@ -1296,6 +1296,18 @@ MESSAGE is a doing part of progress message."
(and value
(std11-unfold-string value))))

+(defun elmo-get-message-id-from-buffer ()
+ (let ((msgid (std11-field-body "Message-ID")))
+ (when msgid
+ (if (string-match "<.+>" msgid)
+ (match-string 0 msgid)
+ ;; Invaild message-id.
+ (substring msgid
+ (and (string-match "^[ \t\n]*" msgid)
+ (match-end 0))
+ (and (string-match "[ \t\n]*\\'" msgid)
+ (match-beginning 0)))))))
+
(defun elmo-decoded-field-body (field-name &optional mode)
(let ((field-body (elmo-field-body field-name)))
(and field-body
diff --git a/wl/wl-draft.el b/wl/wl-draft.el
index 2ec641d..b063b51 100644
--- a/wl/wl-draft.el
+++ b/wl/wl-draft.el
@@ -278,7 +278,7 @@ e.g.
(setq subject (wl-draft-forward-make-subject subject))
(setq references (nconc
(std11-field-bodies '("References" "In-Reply-To"))
- (list (std11-field-body "Message-Id"))))
+ (list (elmo-get-message-id-from-buffer))))
(setq references (delq nil references)
references (mapconcat 'identity references " ")
references (wl-draft-parse-msg-id-list-string references)
@@ -393,7 +393,7 @@ or `wl-draft-reply-with-argument-list' if WITH-ARG argument is non-nil."
(if decoder (funcall decoder addr) addr)))
cc)))
(setq subject (wl-draft-reply-make-subject subject))
- (setq in-reply-to (std11-field-body "Message-Id"))
+ (setq in-reply-to (elmo-get-message-id-from-buffer))
(setq references (nconc
(std11-field-bodies '("References" "In-Reply-To"))
(list in-reply-to)))
@@ -490,7 +490,7 @@ or `wl-draft-reply-with-argument-list' if WITH-ARG argument is non-nil."

(defun wl-draft-add-in-reply-to (&optional alt-field)
(let* ((mes-id (with-current-buffer mail-reply-buffer
- (std11-field-body "message-id")))
+ (elmo-get-message-id-from-buffer)))
(field (or alt-field "In-Reply-To"))
(ref (std11-field-body field))
(ref-list nil) (st nil))
@@ -903,7 +903,7 @@ to find out how to use this."
(wl-draft-set-sent-message 'mail 'unplugged)
;; send the message
(run-hooks 'wl-mail-send-pre-hook) ;; X-PGP-Sig, Cancel-Lock
- (let ((id (std11-field-body "Message-ID"))
+ (let ((id (elmo-get-message-id-from-buffer))
(to (std11-field-body "To")))
(case
(as-binary-process
@@ -1052,7 +1052,7 @@ non-nil."
(or wl-smtp-posting-server smtp-server "localhost"))
(smtp-service (or wl-smtp-posting-port smtp-service))
(smtp-local-domain (or smtp-local-domain wl-local-domain))
- (id (std11-field-body "message-id"))
+ (id (elmo-get-message-id-from-buffer))
recipients)
(if (not (elmo-plugged-p smtp-server smtp-service))
(wl-draft-set-sent-message 'mail 'unplugged
@@ -1132,7 +1132,7 @@ non-nil."
"Send the prepared message buffer with `sendmail-send-it'.
The function `sendmail-send-it' uses the external program
`sendmail-program'."
- (let ((id (std11-field-body "message-id"))
+ (let ((id (elmo-get-message-id-from-buffer))
(to (std11-field-body "to")))
(run-hooks 'wl-mail-send-pre-hook)
(require 'sendmail)
@@ -1237,7 +1237,7 @@ If FORCE-MSGID, insert message-id regardless of `wl-insert-message-id'."
wl-draft-fcc-list)
(setq wl-draft-fcc-list nil)))
(if wl-draft-use-cache
- (let ((id (std11-field-body "Message-ID"))
+ (let ((id (elmo-get-message-id-from-buffer))
(elmo-enable-disconnected-operation t))
(elmo-file-cache-save (elmo-file-cache-get-path id)
nil)))
@@ -1585,7 +1585,7 @@ If KILL-WHEN-DONE is non-nil, current draft buffer is killed"
(wl-draft-insert-required-fields t)
(goto-char (point-max))
(insert-buffer-substring send-mail-buffer header-end)
- (let ((id (std11-field-body "Message-ID"))
+ (let ((id (elmo-get-message-id-from-buffer))
(elmo-enable-disconnected-operation t))
(while fcc-list
(if (elmo-folder-append-buffer
@@ -1941,7 +1941,7 @@ If KILL-WHEN-DONE is non-nil, current draft buffer is killed"
(wl-draft-set-sent-message 'news 'sent)
(wl-draft-write-sendlog 'ok 'nntp elmo-nntp-default-server
(std11-field-body "Newsgroups")
- (std11-field-body "Message-ID")))))
+ (elmo-get-message-id-from-buffer)))))

(defun wl-draft-generate-clone-buffer (name &optional local-variables)
"Generate clone of current buffer named NAME."
@@ -2299,7 +2299,7 @@ Automatically applied in draft sending time."
(message "Queuing..."))
(let ((send-buffer (current-buffer))
(folder (wl-folder-get-elmo-folder wl-queue-folder))
- (message-id (std11-field-body "Message-ID")))
+ (message-id (elmo-get-message-id-from-buffer)))
(if (elmo-folder-append-buffer folder)
(progn
(wl-draft-queue-info-operation
diff --git a/wl/wl-summary.el b/wl/wl-summary.el
index bbc862e..d5fce1f 100644
--- a/wl/wl-summary.el
+++ b/wl/wl-summary.el
@@ -4682,7 +4682,7 @@ If ARG is numeric number, decode message as following:
(save-excursion
(setq from (std11-field-body "from")
newsgroups (std11-field-body "newsgroups")
- message-id (std11-field-body "message-id")
+ message-id (elmo-get-message-id-from-buffer)
distribution (std11-field-body "distribution"))
;; Make sure that this article was written by the user.
(unless (wl-address-user-mail-address-p
@@ -4733,7 +4733,7 @@ If ARG is numeric number, decode message as following:
(wl-address-header-extract-address
(car (wl-parse-addresses from))))
(error "This article is not yours"))
- (let* ((message-id (std11-field-body "message-id"))
+ (let* ((message-id (elmo-get-message-id-from-buffer))
(followup-to (std11-field-body "followup-to"))
(mail-default-headers
(concat mail-default-headers

投稿者 xml-rpc : 2012年7月 6日 22:31
役に立ちました?:
過去のフィードバック 平均:(0) 総合:(0) 投票回数:(0)
本記事へのTrackback: http://hoop.euqset.org/blog/mt-tb2006.cgi/110481
トラックバック
コメント
コメントする




画像の中に見える文字を入力してください。