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