From: Adam Wolfe Gordon Date: Thu, 29 Mar 2012 04:53:38 +0000 (+1800) Subject: [BUG/PATCH v2] emacs: Fix the References header in reply X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=dfc86c551eb4a945591f4c23213d6a65d58cc7ca;p=notmuch-archives.git [BUG/PATCH v2] emacs: Fix the References header in reply --- diff --git a/3e/94a5d01e7a2877db42a4fe3711865634f9dbb5 b/3e/94a5d01e7a2877db42a4fe3711865634f9dbb5 new file mode 100644 index 000000000..8a5edc82a --- /dev/null +++ b/3e/94a5d01e7a2877db42a4fe3711865634f9dbb5 @@ -0,0 +1,124 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id F10EA431FAF + for ; Wed, 28 Mar 2012 21:53:41 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_NONE=-0.0001] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id aYPiasV9jZ6O for ; + Wed, 28 Mar 2012 21:53:41 -0700 (PDT) +Received: from idcmail-mo2no.shaw.ca (idcmail-mo2no.shaw.ca [64.59.134.9]) + by olra.theworths.org (Postfix) with ESMTP id 76BE6431FAE + for ; Wed, 28 Mar 2012 21:53:41 -0700 (PDT) +Received: from lb7f8hsrpno-svcs.dcs.int.inet (HELO pd7ml1no-ssvc.prod.shaw.ca) + ([10.0.144.222]) + by pd7mo1no-svcs.prod.shaw.ca with ESMTP; 28 Mar 2012 22:53:41 -0600 +X-Cloudmark-SP-Filtered: true +X-Cloudmark-SP-Result: v=1.1 cv=Ro8QOmc0aMDfanRtxUddlQ8SbE2D0zCZP8MBHZpYE5w= + c=1 sm=1 + a=82UIbAjXKL0A:10 a=BLceEmwcHowA:10 a=yQp6g8lIsgqumF79BAsFDg==:17 + a=4U69qDNLMXPqwlrapeIA:9 a=R8Bxcb_Lm8ZuesaYTjMA:7 + a=HpAAvcLHHh0Zw7uRqdWCyQ==:117 +Received: from unknown (HELO lagos.xvx.ca) ([96.52.216.56]) + by pd7ml1no-dmz.prod.shaw.ca with ESMTP; 28 Mar 2012 22:53:40 -0600 +Received: by lagos.xvx.ca (Postfix, from userid 1000) + id 4D0AD8004204; Wed, 28 Mar 2012 22:53:40 -0600 (MDT) +From: Adam Wolfe Gordon +To: notmuch@notmuchmail.org +Subject: [BUG/PATCH v2] emacs: Fix the References header in reply +Date: Wed, 28 Mar 2012 22:53:38 -0600 +Message-Id: <1332996818-15700-1-git-send-email-awg+notmuch@xvx.ca> +X-Mailer: git-send-email 1.7.5.4 +In-Reply-To: <1332991226-510-1-git-send-email-awg+notmuch@xvx.ca> +References: <1332991226-510-1-git-send-email-awg+notmuch@xvx.ca> +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Thu, 29 Mar 2012 04:53:42 -0000 + +In the new reply code, the References header gets inserted by +message.el using a function called message-shorten-references. Unlike +all the other header-inserting functions, it doesn't put a newline +after the header, causing the next header to end up on the same +line. In our case, this header happened to be User-Agent, so it's hard +to notice. This is probably a bug in message.el, but we need to work +around it. + +This fixes the problem by wrapping message-shorten-references in a +function that inserts a newline after if necessary. This should +protect against the message.el bug being fixed in the future. +--- + +This version adds the local variables to suppress 'cl warings, per +id:"1332995623-9055-1-git-send-email-amdragon@mit.edu". + + emacs/notmuch-mua.el | 26 +++++++++++++++++++++++--- + 1 files changed, 23 insertions(+), 3 deletions(-) + +diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el +index 24918d3..0d3fcd3 100644 +--- a/emacs/notmuch-mua.el ++++ b/emacs/notmuch-mua.el +@@ -90,6 +90,15 @@ list." + else if (notmuch-match-content-type (plist-get part :content-type) "text/*") + collect part)) + ++;; There is a bug in emacs 23's message.el that results in a newline ++;; not being inserted after the References header, so the next header ++;; is concatenated to the end of it. This function fixes the problem, ++;; while guarding against the possibility that some current or future ++;; version of emacs has the bug fixed. ++(defun notmuch-mua-insert-references (header references) ++ (message-shorten-references header references) ++ (unless (bolp) (insert "\n"))) ++ + (defun notmuch-mua-reply (query-string &optional sender reply-all) + (let ((args '("reply" "--format=json")) + reply +@@ -125,9 +134,16 @@ list." + ;; Overlay the composition window on that being used to read + ;; the original message. + ((same-window-regexps '("\\*mail .*"))) +- (notmuch-mua-mail (plist-get reply-headers :To) +- (plist-get reply-headers :Subject) +- (notmuch-plist-to-alist reply-headers))) ++ ++ ;; We modify message-header-format-alist to get around a bug in message.el. ++ ;; See the comment above on notmuch-mua-insert-references. ++ (let ((message-header-format-alist ++ (append '((References . notmuch-mua-insert-references)) ++ (remove-if (lambda (x) (eq (car x) 'References)) ++ message-header-format-alist)))) ++ (notmuch-mua-mail (plist-get reply-headers :To) ++ (plist-get reply-headers :Subject) ++ (notmuch-plist-to-alist reply-headers)))) + ;; Insert the message body - but put it in front of the signature + ;; if one is present + (goto-char (point-max)) +@@ -301,3 +317,7 @@ simply runs the corresponding `message-mode' hook functions." + ;; + + (provide 'notmuch-mua) ++ ++;; Local Variables: ++;; byte-compile-warnings: (not cl-functions) ++;; End: +-- +1.7.5.4 +