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 28176431FC2 for ; Fri, 14 Dec 2012 21:40:05 -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 KcrKQjJE19of for ; Fri, 14 Dec 2012 21:40:03 -0800 (PST) Received: from dmz-mailsec-scanner-6.mit.edu (DMZ-MAILSEC-SCANNER-6.MIT.EDU [18.7.68.35]) by olra.theworths.org (Postfix) with ESMTP id 164DC431FC0 for ; Fri, 14 Dec 2012 21:40:03 -0800 (PST) X-AuditID: 12074423-b7fcb6d000000927-bf-50cc0d3046f5 Received: from mailhub-auth-1.mit.edu ( [18.9.21.35]) by dmz-mailsec-scanner-6.mit.edu (Symantec Messaging Gateway) with SMTP id 75.12.02343.03D0CC05; Sat, 15 Dec 2012 00:40:01 -0500 (EST) Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id qBF5e0or023041; Sat, 15 Dec 2012 00:40:00 -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 qBF5dxLl013155 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT); Sat, 15 Dec 2012 00:40:00 -0500 (EST) Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80) (envelope-from ) id 1TjkTe-0007AA-NY; Sat, 15 Dec 2012 00:39:58 -0500 From: Austin Clements To: Mark Walters , notmuch@notmuchmail.org Subject: Re: [PATCH v2 2/5] emacs: show: add overlays for each part In-Reply-To: <1355389924-3718-3-git-send-email-markwalters1009@gmail.com> References: <1355389924-3718-1-git-send-email-markwalters1009@gmail.com> <1355389924-3718-3-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:39:58 -0500 Message-ID: <878v8zooup.fsf@awakening.csail.mit.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrHIsWRmVeSWpSXmKPExsUixCmqrGvIeybA4MM3RovVc3ksrt+cyezA 5LFz1l12j2erbjEHMEVx2aSk5mSWpRbp2yVwZdxadJa94JdqxarHCxgbGBfJdTFyckgImEi0 vn7FCGGLSVy4t56ti5GLQ0hgH6NE+/+3TBDOBkaJZR87GCGci0wSx5Y9ZANpERJYwiix65ke iM0moC+xYu0kVhBbRMBV4um3z8wgtrCAs8SJSQeYQGxOAU+JxktvWSB6WxklZt/S7GLk4BAV iJeYfc4HJMwioCqxZds3FpAwL9B1b16rgIR5BQQlTs58AtbJLKAlcePfS6YJjAKzkKRmIUkt YGRaxSibklulm5uYmVOcmqxbnJyYl5dapGuml5tZopeaUrqJERSM7C7KOxj/HFQ6xCjAwajE w7sz4nSAEGtiWXFl7iFGSQ4mJVHeVRxnAoT4kvJTKjMSizPii0pzUosPMUpwMCuJ8IptASrn TUmsrEotyodJSXOwKInzXku56S8kkJ5YkpqdmlqQWgSTleHgUJLgfcUNNFSwKDU9tSItM6cE Ic3EwQkynAdouBIPUA1vcUFibnFmOkT+FKOilDgvI0hCACSRUZoH1wtLFq8YxYFeEea1BKni ASYauO5XQIOZgAbHXToOMrgkESEl1cB46V5PuJrhnuNzE7Oa5kqoCKiJnpFbcHCP4KHfgfc8 g9153y570fpbrEDAaNoN8yadYM1g7vnTHDuEtUJaY2yeLKmZxMqcJKXgPfdjvFqthkyRadMa if76UgWL0/OXZ1RcsOvaeP1Z8+lgJqclmvvEj5bv597L/vbNZ2VXsWumJnxh+TrJykosxRmJ hlrMRcWJACf2NPrxAgAA 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:40:05 -0000 On Thu, 13 Dec 2012, Mark Walters wrote: > This makes notmuch-show-insert-bodypart add an overlay for any > non-trivial part with a button header (currently the first text/plain > part does not have a button). At this point the overlay is available > to the button but there is no action using it yet. > > In addition the argument HIDE is passed down to > notmuch-show-insert-part-overlays to request that the part be hidden > by default but this is not acted on yet. > --- > emacs/notmuch-show.el | 61 +++++++++++++++++++++++++++++++++++++------------ > 1 files changed, 46 insertions(+), 15 deletions(-) > > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el > index 06f7ca5..3f2f277 100644 > --- a/emacs/notmuch-show.el > +++ b/emacs/notmuch-show.el > @@ -567,11 +567,10 @@ message at DEPTH in the current thread." > ;; but it's not clear that this is the wrong thing to do - which > ;; should be chosen if there are more than one that match? > (mapc (lambda (inner-part) > - (let ((inner-type (plist-get inner-part :content-type))) > - (if (or notmuch-show-all-multipart/alternative-parts > - (string= chosen-type inner-type)) > - (notmuch-show-insert-bodypart msg inner-part depth) > - (notmuch-show-insert-part-header (plist-get inner-part :id) inner-type inner-type nil " (not shown)")))) > + (let* ((inner-type (plist-get inner-part :content-type)) > + (hide (not (or notmuch-show-all-multipart/alternative-parts > + (string= chosen-type inner-type))))) > + (notmuch-show-insert-bodypart msg inner-part depth hide))) > inner-parts) > > (when notmuch-show-indent-multipart > @@ -839,17 +838,49 @@ message at DEPTH in the current thread." > (setq handlers (cdr handlers)))) > t) > > -(defun notmuch-show-insert-bodypart (msg part depth) > - "Insert the body part PART at depth DEPTH in the current thread." > +(defun notmuch-show-insert-part-overlays (msg beg end hide) notmuch-show-create-part-overlays? The other show-insert functions actually insert text into the buffer. > + "Add an overlay to the part between BEG and END" > + (let* ((button (button-at beg)) > + (part-beg (and button (1+ (button-end button))))) > + > + ;; If the part contains no text we do not make it toggleable. > + (when (and button (/= part-beg end)) > + (let ((base-label (button-get button :base-label)) > + (overlay (make-overlay part-beg end)) > + (message-invis-spec (plist-get msg :message-invis-spec)) > + (invis-spec (make-symbol "notmuch-part-region"))) > + > + (overlay-put overlay 'invisible (list invis-spec message-invis-spec)) > + (overlay-put overlay 'priority 10) > + (overlay-put overlay 'type "part") Since you're not actually using notmuch-wash, you don't need this 'type property. > + ;; Now we have to add invis-spec to every overlay this > + ;; overlay contains, otherwise these inner overlays will > + ;; override this one. > + (dolist (inner (overlays-in part-beg end)) > + (when (and (>= (overlay-start inner) part-beg) > + (<= (overlay-end inner) end)) > + (overlay-put inner 'invisible > + (cons invis-spec (overlay-get inner 'invisible))))) > + > + (button-put button 'invisibility-spec invis-spec) > + (button-put button 'overlay overlay))))) > + > +(defun notmuch-show-insert-bodypart (msg part depth &optional hide) > + "Insert the body part PART at depth DEPTH in the current thread. > + > +If HIDE is non-nil then initially hide this part." > (let ((content-type (downcase (plist-get part :content-type))) > - (nth (plist-get part :id))) > - (notmuch-show-insert-bodypart-internal msg part content-type nth depth content-type)) > - ;; Some of the body part handlers leave point somewhere up in the > - ;; part, so we make sure that we're down at the end. > - (goto-char (point-max)) > - ;; Ensure that the part ends with a carriage return. > - (unless (bolp) > - (insert "\n"))) > + (nth (plist-get part :id)) > + (beg (point))) > + > + (notmuch-show-insert-bodypart-internal msg part content-type nth depth content-type) > + ;; Some of the body part handlers leave point somewhere up in the > + ;; part, so we make sure that we're down at the end. > + (goto-char (point-max)) > + ;; Ensure that the part ends with a carriage return. > + (unless (bolp) > + (insert "\n")) > + (notmuch-show-insert-part-overlays msg beg (point) hide))) > > (defun notmuch-show-insert-body (msg body depth) > "Insert the body BODY at depth DEPTH in the current thread." > -- > 1.7.9.1 > > _______________________________________________ > notmuch mailing list > notmuch@notmuchmail.org > http://notmuchmail.org/mailman/listinfo/notmuch