[PATCH 2/3] emacs: show: add overlays for each part
authorMark Walters <markwalters1009@gmail.com>
Tue, 4 Dec 2012 23:27:41 +0000 (23:27 +0000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:51:30 +0000 (09:51 -0800)
6e/293e07ab7095f803927e16b36f74eb0c0c0fba [new file with mode: 0644]

diff --git a/6e/293e07ab7095f803927e16b36f74eb0c0c0fba b/6e/293e07ab7095f803927e16b36f74eb0c0c0fba
new file mode 100644 (file)
index 0000000..49ffab8
--- /dev/null
@@ -0,0 +1,157 @@
+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 6A9C2431FD7\r
+       for <notmuch@notmuchmail.org>; Tue,  4 Dec 2012 15:28:01 -0800 (PST)\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 kvXQtx8CCDJj for <notmuch@notmuchmail.org>;\r
+       Tue,  4 Dec 2012 15:27:56 -0800 (PST)\r
+Received: from mail-wg0-f47.google.com (mail-wg0-f47.google.com\r
+ [74.125.82.47])       (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
+ certificate requested)        by olra.theworths.org (Postfix) with ESMTPS id\r
+ 8C230429E32   for <notmuch@notmuchmail.org>; Tue,  4 Dec 2012 15:27:52 -0800\r
+ (PST)\r
+Received: by mail-wg0-f47.google.com with SMTP id dq11so2243404wgb.2\r
+       for <notmuch@notmuchmail.org>; Tue, 04 Dec 2012 15:27:51 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+       h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;\r
+       bh=jS5XjTdjllp2CsHpn/ESiIKeEE6ByFIsb+xTBvJqaoY=;\r
+       b=XvaMOErYMRYJzDDXlpsxCcfz8hQak0WgNBkvgUI9bYeiSdrVR+jKwa004HyW3LkDjE\r
+       lkQ7Z+GjzLC/n4qyXYOFcvBTigDA4Q0TDLXPTPxsqtaYO+wR12UOwKRgM+7BHo7Bcp0P\r
+       RhElKjdJaSHFrs2PACMdg5LX3ASStPybg/yR/6m/lP/KtxgbYEXPud4Ph8zmA9GGSQif\r
+       t7zC0hkP+HM6t2kDZ71J8mJF41vQGzYOLxcfLM0wgQiKMYP9ohxIosjgHhzSacDO3n1K\r
+       t6IoVMkMpwXY0clpY5VgZWnB8nnYFPR90qH/GWc3QlVP9TjQLDy1KjCS+5eSJeW0idgN\r
+       X5xg==\r
+Received: by 10.180.102.234 with SMTP id fr10mr28383wib.17.1354663671416;\r
+       Tue, 04 Dec 2012 15:27:51 -0800 (PST)\r
+Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31])\r
+       by mx.google.com with ESMTPS id eu8sm16989974wib.1.2012.12.04.15.27.50\r
+       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Tue, 04 Dec 2012 15:27:50 -0800 (PST)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 2/3] emacs: show: add overlays for each part\r
+Date: Tue,  4 Dec 2012 23:27:41 +0000\r
+Message-Id: <1354663662-20524-3-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.9.1\r
+In-Reply-To: <1354663662-20524-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1354663662-20524-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: Tue, 04 Dec 2012 23:28:01 -0000\r
+\r
+This make notmuch-show-insert-bodypart add an overlay for any\r
+non-trivial part with a button header (currently the first text/plain\r
+part does not have a button). At this point the overlay is available\r
+to the button but there is no action using it yet.\r
+\r
+In addition a not-shown variable which is used to request the part be\r
+hidden by default down to the overlay but this is not acted on yet.\r
+---\r
+ emacs/notmuch-show.el |   62 +++++++++++++++++++++++++++++++++++++-----------\r
+ 1 files changed, 48 insertions(+), 14 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index f8ce037..3215ebc 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -569,10 +569,9 @@ message at DEPTH in the current thread."\r
+     ;; should be chosen if there are more than one that match?\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= chosen-type inner-type))))))\r
+         inner-parts)\r
\r
+     (when notmuch-show-indent-multipart\r
+@@ -840,17 +839,52 @@ message at DEPTH in the current thread."\r
+       (setq handlers (cdr handlers))))\r
+   t)\r
\r
+-(defun notmuch-show-insert-bodypart (msg part depth)\r
+-  "Insert the body part PART at depth DEPTH in the current thread."\r
++(defun notmuch-show-insert-part-overlays (msg beg end not-shown)\r
++  "Add an overlay to the part between BEG and END"\r
++  (let* ((button (button-at beg))\r
++       (part-beg (and button (1+ (button-end button)))))\r
++\r
++    ;; If the part contains no text we do not make it toggleable.\r
++    (unless (or (not button) (eq part-beg end))\r
++      (let ((base-label (button-get button :base-label))\r
++          (overlay (make-overlay part-beg end))\r
++          (message-invis-spec (plist-get msg :message-invis-spec))\r
++          (invis-spec (make-symbol "notmuch-part-region")))\r
++\r
++      (overlay-put overlay 'invisible (list invis-spec message-invis-spec))\r
++      (overlay-put overlay 'isearch-open-invisible #'notmuch-wash-region-isearch-show)\r
++      (overlay-put overlay 'priority 10)\r
++      (overlay-put overlay 'type "part")\r
++      ;; Now we have to add invis-spec to every overlay this\r
++      ;; overlay contains, otherwise these inner overlays will\r
++      ;; override this one.\r
++      (mapc (lambda (inner)\r
++              (when (and (>= (overlay-start inner) part-beg)\r
++                         (<= (overlay-end inner) end))\r
++                (overlay-put inner 'invisible\r
++                             (cons invis-spec (overlay-get inner 'invisible)))))\r
++            (overlays-in part-beg end))\r
++\r
++      (button-put button 'invisibility-spec invis-spec)\r
++      (button-put button 'overlay overlay))\r
++      (goto-char (point-max)))))\r
++\r
++(defun notmuch-show-insert-bodypart (msg part depth &optional not-shown)\r
++  "Insert the body part PART at depth DEPTH in the current thread.\r
++\r
++If not-shown is TRUE then initially hide this part."\r
+   (let ((content-type (downcase (plist-get part :content-type)))\r
+-      (nth (plist-get part :id)))\r
+-    (notmuch-show-insert-bodypart-internal msg part content-type nth depth content-type))\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
+-  ;; Ensure that the part ends with a carriage return.\r
+-  (unless (bolp)\r
+-    (insert "\n")))\r
++      (nth (plist-get part :id))\r
++      (beg (point)))\r
++\r
++    (notmuch-show-insert-bodypart-internal msg part content-type nth depth content-type)\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
++    ;; Ensure that the part ends with a carriage return.\r
++    (unless (bolp)\r
++      (insert "\n"))\r
++    (notmuch-show-insert-part-overlays msg beg (point) not-shown)))\r
\r
+ (defun notmuch-show-insert-body (msg body depth)\r
+   "Insert the body BODY at depth DEPTH in the current thread."\r
+-- \r
+1.7.9.1\r
+\r