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 28338431FC2 for ; Fri, 14 Dec 2012 21:45:34 -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 p752ZQtKG4gB for ; Fri, 14 Dec 2012 21:45:33 -0800 (PST) Received: from dmz-mailsec-scanner-5.mit.edu (DMZ-MAILSEC-SCANNER-5.MIT.EDU [18.7.68.34]) by olra.theworths.org (Postfix) with ESMTP id 7557F431FC0 for ; Fri, 14 Dec 2012 21:45:33 -0800 (PST) X-AuditID: 12074422-b7fe46d0000008d2-90-50cc0e7c3051 Received: from mailhub-auth-3.mit.edu ( [18.9.21.43]) by dmz-mailsec-scanner-5.mit.edu (Symantec Messaging Gateway) with SMTP id 12.D1.02258.C7E0CC05; Sat, 15 Dec 2012 00:45:32 -0500 (EST) Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id qBF5jWke031896; Sat, 15 Dec 2012 00:45:32 -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 qBF5jU0l013664 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT); Sat, 15 Dec 2012 00:45:32 -0500 (EST) Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80) (envelope-from ) id 1TjkZ0-0007By-Oi; Sat, 15 Dec 2012 00:45:30 -0500 From: Austin Clements To: Mark Walters , notmuch@notmuchmail.org Subject: Re: [PATCH v2 3/5] emacs: show: add invisibility button action In-Reply-To: <1355389924-3718-4-git-send-email-markwalters1009@gmail.com> References: <1355389924-3718-1-git-send-email-markwalters1009@gmail.com> <1355389924-3718-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: Sat, 15 Dec 2012 00:45:30 -0500 Message-ID: <876243oolh.fsf@awakening.csail.mit.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrLIsWRmVeSWpSXmKPExsUixCmqrVvDdybA4E6XocXquTwW12/OZHZg 8tg56y67x7NVt5gDmKK4bFJSczLLUov07RK4Mm7/3sNScEmuYs+ps6wNjP8luhg5OSQETCSW bu1ih7DFJC7cW88GYgsJ7GOU+HsqHsLewChx/oFcFyMXkH2RSaLx/1NmCGcJo8TZrUeZQarY BPQlVqydxApiiwi4Sjz99hksLizgLvHw2DqgqRwcnAKeEifW+UH0tjJKPOtcxQ4SFxWIl5h9 zgeknEVAVeL/qwmsIGFeoOPebGMECfMKCEqcnPmEBcRmFtCSuPHvJdMERoFZSFKzkKQWMDKt YpRNya3SzU3MzClOTdYtTk7My0st0jXVy80s0UtNKd3ECApFdhelHYw/DyodYhTgYFTi4d0R cTpAiDWxrLgy9xCjJAeTkihvH++ZACG+pPyUyozE4oz4otKc1OJDjBIczEoivGJbgMp5UxIr q1KL8mFS0hwsSuK811Ju+gsJpCeWpGanphakFsFkZTg4lCR4J4AMFSxKTU+tSMvMKUFIM3Fw ggznARreDVLDW1yQmFucmQ6RP8WoKCXOmwOSEABJZJTmwfXCUsUrRnGgV4R500CqeIBpBq77 FdBgJqDBcZeOgwwuSURISTUweqTf1QwRyVb/6jIv0r98v/EL2/8X73/T3ZZ09dze1uyfkfkZ i36uMnswe/nHj8GSjH0ybOc5+09ej7axdNz/9se/+Wd3M1Ze3/BN07vrYur+U6ZTrk9nj5YQ 5GwqjX/dvvv+pKd3Arm8fvjxVHJN6jw+5TYbD8cDh0hbr7XOAVfvfGe9v2JVnBJLcUaioRZz UXEiAMWNQBXwAgAA 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: Sat, 15 Dec 2012 05:45:34 -0000 On Thu, 13 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, 34 insertions(+), 2 deletions(-) > > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el > index 3f2f277..202258f 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) Do we actually need this? Isn't it redundant with RET in all cases where t would be meaningful? > map) > "Submap for button commands") > (fset 'notmuch-show-part-button-map notmuch-show-part-button-map) > @@ -554,6 +555,28 @@ 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) notmuch-show-toggle-part-invisibility? > + (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 " ]" " (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)))))))) > + > (defun notmuch-show-multipart/*-to-list (part) > (mapcar (lambda (inner-part) (plist-get inner-part :content-type)) > (plist-get part :content))) > @@ -863,7 +886,13 @@ message at DEPTH in the current thread." > (cons invis-spec (overlay-get inner 'invisible))))) > > (button-put button 'invisibility-spec invis-spec) > - (button-put button 'overlay overlay))))) > + (button-put button 'overlay overlay)) > + > + ;; We toggle the button for hidden parts as that gets the > + ;; button label right. > + (save-excursion > + (when hide > + (notmuch-show-toggle-invisible-part-action button)))))) > > (defun notmuch-show-insert-bodypart (msg part depth &optional hide) > "Insert the body part PART at depth DEPTH in the current thread. > @@ -1992,7 +2021,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 (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 > > _______________________________________________ > notmuch mailing list > notmuch@notmuchmail.org > http://notmuchmail.org/mailman/listinfo/notmuch