Re: [PATCH 3/3] emacs: show: add invisibility button action
authorAustin Clements <aclements@csail.mit.edu>
Tue, 11 Dec 2012 04:06:48 +0000 (23:06 +1900)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:52:01 +0000 (09:52 -0800)
a1/7a9e64fb69a57821c67b664c34662d63aea481 [new file with mode: 0644]

diff --git a/a1/7a9e64fb69a57821c67b664c34662d63aea481 b/a1/7a9e64fb69a57821c67b664c34662d63aea481
new file mode 100644 (file)
index 0000000..aff361d
--- /dev/null
@@ -0,0 +1,164 @@
+Return-Path: <amdragon@mit.edu>\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 8A4ED431FAF\r
+       for <notmuch@notmuchmail.org>; Mon, 10 Dec 2012 20:06:52 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[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 hUgYaqAVdZb6 for <notmuch@notmuchmail.org>;\r
+       Mon, 10 Dec 2012 20:06:52 -0800 (PST)\r
+Received: from dmz-mailsec-scanner-3.mit.edu (DMZ-MAILSEC-SCANNER-3.MIT.EDU\r
+       [18.9.25.14])\r
+       by olra.theworths.org (Postfix) with ESMTP id DF88C431FAE\r
+       for <notmuch@notmuchmail.org>; Mon, 10 Dec 2012 20:06:51 -0800 (PST)\r
+X-AuditID: 1209190e-b7f516d0000008e4-04-50c6b15b8293\r
+Received: from mailhub-auth-2.mit.edu ( [18.7.62.36])\r
+       by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP\r
+       id 98.D6.02276.B51B6C05; Mon, 10 Dec 2012 23:06:51 -0500 (EST)\r
+Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
+       by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id qBB46ock003735; \r
+       Mon, 10 Dec 2012 23:06:51 -0500\r
+Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
+       (authenticated bits=0)\r
+       (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+       by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id qBB46mNT017618\r
+       (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT);\r
+       Mon, 10 Dec 2012 23:06:50 -0500 (EST)\r
+Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80)\r
+       (envelope-from <amdragon@mit.edu>)\r
+       id 1TiH7I-0003bJ-9l; Mon, 10 Dec 2012 23:06:48 -0500\r
+From: Austin Clements <aclements@csail.mit.edu>\r
+To: Mark Walters <markwalters1009@gmail.com>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH 3/3] emacs: show: add invisibility button action\r
+In-Reply-To: <1354663662-20524-4-git-send-email-markwalters1009@gmail.com>\r
+References: <1354663662-20524-1-git-send-email-markwalters1009@gmail.com>\r
+       <1354663662-20524-4-git-send-email-markwalters1009@gmail.com>\r
+User-Agent: Notmuch/0.14+159~g6895fee (http://notmuchmail.org) Emacs/23.4.1\r
+       (i486-pc-linux-gnu)\r
+Date: Mon, 10 Dec 2012 23:06:48 -0500\r
+Message-ID: <87r4mxnsfb.fsf@awakening.csail.mit.edu>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFnrAIsWRmVeSWpSXmKPExsUixG6nohu98ViAwYU3khar5/JYXL85k9mB\r
+       yWPnrLvsHs9W3WIOYIrisklJzcksSy3St0vgymg618JW8FGm4sCp2ywNjAfEuxg5OSQETCTe\r
+       vVjMDGGLSVy4t56ti5GLQ0hgH6PE/Q0gDieQs4FRYu0tZYjERSaJFYt2MUI4SxglNmx9xg5S\r
+       xSagL7Fi7SRWEFtEwFXi6bfPYGOFBVwkLhw7ADaJU8BL4sLRacwQze2MEkcaGoEcDg5RgXiJ\r
+       2ed8QGpYBFQlOm/8B5vDC3Tewt4JTBC2oMTJmU9YQGxmAS2JG/9eMk1gFJiFJDULSWoBI9Mq\r
+       RtmU3Crd3MTMnOLUZN3i5MS8vNQiXWO93MwSvdSU0k2MoIDklOTbwfj1oNIhRgEORiUe3grV\r
+       YwFCrIllxZW5hxglOZiURHl9lwOF+JLyUyozEosz4otKc1KLDzFKcDArifCW5gLleFMSK6tS\r
+       i/JhUtIcLErivFdSbvoLCaQnlqRmp6YWpBbBZGU4OJQkeF02ADUKFqWmp1akZeaUIKSZODhB\r
+       hvMADf+zHmR4cUFibnFmOkT+FKOilDivBUizAEgiozQPrheWMF4xigO9IswrDFLFA0w2cN2v\r
+       gAYzAQ0+KXgYZHBJIkJKqoHR7OpL6xTfyqoqfsEbvactNrtzCPx97cCZdqmqceMcnsqKU7Nu\r
+       8tv/V3DpFvDYHRI4p2leLufM0J87O/QbH1fY7Q6a9OnF84f/049LiVm16lTZhS1WMiiquvEw\r
+       5pO69kW5y3mlz8z/vYnV7Z7Fp5int/92bMJlnmt7WXaoS3spnTEtDY68uEmJpTgj0VCLuag4\r
+       EQBRRs6m8wIAAA==\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, 11 Dec 2012 04:06:52 -0000\r
+\r
+On Tue, 04 Dec 2012, Mark Walters <markwalters1009@gmail.com> wrote:\r
+> This adds a button action to show hidden parts. In this version "t"\r
+> toggles the visibility of a part. In addition "RET" on a non-shown\r
+> part shows it.\r
+>\r
+> The button is used to hide parts when appropriate (eg text/html in\r
+> multipart/alternative).\r
+> ---\r
+>  emacs/notmuch-show.el |   36 +++++++++++++++++++++++++++++++++++-\r
+>  1 files changed, 35 insertions(+), 1 deletions(-)\r
+>\r
+> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+> index 3215ebc..a4daff8 100644\r
+> --- a/emacs/notmuch-show.el\r
+> +++ b/emacs/notmuch-show.el\r
+> @@ -478,6 +478,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-toggle-invisible-part-action)\r
+>      map)\r
+>    "Submap for button commands")\r
+>  (fset 'notmuch-show-part-button-map notmuch-show-part-button-map)\r
+> @@ -555,6 +556,31 @@ 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
+> +;; This is taken from notmuch-wash: maybe it should be unified?\r
+> +(defun notmuch-show-toggle-invisible-part-action (&optional button no-redisplay)\r
+> +  (interactive)\r
+> +  (let* ((button (or button (button-at (point))))\r
+> +     (overlay (button-get button 'overlay))\r
+> +     (invis-spec (button-get button 'invisibility-spec))\r
+> +     (show (invisible-p invis-spec)))\r
+> +    (when overlay\r
+> +      (if show\r
+> +      (remove-from-invisibility-spec invis-spec)\r
+> +    (add-to-invisibility-spec invis-spec))\r
+> +      (let* ((new-start (button-start button))\r
+> +         (button-label (button-get button :base-label))\r
+> +         (old-point (point))\r
+> +         (inhibit-read-only t))\r
+> +    (goto-char new-start)\r
+> +    (insert "[ " button-label (if show " ]" " (not shown) ]"))\r
+\r
+s/not shown/hidden/?\r
+\r
+> +    (let ((old-end (button-end button)))\r
+> +      (move-overlay button new-start (point))\r
+> +      (delete-region (point) old-end))\r
+> +    (goto-char (min old-point (1- (button-end button)))))\r
+> +      (unless no-redisplay\r
+> +    (force-window-update)\r
+> +    (redisplay t)))))\r
+\r
+Is the t argument necessary?  Actually, are either (force-window-update)\r
+or (redisplay) necessary?\r
+\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
+> @@ -867,6 +893,11 @@ message at DEPTH in the current thread."\r
+>  \r
+>      (button-put button 'invisibility-spec invis-spec)\r
+>      (button-put button 'overlay overlay))\r
+> +\r
+> +      ;; We toggle the button for hidden parts as that gets the\r
+> +      ;; button label right.\r
+> +      (when not-shown\r
+> +    (notmuch-show-toggle-invisible-part-action button t))\r
+>        (goto-char (point-max)))))\r
+>  \r
+>  (defun notmuch-show-insert-bodypart (msg part depth &optional not-shown)\r
+> @@ -1996,7 +2027,10 @@ the user (see `notmuch-show-stash-mlarchive-link-alist')."\r
+>  \r
+>  (defun notmuch-show-part-button-default (&optional button)\r
+>    (interactive)\r
+> -  (notmuch-show-part-button-internal button notmuch-show-part-button-default-action))\r
+> +  (let ((button (or button (button-at (point)))))\r
+> +    (if (invisible-p (button-get button 'invisibility-spec))\r
+> +    (notmuch-show-toggle-invisible-part-action button)\r
+> +      (notmuch-show-part-button-internal button notmuch-show-part-button-default-action))))\r
+>  \r
+>  (defun notmuch-show-part-button-save (&optional button)\r
+>    (interactive)\r
+> -- \r
+> 1.7.9.1\r