--- /dev/null
+Return-Path: <markwalters1009@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 74547431FAF\r
+ for <notmuch@notmuchmail.org>; Sat, 4 May 2013 06:01:39 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.201\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.201 tagged_above=-999 required=5\r
+ tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+ FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
+ RCVD_IN_DNSWL_LOW=-0.7] 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 Po3EzUKrAus1 for <notmuch@notmuchmail.org>;\r
+ Sat, 4 May 2013 06:01:33 -0700 (PDT)\r
+Received: from mail-wi0-f175.google.com (mail-wi0-f175.google.com\r
+ [209.85.212.175]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 2A2AF431FC0\r
+ for <notmuch@notmuchmail.org>; Sat, 4 May 2013 06:01:33 -0700 (PDT)\r
+Received: by mail-wi0-f175.google.com with SMTP id h11so1363247wiv.8\r
+ for <notmuch@notmuchmail.org>; Sat, 04 May 2013 06:01:32 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+ h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to\r
+ :references; bh=Tzkgjg4d3ubib606ysb8b/eQysKyODZ6mt8VbIZJkes=;\r
+ b=NBFUXUA01QZ5yIRYouyVYOpXedaEcvti6/oL7tZTADGgrlqdpkLfQo1cMiosyICqw/\r
+ mxIDvCYSjbWmnyAevRww7QLpPLPXCP5V/iHpdPFI+kXUdNt32bEpWGDzHDH7NbgxIfwV\r
+ mtcTG2+AP5qu3KQM2RqWQpAuLbEQ223DUFB9hjWxVETjTeOiIPhWqoDM1TH1uTrQAehW\r
+ 5cPU8xMlURBQc3u22j7rNhlZ6ekPbj77g35ErvczLERbftU8cJ5bVvLTyK3MSVluaSai\r
+ rIBI6mzjuH/4WYCE61mR9KLKmwRaAAS4+FxIExg48GIn4IndcOopUPoSGbLQ3jJ1mvnr\r
+ UvVA==\r
+X-Received: by 10.180.188.141 with SMTP id ga13mr2013674wic.9.1367672492086;\r
+ Sat, 04 May 2013 06:01:32 -0700 (PDT)\r
+Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31])\r
+ by mx.google.com with ESMTPSA id k5sm3129210wiy.5.2013.05.04.06.01.30\r
+ for <multiple recipients>\r
+ (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+ Sat, 04 May 2013 06:01:31 -0700 (PDT)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 3/4] emacs: show: move the insertion of the header button to\r
+ the top level\r
+Date: Sat, 4 May 2013 14:01:16 +0100\r
+Message-Id: <1367672478-12247-4-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.9.1\r
+In-Reply-To: <1367672478-12247-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1367672478-12247-1-git-send-email-markwalters1009@gmail.com>\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: Sat, 04 May 2013 13:01:39 -0000\r
+\r
+Previously each of the part insertion handlers inserted the part\r
+button themselves. Move this up into\r
+notmuch-show-insert-bodypart. Since a small number of the handlers\r
+modify the button (the encryption/signature ones) we need to pass the\r
+header button as an argument into the individual part insertion\r
+handlers.\r
+\r
+The patch is large but mostly simple. The only things of note are that\r
+we let the text/plain handler insert part buttons itself (as it does\r
+not always insert one and it applies motmuch-wash to the whole part\r
+including the button. Also this is by far the most important case so\r
+this reduces the risk of annoying side effects.\r
+\r
+The handler for inline-patch-fake-part is called from notmuch wash not\r
+from notmuch-show-insert-bodypart so that needs to insert the header\r
+button itself (rather than relying on notmuch-show-insert-part-*/*).\r
+---\r
+ emacs/notmuch-show.el | 91 +++++++++++++++++++++++-------------------------\r
+ 1 files changed, 44 insertions(+), 47 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index f984143..2c48b24 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -575,8 +575,7 @@ message at DEPTH in the current thread."\r
+ (mapcar (lambda (inner-part) (plist-get inner-part :content-type))\r
+ (plist-get part :content)))\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
++(defun notmuch-show-insert-part-multipart/alternative (msg part content-type nth depth declared-type button)\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
+@@ -653,8 +652,7 @@ message at DEPTH in the current thread."\r
+ content-type)\r
+ nil)))\r
+ \r
+-(defun notmuch-show-insert-part-multipart/related (msg part content-type nth depth declared-type)\r
+- (notmuch-show-insert-part-header nth declared-type content-type nil)\r
++(defun notmuch-show-insert-part-multipart/related (msg part content-type nth depth declared-type button)\r
+ (let ((inner-parts (plist-get part :content))\r
+ (start (point)))\r
+ \r
+@@ -673,16 +671,15 @@ message at DEPTH in the current thread."\r
+ (indent-rigidly start (point) 1)))\r
+ t)\r
+ \r
+-(defun notmuch-show-insert-part-multipart/signed (msg part content-type nth depth declared-type)\r
+- (let ((button (notmuch-show-insert-part-header nth declared-type content-type nil)))\r
+- (button-put button 'face 'notmuch-crypto-part-header)\r
+- ;; add signature status button if sigstatus provided\r
+- (if (plist-member part :sigstatus)\r
+- (let* ((from (notmuch-show-get-header :From msg))\r
+- (sigstatus (car (plist-get part :sigstatus))))\r
+- (notmuch-crypto-insert-sigstatus-button sigstatus from))\r
+- ;; if we're not adding sigstatus, tell the user how they can get it\r
+- (button-put button 'help-echo "Set notmuch-crypto-process-mime to process cryptographic MIME parts.")))\r
++(defun notmuch-show-insert-part-multipart/signed (msg part content-type nth depth declared-type button)\r
++ (button-put button 'face 'notmuch-crypto-part-header)\r
++ ;; add signature status button if sigstatus provided\r
++ (if (plist-member part :sigstatus)\r
++ (let* ((from (notmuch-show-get-header :From msg))\r
++ (sigstatus (car (plist-get part :sigstatus))))\r
++ (notmuch-crypto-insert-sigstatus-button sigstatus from))\r
++ ;; if we're not adding sigstatus, tell the user how they can get it\r
++ (button-put button 'help-echo "Set notmuch-crypto-process-mime to process cryptographic MIME parts."))\r
+ \r
+ (let ((inner-parts (plist-get part :content))\r
+ (start (point)))\r
+@@ -695,20 +692,19 @@ message at DEPTH in the current thread."\r
+ (indent-rigidly start (point) 1)))\r
+ t)\r
+ \r
+-(defun notmuch-show-insert-part-multipart/encrypted (msg part content-type nth depth declared-type)\r
+- (let ((button (notmuch-show-insert-part-header nth declared-type content-type nil)))\r
+- (button-put button 'face 'notmuch-crypto-part-header)\r
+- ;; add encryption status button if encstatus specified\r
+- (if (plist-member part :encstatus)\r
+- (let ((encstatus (car (plist-get part :encstatus))))\r
+- (notmuch-crypto-insert-encstatus-button encstatus)\r
+- ;; add signature status button if sigstatus specified\r
+- (if (plist-member part :sigstatus)\r
+- (let* ((from (notmuch-show-get-header :From msg))\r
+- (sigstatus (car (plist-get part :sigstatus))))\r
+- (notmuch-crypto-insert-sigstatus-button sigstatus from))))\r
+- ;; if we're not adding encstatus, tell the user how they can get it\r
+- (button-put button 'help-echo "Set notmuch-crypto-process-mime to process cryptographic MIME parts.")))\r
++(defun notmuch-show-insert-part-multipart/encrypted (msg part content-type nth depth declared-type button)\r
++ (button-put button 'face 'notmuch-crypto-part-header)\r
++ ;; add encryption status button if encstatus specified\r
++ (if (plist-member part :encstatus)\r
++ (let ((encstatus (car (plist-get part :encstatus))))\r
++ (notmuch-crypto-insert-encstatus-button encstatus)\r
++ ;; add signature status button if sigstatus specified\r
++ (if (plist-member part :sigstatus)\r
++ (let* ((from (notmuch-show-get-header :From msg))\r
++ (sigstatus (car (plist-get part :sigstatus))))\r
++ (notmuch-crypto-insert-sigstatus-button sigstatus from))))\r
++ ;; if we're not adding encstatus, tell the user how they can get it\r
++ (button-put button 'help-echo "Set notmuch-crypto-process-mime to process cryptographic MIME parts."))\r
+ \r
+ (let ((inner-parts (plist-get part :content))\r
+ (start (point)))\r
+@@ -721,8 +717,7 @@ message at DEPTH in the current thread."\r
+ (indent-rigidly start (point) 1)))\r
+ t)\r
+ \r
+-(defun notmuch-show-insert-part-multipart/* (msg part content-type nth depth declared-type)\r
+- (notmuch-show-insert-part-header nth declared-type content-type nil)\r
++(defun notmuch-show-insert-part-multipart/* (msg part content-type nth depth declared-type button)\r
+ (let ((inner-parts (plist-get part :content))\r
+ (start (point)))\r
+ ;; Show all of the parts.\r
+@@ -734,8 +729,7 @@ message at DEPTH in the current thread."\r
+ (indent-rigidly start (point) 1)))\r
+ t)\r
+ \r
+-(defun notmuch-show-insert-part-message/rfc822 (msg part content-type nth depth declared-type)\r
+- (notmuch-show-insert-part-header nth declared-type content-type nil)\r
++(defun notmuch-show-insert-part-message/rfc822 (msg part content-type nth depth declared-type button)\r
+ (let* ((message (car (plist-get part :content)))\r
+ (body (car (plist-get message :body)))\r
+ (start (point)))\r
+@@ -756,7 +750,7 @@ message at DEPTH in the current thread."\r
+ (indent-rigidly start (point) 1)))\r
+ t)\r
+ \r
+-(defun notmuch-show-insert-part-text/plain (msg part content-type nth depth declared-type)\r
++(defun notmuch-show-insert-part-text/plain (msg part content-type nth depth declared-type button)\r
+ (let ((start (point)))\r
+ ;; If this text/plain part is not the first part in the message,\r
+ ;; insert a header to make this clear.\r
+@@ -769,8 +763,7 @@ message at DEPTH in the current thread."\r
+ (run-hook-with-args 'notmuch-show-insert-text/plain-hook msg depth))))\r
+ t)\r
+ \r
+-(defun notmuch-show-insert-part-text/calendar (msg part content-type nth depth declared-type)\r
+- (notmuch-show-insert-part-header nth declared-type content-type (plist-get part :filename))\r
++(defun notmuch-show-insert-part-text/calendar (msg part content-type nth depth declared-type button)\r
+ (insert (with-temp-buffer\r
+ (insert (notmuch-get-bodypart-content msg part nth notmuch-show-process-crypto))\r
+ ;; notmuch-get-bodypart-content provides "raw", non-converted\r
+@@ -793,8 +786,8 @@ message at DEPTH in the current thread."\r
+ t)\r
+ \r
+ ;; For backwards compatibility.\r
+-(defun notmuch-show-insert-part-text/x-vcalendar (msg part content-type nth depth declared-type)\r
+- (notmuch-show-insert-part-text/calendar msg part content-type nth depth declared-type))\r
++(defun notmuch-show-insert-part-text/x-vcalendar (msg part content-type nth depth declared-type button)\r
++ (notmuch-show-insert-part-text/calendar msg part content-type nth depth declared-type button))\r
+ \r
+ (defun notmuch-show-get-mime-type-of-application/octet-stream (part)\r
+ ;; If we can deduce a MIME type from the filename of the attachment,\r
+@@ -813,10 +806,10 @@ message at DEPTH in the current thread."\r
+ nil))))\r
+ \r
+ ;; Handler for wash generated inline patch fake parts.\r
+-(defun notmuch-show-insert-part-inline-patch-fake-part (msg part content-type nth depth declared-type)\r
+- (notmuch-show-insert-part-*/* msg part content-type nth depth declared-type))\r
++(defun notmuch-show-insert-part-inline-patch-fake-part (msg part content-type nth depth declared-type button)\r
++ (notmuch-show-insert-part-*/* msg part content-type nth depth declared-type button))\r
+ \r
+-(defun notmuch-show-insert-part-text/html (msg part content-type nth depth declared-type)\r
++(defun notmuch-show-insert-part-text/html (msg part content-type nth depth declared-type button)\r
+ ;; text/html handler to work around bugs in renderers and our\r
+ ;; invisibile parts code. In particular w3m sets up a keymap which\r
+ ;; "leaks" outside the invisible region and causes strange effects\r
+@@ -824,11 +817,10 @@ message at DEPTH in the current thread."\r
+ ;; tell w3m not to set a keymap (so the normal notmuch-show-mode-map\r
+ ;; remains).\r
+ (let ((mm-inline-text-html-with-w3m-keymap nil))\r
+- (notmuch-show-insert-part-*/* msg part content-type nth depth declared-type)))\r
++ (notmuch-show-insert-part-*/* msg part content-type nth depth declared-type button)))\r
+ \r
+-(defun notmuch-show-insert-part-*/* (msg part content-type nth depth declared-type)\r
++(defun notmuch-show-insert-part-*/* (msg part content-type nth depth declared-type button)\r
+ ;; This handler _must_ succeed - it is the handler of last resort.\r
+- (notmuch-show-insert-part-header nth content-type declared-type (plist-get part :filename))\r
+ (notmuch-mm-display-part-inline msg part nth content-type notmuch-show-process-crypto)\r
+ t)\r
+ \r
+@@ -851,13 +843,13 @@ message at DEPTH in the current thread."\r
+ \r
+ ;; \f\r
+\r
+ \r
+-(defun notmuch-show-insert-bodypart-internal (msg part content-type nth depth declared-type)\r
++(defun notmuch-show-insert-bodypart-internal (msg part content-type nth depth declared-type button)\r
+ (let ((handlers (notmuch-show-handlers-for content-type)))\r
+ ;; Run the content handlers until one of them returns a non-nil\r
+ ;; value.\r
+ (while (and handlers\r
+ (not (condition-case err\r
+- (funcall (car handlers) msg part content-type nth depth declared-type)\r
++ (funcall (car handlers) msg part content-type nth depth declared-type button)\r
+ (error (progn\r
+ (insert "!!! Bodypart insert error: ")\r
+ (insert (error-message-string err))\r
+@@ -885,6 +877,9 @@ message at DEPTH in the current thread."\r
+ "Insert the body part PART at depth DEPTH in the current thread.\r
+ \r
+ If HIDE is non-nil then initially hide this part."\r
++\r
++ ;; We handle text/plain specially as its code does things before\r
++ ;; inserting a part button (and does not always insert a part button).\r
+ (let* ((content-type (downcase (plist-get part :content-type)))\r
+ (mime-type (or (and (string= content-type "application/octet-stream")\r
+ (notmuch-show-get-mime-type-of-application/octet-stream part))\r
+@@ -892,9 +887,11 @@ If HIDE is non-nil then initially hide this part."\r
+ "text/x-diff")\r
+ content-type))\r
+ (nth (plist-get part :id))\r
+- (beg (point)))\r
++ (beg (point))\r
++ (button (unless (string= mime-type "text/plain")\r
++ (notmuch-show-insert-part-header nth mime-type content-type (plist-get part :filename)))))\r
+ \r
+- (notmuch-show-insert-bodypart-internal msg part mime-type nth depth content-type)\r
++ (notmuch-show-insert-bodypart-internal msg part mime-type nth depth content-type button)\r
+ ;; Some of the body part handlers leave point somewhere up in the\r
+ ;; part, so we make sure that we're down at the end.\r
+ (goto-char (point-max))\r
+-- \r
+1.7.9.1\r
+\r