From 3d7ccead87984baff63fc559aa0be159a98c9fde Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Mon, 7 Mar 2016 19:52:11 +0200 Subject: [PATCH] Re: [PATCH v6 4/6] emacs/mua: Generate improved cited text for replies --- 9b/6e1e4c6aad5d9ce92602f0037d54aec3f0641e | 270 ++++++++++++++++++++++ 1 file changed, 270 insertions(+) create mode 100644 9b/6e1e4c6aad5d9ce92602f0037d54aec3f0641e diff --git a/9b/6e1e4c6aad5d9ce92602f0037d54aec3f0641e b/9b/6e1e4c6aad5d9ce92602f0037d54aec3f0641e new file mode 100644 index 000000000..95c2b8734 --- /dev/null +++ b/9b/6e1e4c6aad5d9ce92602f0037d54aec3f0641e @@ -0,0 +1,270 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by arlo.cworth.org (Postfix) with ESMTP id 198AD6DE155C + for ; Mon, 7 Mar 2016 09:53:20 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: -0.551 +X-Spam-Level: +X-Spam-Status: No, score=-0.551 tagged_above=-999 required=5 tests=[AWL=0.169, + DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_LOW=-0.7, + RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01] autolearn=disabled +Received: from arlo.cworth.org ([127.0.0.1]) + by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id FXB4eeJulrvl for ; + Mon, 7 Mar 2016 09:53:17 -0800 (PST) +Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com + [74.125.82.67]) by arlo.cworth.org (Postfix) with ESMTPS id C26F86DE1410 for + ; Mon, 7 Mar 2016 09:53:16 -0800 (PST) +Received: by mail-wm0-f67.google.com with SMTP id 1so12094337wmg.2 + for ; Mon, 07 Mar 2016 09:53:16 -0800 (PST) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=nikula-org.20150623.gappssmtp.com; s=20150623; + h=from:to:subject:in-reply-to:references:user-agent:date:message-id + :mime-version:content-transfer-encoding; + bh=NXhpAqP6cDy4pE93MlSLy5iq8gabDOUapeshRQt1Td8=; + b=kL7t0ESNJ9mbgTmWevr4QcbHdIfEmlyhY+C8rzAwvCSNQp44DZm051GcExe6/I+k8q + m14Od7bwI7ONZ4ophno020VpHzDyIS3akShD3dzpdhkk5sBJFuvtCBUfXjJnWUnxOjbq + ysiHZtu7LpfFteU8caDcxCxZw3Jpvf9LgyLlp7Re7QCdi/XGKsbYRUAtrXenmkcxcS2c + ac6Ozue4T4MBCs3LJazkv23PeKlnabkIMyXwo5oCCEGODl5N31n3uDJvVwhdxNMl7ooz + jqpCM5p0ZazaD1pWeSGoc+OmSMvvBVkAJ5RdAnh+LlJ08qZXk35DzYL9QeaauepjwzS5 + 8DqQ== +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=1e100.net; s=20130820; + h=x-gm-message-state:from:to:subject:in-reply-to:references + :user-agent:date:message-id:mime-version:content-transfer-encoding; + bh=NXhpAqP6cDy4pE93MlSLy5iq8gabDOUapeshRQt1Td8=; + b=LM79nQcubzHV67lOXtHA4iopYVZxxYMOQm89V4h8w3o7vjqSoc9nvuXZCizeckaeXF + d7JeMoBsVfcSW+kY+tKHLgz6mXEZTVuF4WSD1im5z1PDGVMIH2r4V/x8Z6NBN6P2IOf4 + lDXFnm3ocONxvwyRvCIyjCDxbRIX6oejj1SeSStC5jpL5CBOMx0uVGgpGwxrnxv6wcTh + JPBD8y5RLTeiINErmGWo4YSdIzb2e1/d0ilL/rcEn4EIn6/kAIk7im77xjv5ptt0Ogl6 + VsWmX+Y/d4zp0y9Pq5oWsDG/xRdMve5abyUidIVU22TL/Iu06vFmCrcX5xqKOW3iCSmF + pEZw== +X-Gm-Message-State: + AD7BkJLYA7xlrSlFl7JwsKdv/XNCs0/3Fz+Tdhv+2+Gx+CqOvYoHYbKxtC5/eYKPWGoz/w== +X-Received: by 10.194.238.34 with SMTP id vh2mr28243348wjc.157.1457373195145; + Mon, 07 Mar 2016 09:53:15 -0800 (PST) +Received: from localhost (mobile-access-bcee39-255.dhcp.inet.fi. + [188.238.57.255]) + by smtp.gmail.com with ESMTPSA id gb9sm19056028wjb.26.2016.03.07.09.53.14 + (version=TLSv1/SSLv3 cipher=OTHER); + Mon, 07 Mar 2016 09:53:14 -0800 (PST) +From: Jani Nikula +To: Mark Walters , notmuch@notmuchmail.org +Subject: Re: [PATCH v6 4/6] emacs/mua: Generate improved cited text for + replies +In-Reply-To: <1455992680-24978-5-git-send-email-markwalters1009@gmail.com> +References: <1455992680-24978-1-git-send-email-markwalters1009@gmail.com> + <1455992680-24978-5-git-send-email-markwalters1009@gmail.com> +User-Agent: Notmuch/0.21+73~gf8cc320 (http://notmuchmail.org) Emacs/24.4.1 + (x86_64-pc-linux-gnu) +Date: Mon, 07 Mar 2016 19:52:11 +0200 +Message-ID: <87vb4y5g6s.fsf@nikula.org> +MIME-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Transfer-Encoding: quoted-printable +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.20 +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: Mon, 07 Mar 2016 17:53:20 -0000 + +On Sat, 20 Feb 2016, Mark Walters wrote: +> [ text/plain ] +> From: David Edmondson +> +> Use the message display code to generate message text to cite in +> replies. +> +> For now we set insert-headers-p function to +> notmuch-show-reply-insert-header-p-never so that, as before, we don't +> insert part buttons. +> +> With that choice of insert-headers-p function there is only one +> failing test: this test has a text part (an email message) listed as +> application/octet-stream. Notmuch show displays this part, but the +> reply code omitted it as it had type application/octet-stream. The new +> code correctly includes it. Thus update the expected output to match. + +For a message with mime structure: + +=E2=94=94=E2=94=AC=E2=95=B4multipart/mixed 120338 bytes + =E2=94=9C=E2=94=80=E2=95=B4text/html 59234 bytes + =E2=94=94=E2=94=80=E2=95=B4application/octet-stream attachment [filename.h= +tml] 59234 bytes + +this patch (i.e. commit e103f0a971b8 emacs/mua: Generate improved cited +text for replies) causes the application/octet-stream attachment to be +displayed, with: + +[ filename.html: application/octet-stream (as text/html) ] +!!! Bodypart insert error: Internal error: No :content from ("show" "--form= +at=3Dsexp" "--include-html" "--part=3D3" "--decrypt" "id:mid@example.com") = +!!! + +It is anyway followed by what looks like the contents of the attachment +in html, parsed and displayed properly. Running the above command does +not produce any output on the command line. + +Replies now include both text/html and the attachment cited. The cited +text also includes the error message. (To make matters worse, in this +particular case the two parts contain the same information, *sigh*. Not +sure anything can be done about that.) + +Is there a way to interactively choose which parts are cited in replies? + + +BR, +Jani. + + +> --- +> emacs/notmuch-mua.el | 43 +++++++++++++------------------------------ +> test/T310-emacs.sh | 32 ++++++++++++++++++++++++++++++++ +> 2 files changed, 45 insertions(+), 30 deletions(-) +> +> diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el +> index d4fad7b..ecc5bec 100644 +> --- a/emacs/notmuch-mua.el +> +++ b/emacs/notmuch-mua.el +> @@ -28,7 +28,7 @@ +>=20=20 +> (eval-when-compile (require 'cl)) +>=20=20 +> -(declare-function notmuch-show-insert-bodypart "notmuch-show" (msg part = +depth &optional hide)) +> +(declare-function notmuch-show-insert-body "notmuch-show" (msg body dept= +h)) +> (declare-function notmuch-fcc-header-setup "notmuch-maildir-fcc" ()) +> (declare-function notmuch-fcc-handler "notmuch-maildir-fcc" (destdir)) +>=20=20 +> @@ -144,31 +144,6 @@ (defun notmuch-mua-reply-crypto (parts) +> else if (notmuch-match-content-type (plist-get part :content-type) "mul= +tipart/*") +> do (notmuch-mua-reply-crypto (plist-get part :content)))) +>=20=20 +> -(defun notmuch-mua-get-quotable-parts (parts) +> - (loop for part in parts +> - if (notmuch-match-content-type (plist-get part :content-type) "multipar= +t/alternative") +> - collect (let* ((subparts (plist-get part :content)) +> - (types (mapcar (lambda (part) (plist-get part :content-type)) subpart= +s)) +> - (chosen-type (car (notmuch-multipart/alternative-choose types)))) +> - (loop for part in (reverse subparts) +> - if (notmuch-match-content-type (plist-get part :content-type) chosen= +-type) +> - return part)) +> - else if (notmuch-match-content-type (plist-get part :content-type) "mul= +tipart/*") +> - append (notmuch-mua-get-quotable-parts (plist-get part :content)) +> - else if (notmuch-match-content-type (plist-get part :content-type) "tex= +t/*") +> - collect part)) +> - +> -(defun notmuch-mua-insert-quotable-part (message part) +> - ;; We don't want text properties leaking from the show renderer into +> - ;; the reply so we use a temp buffer. Also we don't want hooks, such +> - ;; as notmuch-wash-*, to be run on the quotable part so we set +> - ;; notmuch-show-insert-text/plain-hook to nil. +> - (insert (with-temp-buffer +> - (let ((notmuch-show-insert-text/plain-hook nil)) +> - ;; Show the part but do not add buttons. +> - (notmuch-show-insert-bodypart message part 0 'no-buttons)) +> - (buffer-substring-no-properties (point-min) (point-max))))) +> - +> ;; 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, +> @@ -247,10 +222,18 @@ (defun notmuch-mua-reply (query-string &optional se= +nder reply-all) +> (insert "From: " from "\n") +> (insert "Date: " date "\n\n") +>=20=20 +> - ;; Get the parts of the original message that should be quoted; this in= +cludes +> - ;; all the text parts, except the non-preferred ones in a multipart/alt= +ernative. +> - (let ((quotable-parts (notmuch-mua-get-quotable-parts (plist-get origin= +al :body)))) +> - (mapc (apply-partially 'notmuch-mua-insert-quotable-part original) qu= +otable-parts)) +> + (insert (with-temp-buffer +> + (let +> + ;; Don't attempt to clean up messages, excerpt +> + ;; citations, etc. in the original message before +> + ;; quoting. +> + ((notmuch-show-insert-text/plain-hook nil) +> + ;; Don't omit long parts. +> + (notmuch-show-max-text-part-size 0) +> + ;; Insert headers for parts as appropriate for replying. +> + (notmuch-show-insert-header-p-function #'notmuch-show-reply-ins= +ert-header-p-never)) +> + (notmuch-show-insert-body original (plist-get original :body) 0) +> + (buffer-substring-no-properties (point-min) (point-max))))) +>=20=20 +> (set-mark (point)) +> (goto-char start) +> diff --git a/test/T310-emacs.sh b/test/T310-emacs.sh +> index 61bc369..22ca71c 100755 +> --- a/test/T310-emacs.sh +> +++ b/test/T310-emacs.sh +> @@ -473,6 +473,38 @@ Alex Botero-Lowry write= +s: +> > and http://mail-index.netbsd.org/pkgsrc-bugs/2006/06/07/msg016808.html= +specifically +> > uses 64 as the +> > buffer size. +> +> From e3bc4bbd7b9d0d086816ab5f8f2d6ffea1dd3ea4 Mon Sep 17 00:00:00 2001 +> +> From: Alexander Botero-Lowry +> +> Date: Tue, 17 Nov 2009 11:30:39 -0800 +> +> Subject: [PATCH] Deal with situation where sysconf(_SC_GETPW_R_SIZE_MA= +X) returns -1 +> +> +> +> --- +> +> notmuch-config.c | 2 ++ +> +> 1 files changed, 2 insertions(+), 0 deletions(-) +> +> +> +> diff --git a/notmuch-config.c b/notmuch-config.c +> +> index 248149c..e7220d8 100644 +> +> --- a/notmuch-config.c +> +> +++ b/notmuch-config.c +> +> @@ -77,6 +77,7 @@ static char * +> +> get_name_from_passwd_file (void *ctx) +> +> { +> +> long pw_buf_size =3D sysconf(_SC_GETPW_R_SIZE_MAX); +> +> + if (pw_buf_size =3D=3D -1) pw_buf_size =3D 64; +> +> char *pw_buf =3D talloc_zero_size (ctx, pw_buf_size); +> +> struct passwd passwd, *ignored; +> +> char *name; +> +> @@ -101,6 +102,7 @@ static char * +> +> get_username_from_passwd_file (void *ctx) +> +> { +> +> long pw_buf_size =3D sysconf(_SC_GETPW_R_SIZE_MAX); +> +> + if (pw_buf_size =3D=3D -1) pw_buf_size =3D 64; +> +> char *pw_buf =3D talloc_zero_size (ctx, pw_buf_size); +> +> struct passwd passwd, *ignored; +> +> char *name; +> +> --=20 +> +> 1.6.5.2 +> +> +> > _______________________________________________ +> > notmuch mailing list +> > notmuch@notmuchmail.org +> --=20 +> 2.1.4 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> https://notmuchmail.org/mailman/listinfo/notmuch -- 2.26.2