From 8fd6013c75207af1c0210f84a96f928e29724d38 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Sat, 1 Jun 2013 19:12:39 +2000 Subject: [PATCH] Re: [PATCH v3 3/5] emacs: show: pass button to create-overlays --- 3f/b2ed8f95f52603eaf795650d6883b28b89f8cd | 176 ++++++++++++++++++++++ 1 file changed, 176 insertions(+) create mode 100644 3f/b2ed8f95f52603eaf795650d6883b28b89f8cd diff --git a/3f/b2ed8f95f52603eaf795650d6883b28b89f8cd b/3f/b2ed8f95f52603eaf795650d6883b28b89f8cd new file mode 100644 index 000000000..8a2893b04 --- /dev/null +++ b/3f/b2ed8f95f52603eaf795650d6883b28b89f8cd @@ -0,0 +1,176 @@ +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 9EAD4431FDB + for ; Fri, 31 May 2013 16:12:55 -0700 (PDT) +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 v3xJ5CBIWSvf for ; + Fri, 31 May 2013 16:12:51 -0700 (PDT) +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 815AD431FBD + for ; Fri, 31 May 2013 16:12:51 -0700 (PDT) +X-AuditID: 12074422-b7f5b6d00000095d-6f-51a92e73b8ac +Received: from mailhub-auth-1.mit.edu ( [18.9.21.35]) + by dmz-mailsec-scanner-5.mit.edu (Symantec Messaging Gateway) with SMTP + id 3E.60.02397.37E29A15; Fri, 31 May 2013 19:12:51 -0400 (EDT) +Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11]) + by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id r4VNCgat001760; + Fri, 31 May 2013 19:12:42 -0400 +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.8/8.12.4) with ESMTP id r4VNCeok028579 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT); + Fri, 31 May 2013 19:12:41 -0400 +Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80) + (envelope-from ) + id 1UiYUx-0005AP-Sc; Fri, 31 May 2013 19:12:39 -0400 +Date: Fri, 31 May 2013 19:12:39 -0400 +From: Austin Clements +To: Mark Walters +Subject: Re: [PATCH v3 3/5] emacs: show: pass button to create-overlays +Message-ID: <20130531231239.GD5999@mit.edu> +References: <1370024806-6616-1-git-send-email-markwalters1009@gmail.com> + <1370024806-6616-4-git-send-email-markwalters1009@gmail.com> + <874ndi3gd7.fsf@awakening.csail.mit.edu> + <87vc5yg329.fsf@qmul.ac.uk> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <87vc5yg329.fsf@qmul.ac.uk> +User-Agent: Mutt/1.5.21 (2010-09-15) +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFprJKsWRmVeSWpSXmKPExsUixCmqrFustzLQ4GoPm8WRPbPYLVbP5bG4 + fnMmswOzx85Zd9k9nq26xezR9GMxawBzFJdNSmpOZllqkb5dAldG965TbAX7FCs2zP/G1sD4 + RLKLkZNDQsBEYtmvOWwQtpjEhXvrgWwuDiGBfYwS5479YoRwNjJK7Pv2ghnCOc0ksf3gO1YI + ZzWjxPf5R5m6GDk4WARUJfZdVQUZxSagL7Fi7SRWEFtEQEfi9qEF7CA2s4CzxL5PnWDrhAXc + JRbu7AWzeQW0JR7tvQ21+gKjxMW+XYwQCUGJkzOfsEA0a0nc+PcSbBezgLTE8n8cIGFOAQ2J + xlvzwEpEBVQkppzcxjaBUWgWku5ZSLpnIXQvYGRexSibklulm5uYmVOcmqxbnJyYl5dapGuq + l5tZopeaUrqJERTq7C5KOxh/HlQ6xCjAwajEw2uwYkWgEGtiWXFl7iFGSQ4mJVHeevWVgUJ8 + SfkplRmJxRnxRaU5qcWHGCU4mJVEePPnAJXzpiRWVqUW5cOkpDlYlMR5r6Xc9BcSSE8sSc1O + TS1ILYLJynBwKEnwVuoCDRUsSk1PrUjLzClBSDNxcIIM5wEaHgNSw1tckJhbnJkOkT/FqMux + +fzkd4xCLHn5ealS4ryxIEUCIEUZpXlwc2Ap6hWjONBbwryzQKp4gOkNbtIroCVMQEueWC8H + WVKSiJCSamA0EJyyn4OlYdeU8xNaluxS6auZ32/1j90/vV606UVVyZk/J3vOv6hf43N42qQ/ + f995/T18Jp5pWgiLs+2CfateCs4UceH95V8RtMHk4zY1M3vpl7dfr3+bvL03geH12w+Xvgip + Lst4GfSuekVqsNnO6IpJHwT2LNvxaXX7FL/lvtpyp/P6/F/7K7EUZyQaajEXFScCAFWNR4Is AwAA +X-Mailman-Approved-At: Fri, 31 May 2013 23:39:02 -0700 +Cc: notmuch@notmuchmail.org +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: Fri, 31 May 2013 23:12:55 -0000 + +Quoth Mark Walters on Jun 01 at 12:08 am: +> +> > On Fri, 31 May 2013, Mark Walters wrote: +> >> Now that the bodypart code has the button we can pass that to +> >> create-overlays and simplify that. +> >> --- +> >> emacs/notmuch-show.el | 26 ++++++++++++-------------- +> >> 1 file changed, 12 insertions(+), 14 deletions(-) +> >> +> >> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el +> >> index be3aeac..66cc3a5 100644 +> >> --- a/emacs/notmuch-show.el +> >> +++ b/emacs/notmuch-show.el +> >> @@ -851,21 +851,19 @@ message at DEPTH in the current thread." +> >> (setq handlers (cdr handlers)))) +> >> t) +> >> +> >> -(defun notmuch-show-create-part-overlays (msg beg end hide) +> >> +(defun notmuch-show-create-part-overlays (button beg end hide) +> >> "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. We +> >> - ;; also need to check that the button is a genuine part button not +> >> - ;; a notmuch-wash button. +> >> - (when (and button (/= part-beg end) (button-get button :base-label)) +> >> - (button-put button 'overlay (make-overlay part-beg end)) +> >> - ;; We toggle the button for hidden parts as that gets the +> >> + +> >> + ;; If there is no button (i.e., the part is text/plain and the first +> >> + ;; part) or if the part has no content then we don't make the part +> >> + ;; toggleable. +> >> + (when (and button (/= beg end)) +> >> + (button-put button 'overlay (make-overlay beg end)) +> >> + ;; We toggle the button for hidden parts as that gets the +> >> ;; button label right. +> >> (save-excursion +> >> (when hide +> >> - (notmuch-show-toggle-part-invisibility button)))))) +> >> + (notmuch-show-toggle-part-invisibility button))))) +> > +> > I might just be mis-following the diff here, but shouldn't the above get +> > re-indented? +> +> I think you are right: it got a bit messed up when I tried to split up +> the patch. I don't think it matters much as these lines get deleted in +> the next patch. Incidentally is there a good git work flow for fixing up +> something like this where you just want to change the midpoint of a +> series? + +Yeah, I just came across that. If you want to fix it up, personally I +would use git rebase -i and mark this patch as "edit", then amend this +commit to fix the indentation, continue the rebase, and clean up the +inevitable rebase conflict when it replays the next patch. + +> > +> >> +> >> (defun notmuch-show-insert-bodypart (msg part depth &optional hide) +> >> "Insert the body part PART at depth DEPTH in the current thread. +> >> @@ -879,10 +877,10 @@ If HIDE is non-nil then initially hide this part." +> >> "text/x-diff") +> >> content-type)) +> >> (nth (plist-get part :id)) +> >> - (beg (point)) +> >> ;; We omit the part button for the first (or only) part if this is text/plain. +> >> (button (unless (and (string= mime-type "text/plain") (<= nth 1)) +> >> - (notmuch-show-insert-part-header nth mime-type content-type (plist-get part :filename))))) +> >> + (notmuch-show-insert-part-header nth mime-type content-type (plist-get part :filename)))) +> >> + (beg (point))) +> > +> > Was this swap necessary? +> +> This is needed: inserting a part header moves point and this means that +> point is at the start of the part content rather than the start of the +> part button. + +Ah, okay. + +> Best wishes +> +> Mark +> +> > +> >> +> >> (notmuch-show-insert-bodypart-internal msg part mime-type nth depth button) +> >> ;; Some of the body part handlers leave point somewhere up in the +> >> @@ -891,7 +889,7 @@ If HIDE is non-nil then initially hide this part." +> >> ;; Ensure that the part ends with a carriage return. +> >> (unless (bolp) +> >> (insert "\n")) +> >> - (notmuch-show-create-part-overlays msg beg (point) hide))) +> >> + (notmuch-show-create-part-overlays button beg (point) hide))) +> >> +> >> (defun notmuch-show-insert-body (msg body depth) +> >> "Insert the body BODY at depth DEPTH in the current thread." -- 2.26.2