Re: [PATCH v2] emacs: add function to toggle display of all multipart/alternative...
authorEthan Glasser-Camp <ethan.glasser.camp@gmail.com>
Fri, 19 Oct 2012 16:36:26 +0000 (12:36 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:49:53 +0000 (09:49 -0800)
fa/045484a3dff12c828c679dc4a6847aa2874ce6 [new file with mode: 0644]

diff --git a/fa/045484a3dff12c828c679dc4a6847aa2874ce6 b/fa/045484a3dff12c828c679dc4a6847aa2874ce6
new file mode 100644 (file)
index 0000000..e340c97
--- /dev/null
@@ -0,0 +1,155 @@
+Return-Path: <ethan.glasser.camp@gmail.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id AA36F431FB6\r
+       for <notmuch@notmuchmail.org>; Fri, 19 Oct 2012 09:36:33 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.776\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.776 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+       FREEMAIL_FROM=0.001, HS_INDEX_PARAM=0.023, RCVD_IN_DNSWL_LOW=-0.7]\r
+       autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id uuwMOSeZbhHR for <notmuch@notmuchmail.org>;\r
+       Fri, 19 Oct 2012 09:36:33 -0700 (PDT)\r
+Received: from mail-vb0-f53.google.com (mail-vb0-f53.google.com\r
+       [209.85.212.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id F11F8431FAE\r
+       for <notmuch@notmuchmail.org>; Fri, 19 Oct 2012 09:36:32 -0700 (PDT)\r
+Received: by mail-vb0-f53.google.com with SMTP id fc21so715065vbb.26\r
+       for <notmuch@notmuchmail.org>; Fri, 19 Oct 2012 09:36:32 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+       h=from:to:subject:in-reply-to:references:user-agent:date:message-id\r
+       :mime-version:content-type;\r
+       bh=FL+NLvrYWzganYQhz/+4PHAe7lOrthGsOWAPFykAvzA=;\r
+       b=TTdH7xc+7xr2l+nW1mcoACoR9uaX0T1+NDkCm4fUig5WZW7XQ08YYL9Vg/l325CQjI\r
+       fx6K3wJ0gGmbm59svbdzEm+zlH9VawSG/P3dcND8sAQ8E98e6D55lnHHmG51m5Ud0XGq\r
+       PpRrHimlk3VAP8QCV0E1b+i7et/Mh/SnGYA/i4AY70QCqoXgyj+bqMPUnS5JjUfmPqjl\r
+       yrw18vSxSFnFCVSQoZ8a0gqZiwKFJ8rwPVC6BVJyhO3N7UcD3CkOR3weja3j1GWxzWWb\r
+       fO02VrTXSYOMmYFL1RqawTKB1XiRkw+1lijN118KLQljeEvgaEDtqgMNYofFGqoiMbDA\r
+       tlLQ==\r
+Received: by 10.52.27.82 with SMTP id r18mr1818894vdg.120.1350664592262;\r
+       Fri, 19 Oct 2012 09:36:32 -0700 (PDT)\r
+Received: from smtp.gmail.com (p70-80.acedsl.com. [66.114.70.80])\r
+       by mx.google.com with ESMTPS id w17sm1921449vdf.16.2012.10.19.09.36.30\r
+       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Fri, 19 Oct 2012 09:36:30 -0700 (PDT)\r
+From: Ethan Glasser-Camp <ethan.glasser.camp@gmail.com>\r
+To: Mark Walters <markwalters1009@gmail.com>,\r
+       Jameson Graef Rollins <jrollins@finestructure.net>,\r
+       Jani Nikula <jani@nikula.org>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH v2] emacs: add function to toggle display of all\r
+       multipart/alternative parts\r
+In-Reply-To: <87r4rf9q8x.fsf@qmul.ac.uk>\r
+References: <1339775751-18002-1-git-send-email-jani@nikula.org>\r
+       <87zk80gvmb.fsf@servo.finestructure.net>\r
+       <87pq8vokmp.fsf@qmul.ac.uk>\r
+       <87ipcrvlcw.fsf@servo.finestructure.net>\r
+       <87r4rf9q8x.fsf@qmul.ac.uk>\r
+User-Agent: Notmuch/0.14+45~g6ea9330 (http://notmuchmail.org) Emacs/23.3.1\r
+       (x86_64-pc-linux-gnu)\r
+Date: Fri, 19 Oct 2012 12:36:26 -0400\r
+Message-ID: <87pq4e771x.fsf@betacantrips.com>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Fri, 19 Oct 2012 16:36:33 -0000\r
+\r
+Mark Walters <markwalters1009@gmail.com> writes:\r
+\r
+> Some messages are sent as multipart/alternative but the alternatives\r
+> contain different information. This allows the user to cycle which\r
+> part to view. By default this is bound to 'W'.\r
+> ---\r
+>\r
+> This version at least uses the notmuch escaping for message-id which\r
+> makes me a bit happier: it probably doesn't have any nasty security\r
+> flaws. I do still feel that the lisp is a bit ugly though.\r
+\r
+For what it's worth, I don't feel that this code is horrible. It seems\r
+like there remain design decisions to be made about how notmuch show\r
+"ought" to handle multipart/alternatives, but I can at least comment on\r
+this code.\r
+\r
+First, the use of a plist looks fine to me because most of the time it's\r
+going to have length 0. At most it will have one entry per message -- a\r
+few hundred. So I'm not worried about efficiency concerns.\r
+\r
+>  (defcustom notmuch-show-stash-mlarchive-link-alist\r
+>    '(("Gmane" . "http://mid.gmane.org/")\r
+>      ("MARC" . "http://marc.info/?i=")\r
+> @@ -536,9 +540,19 @@ message at DEPTH in the current thread."\r
+>  \r
+>  (defun notmuch-show-insert-part-multipart/alternative (msg part content-type nth depth declared-type)\r
+>    (notmuch-show-insert-part-header nth declared-type content-type nil)\r
+> -  (let ((chosen-type (car (notmuch-multipart/alternative-choose (notmuch-show-multipart/*-to-list part))))\r
+> -    (inner-parts (plist-get part :content))\r
+> -    (start (point)))\r
+> +  (let* ((chosen-nth (or (lax-plist-get notmuch-show-message-multipart/alternative-display-part\r
+> +                                    (notmuch-id-to-query (plist-get msg :id))) 0))\r
+> +     (chosen-type (nth chosen-nth\r
+> +                      (notmuch-multipart/alternative-choose (notmuch-show-multipart/*-to-list part))))\r
+> +     (inner-parts (plist-get part :content))\r
+> +     (start (point)))\r
+\r
+Changing let to let* makes me the slightest bit uneasy, although I'm not\r
+sure I could explain why.\r
+\r
+It would be nice if you could wrap the manipulation of\r
+notmuch-show-message-multipart/alternative-display-part in functions,\r
+ideally with names that are shorter than the variable they\r
+manipulate. Specifically, I think the definition of chosen-nth (which is\r
+almost repeated below) could be its own function, something like\r
+(notmuch-show-message-current-multipart msg), which could take a msg-id\r
+or a plist and do the plist-get and id-to-query that you do here.\r
+\r
+> +    ;; If we have run out of possible content-types restart from the beginning\r
+> +    (unless chosen-type\r
+> +      (setq chosen-type (car (notmuch-multipart/alternative-choose (notmuch-show-multipart/*-to-list part))))\r
+> +      (setq notmuch-show-message-multipart/alternative-display-part\r
+> +        (lax-plist-put notmuch-show-message-multipart/alternative-display-part\r
+> +                       (notmuch-id-to-query (plist-get msg :id)) 0)))\r
+> +\r
+>      ;; This inserts all parts of the chosen type rather than just one,\r
+>      ;; but it's not clear that this is the wrong thing to do - which\r
+>      ;; should be chosen if there are more than one that match?\r
+> @@ -942,6 +956,16 @@ message at DEPTH in the current thread."\r
+>           "Not processing cryptographic MIME parts."))\r
+>    (notmuch-show-refresh-view))\r
+>  \r
+> +(defun notmuch-show-cycle-message-multipart ()\r
+> +  "Cycle which part to display of a multipart messageToggle the display of non-matching messages."\r
+\r
+This docstring is broken.\r
+\r
+> +  (interactive)\r
+> +  (let* ((msg-id (notmuch-show-get-message-id))\r
+> +     (next-part (1+ (or (lax-plist-get notmuch-show-message-multipart/alternative-display-part msg-id) 0))))\r
+> +    (setq notmuch-show-message-multipart/alternative-display-part\r
+> +    (lax-plist-put notmuch-show-message-multipart/alternative-display-part msg-id next-part))\r
+> +    (message "Cycling multipart/alternative for current message")\r
+> +    (notmuch-show-refresh-view)))\r
+\r
+Maybe move the reset-and-go-back-to-zero behavior to this function\r
+instead of in the display function. This opens you up to weird\r
+situations if one of the multipart/alternatives should disappear from a\r
+message or if some other function should change the alternative on\r
+display for a given message, but both of these seem unlikely to me..\r
+\r
+Ethan\r