--- /dev/null
+Return-Path: <m.walters@qmul.ac.uk>\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 0C81F431FB6\r
+ for <notmuch@notmuchmail.org>; Sun, 28 Oct 2012 01:01:12 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -1.075\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-1.075 tagged_above=-999 required=5\r
+ tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,\r
+ HS_INDEX_PARAM=0.023, NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3]\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 uUOXOQCC5nuQ for <notmuch@notmuchmail.org>;\r
+ Sun, 28 Oct 2012 01:01:08 -0700 (PDT)\r
+Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])\r
+ (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id F2816431FAF\r
+ for <notmuch@notmuchmail.org>; Sun, 28 Oct 2012 01:01:07 -0700 (PDT)\r
+Received: from smtp.qmul.ac.uk ([138.37.6.40])\r
+ by mail2.qmul.ac.uk with esmtp (Exim 4.71)\r
+ (envelope-from <m.walters@qmul.ac.uk>)\r
+ id 1TSNno-0001kV-24; Sun, 28 Oct 2012 08:01:04 +0000\r
+Received: from 93-97-24-31.zone5.bethere.co.uk ([93.97.24.31] helo=localhost)\r
+ by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69)\r
+ (envelope-from <m.walters@qmul.ac.uk>)\r
+ id 1TSNnn-0001HH-L1; Sun, 28 Oct 2012 08:00:59 +0000\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: Ethan Glasser-Camp <ethan.glasser.camp@gmail.com>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH (draft) 1/2] emacs: allow the user to toggle the\r
+ visibility of multipart/alternative parts\r
+In-Reply-To: <87sj8zh2zy.fsf@betacantrips.com>\r
+References: <1351152563-27277-1-git-send-email-markwalters1009@gmail.com>\r
+ <1351152563-27277-2-git-send-email-markwalters1009@gmail.com>\r
+ <87sj8zh2zy.fsf@betacantrips.com>\r
+User-Agent: Notmuch/0.14+69~g024ea36 (http://notmuchmail.org) Emacs/23.4.1\r
+ (i486-pc-linux-gnu)\r
+Date: Sun, 28 Oct 2012 08:00:58 +0000\r
+Message-ID: <87objnkoud.fsf@qmul.ac.uk>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+X-Sender-Host-Address: 93.97.24.31\r
+X-QM-SPAM-Info: Sender has good ham record. :)\r
+X-QM-Body-MD5: e97fb7d8e7c9c1ff2b54acf6e29a6b82 (of first 20000 bytes)\r
+X-SpamAssassin-Score: -1.5\r
+X-SpamAssassin-SpamBar: -\r
+X-SpamAssassin-Report: The QM spam filters have analysed this message to\r
+ determine if it is\r
+ spam. We require at least 5.0 points to mark a message as spam.\r
+ This message scored -1.5 points.\r
+ Summary of the scoring: \r
+ * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/,\r
+ * medium trust\r
+ * [138.37.6.40 listed in list.dnswl.org]\r
+ * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\r
+ provider * (markwalters1009[at]gmail.com)\r
+ * 0.5 QM_SPAMMYURI URI: \".info\" uri is common in spam.\r
+ * 0.3 AWL AWL: From: address is in the auto white-list\r
+X-QM-Scan-Virus: ClamAV says the message is clean\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: Sun, 28 Oct 2012 08:01:12 -0000\r
+\r
+\r
+Ethan Glasser-Camp <ethan.glasser.camp@gmail.com> writes:\r
+\r
+> Mark Walters <markwalters1009@gmail.com> writes:\r
+>\r
+>> This patch adds a keybinding to the buttons in the notmuch-show emacs\r
+>> buffer to allow the user to toggle the visibility of each part of a\r
+>> message in the show buffer. This is particularly useful for\r
+>> multipart/alternative parts where the parts are not really\r
+>> alternatives but contain different information.\r
+>> ---\r
+>> emacs/notmuch-show.el | 47 +++++++++++++++++++++++++++++++++++++++--------\r
+>> 1 files changed, 39 insertions(+), 8 deletions(-)\r
+>>\r
+>> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+>> index 0f54259..9157669 100644\r
+>> --- a/emacs/notmuch-show.el\r
+>> +++ b/emacs/notmuch-show.el\r
+>> @@ -155,6 +155,10 @@ indentation."\r
+>> (make-variable-buffer-local 'notmuch-show-indent-content)\r
+>> (put 'notmuch-show-indent-content 'permanent-local t)\r
+>>\r
+>> +(defvar notmuch-show-message-multipart/alternative-display-parts nil)\r
+>> +(make-variable-buffer-local 'notmuch-show-message-multipart/alternative-display-parts)\r
+>> +(put 'notmuch-show-message-multipart/alternative-display-parts 'permanent-local t)\r
+>> +\r
+>> (defcustom notmuch-show-stash-mlarchive-link-alist\r
+>> '(("Gmane" . "http://mid.gmane.org/")\r
+>> ("MARC" . "http://marc.info/?i=")\r
+>> @@ -455,6 +459,7 @@ message at DEPTH in the current thread."\r
+>> (define-key map "v" 'notmuch-show-part-button-view)\r
+>> (define-key map "o" 'notmuch-show-part-button-interactively-view)\r
+>> (define-key map "|" 'notmuch-show-part-button-pipe)\r
+>> + (define-key map "t" 'notmuch-show-part-button-internally-show)\r
+>> map)\r
+>> "Submap for button commands")\r
+>> (fset 'notmuch-show-part-button-map notmuch-show-part-button-map)\r
+>> @@ -531,6 +536,16 @@ message at DEPTH in the current thread."\r
+>> (let ((handle (mm-make-handle (current-buffer) (list content-type))))\r
+>> (mm-pipe-part handle))))\r
+>>\r
+>> +(defun notmuch-show-internally-show-part (message-id nth &optional filename content-type)\r
+>> + "Set a part to be displayed internally"\r
+>> + (let ((current-parts (lax-plist-get notmuch-show-message-multipart/alternative-display-parts message-id)))\r
+>> + (setq notmuch-show-message-multipart/alternative-display-parts\r
+>> + (lax-plist-put notmuch-show-message-multipart/alternative-display-parts message-id\r
+>> + (if (memq nth current-parts)\r
+>> + (delq nth current-parts)\r
+>> + (cons nth current-parts)))))\r
+>> + (notmuch-show-refresh-view))\r
+>> +\r
+>> (defun notmuch-show-multipart/*-to-list (part)\r
+>> (mapcar (lambda (inner-part) (plist-get inner-part :content-type))\r
+>> (plist-get part :content)))\r
+>> @@ -543,12 +558,15 @@ message at DEPTH in the current thread."\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
+>> +\r
+>> + ;; The variable user-parts says which parts should override the\r
+>> + ;; default so we use xor (handcoded since lisp does not have it).\r
+>\r
+> I don't follow the comment. user-parts isn't used in this\r
+> function. Neither is xor.\r
+\r
+Sorry that is vestigial from when the logic was in this function. The\r
+"xor" now occurs in the other function.\r
+\r
+>\r
+>> (mapc (lambda (inner-part)\r
+>> (let ((inner-type (plist-get inner-part :content-type)))\r
+>> - (if (or notmuch-show-all-multipart/alternative-parts\r
+>> - (string= chosen-type inner-type))\r
+>> - (notmuch-show-insert-bodypart msg inner-part depth)\r
+>> - (notmuch-show-insert-part-header (plist-get inner-part :id) inner-type inner-type nil " (not shown)"))))\r
+>> + (notmuch-show-insert-bodypart msg inner-part depth\r
+>> + (not (or notmuch-show-all-multipart/alternative-parts\r
+>> + (string=\r
+>> chosen-type inner-type))))))\r
+>\r
+> For what it's worth, I found this not-shown logic very confusing, and\r
+> have had to think about it seven or eight different times to make sure I\r
+> understood what's going on. I'm not sure why exactly this is, though I\r
+> could offer hypotheses -- the fact that it's split across two functions,\r
+> or the fiddling with mime-types. I'm satisfied that it's correct, but I\r
+> wish it could be made clearer.\r
+\r
+I think the reason I went for the split is that I wanted all parts to be\r
+togglable: I think having some parts which can be collapsed and some\r
+which can't is a recipe for confusion (particularly as they might both\r
+be labelled "[text/html]" for example). I think this means the split is\r
+required: the first is "what does notmuch want to do with this part" and\r
+the second is "what does the user want to do"\r
+\r
+> This is just armchair hypothesizing, but here are some ideas that might\r
+> make it more obvious what's going on: bringing the user-parts logic into\r
+> this function; making user-parts, instead of a "t" meaning "user has\r
+> toggled this", something like 'opened or 'closed and if user-parts for\r
+> this message is absent, falling back to this calculation; alternately,\r
+> prefilling user-parts with t when show is invoked, according to this\r
+> calculation, and then not using it any more; moving this\r
+> not-shown calculation into a separate function, something like notmuch-show-get-message-visibility.\r
+\r
+I would be happy to use the 'open 'closed for each part which I guess\r
+would make the list for each message a plist. It can be something of a\r
+separate function but the we would need something like the not-shown\r
+variable as the function notmuch-show-insert-bodypart does not know\r
+whether it was called from the top level or from one of the multipart levels.\r
+\r
+> I guess I jumped into this series halfway, but why are we doing this\r
+> with the wipe/redraw technique instead of just using invisible overlays,\r
+> like we do more generally with notmuch-show? I think I agree that\r
+> toggling individual parts is a good UI approach, and this isn't a bad\r
+> way to implement it, but I wonder if we could do it better/easier if we\r
+> used emacs's builtin functionality.\r
+\r
+I think overlays would be better but I have always found them difficult\r
+to use. If this feels like the right user interface then maybe it could\r
+be pushed and then something better can be added (as it should not break\r
+things for the user). I basically don't use this functionality so I was\r
+hoping for feedback from those who do as to whether the user interface\r
+is reasonable.\r
+\r
+Best wishes\r
+\r
+Mark\r
+\r
+\r