From 631813b3a3803c327bf72a05fdd9ac6587b2e326 Mon Sep 17 00:00:00 2001 From: Mark Walters Date: Sat, 1 Jun 2013 00:08:46 +0100 Subject: [PATCH] Re: [PATCH v3 3/5] emacs: show: pass button to create-overlays --- cd/862c05625245d2ff035defa15261545d95a3e3 | 162 ++++++++++++++++++++++ 1 file changed, 162 insertions(+) create mode 100644 cd/862c05625245d2ff035defa15261545d95a3e3 diff --git a/cd/862c05625245d2ff035defa15261545d95a3e3 b/cd/862c05625245d2ff035defa15261545d95a3e3 new file mode 100644 index 000000000..12a213144 --- /dev/null +++ b/cd/862c05625245d2ff035defa15261545d95a3e3 @@ -0,0 +1,162 @@ +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 1B3AD431FD0 + for ; Fri, 31 May 2013 16:09:01 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -1.098 +X-Spam-Level: +X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5 + tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001, + NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] 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 BuW8kvcvPZGA for ; + Fri, 31 May 2013 16:08:55 -0700 (PDT) +Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 02CED431FBD + for ; Fri, 31 May 2013 16:08:55 -0700 (PDT) +Received: from smtp.qmul.ac.uk ([138.37.6.40]) + by mail2.qmul.ac.uk with esmtp (Exim 4.71) + (envelope-from ) + id 1UiYRD-00073D-O5; Sat, 01 Jun 2013 00:08:53 +0100 +Received: from 93-97-24-31.zone5.bethere.co.uk ([93.97.24.31] helo=localhost) + by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.71) + (envelope-from ) + id 1UiYRD-0002DF-EM; Sat, 01 Jun 2013 00:08:47 +0100 +From: Mark Walters +To: Austin Clements , notmuch@notmuchmail.org, + Adam Wolfe Gordon +Subject: Re: [PATCH v3 3/5] emacs: show: pass button to create-overlays +In-Reply-To: <874ndi3gd7.fsf@awakening.csail.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> +User-Agent: Notmuch/0.14+255~gff3cc55 (http://notmuchmail.org) Emacs/23.4.1 + (i486-pc-linux-gnu) +Date: Sat, 01 Jun 2013 00:08:46 +0100 +Message-ID: <87vc5yg329.fsf@qmul.ac.uk> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Sender-Host-Address: 93.97.24.31 +X-QM-SPAM-Info: Sender has good ham record. :) +X-QM-Body-MD5: b6e91ab99d81b99d8f76102b1756fd01 (of first 20000 bytes) +X-SpamAssassin-Score: -0.1 +X-SpamAssassin-SpamBar: / +X-SpamAssassin-Report: The QM spam filters have analysed this message to + determine if it is + spam. We require at least 5.0 points to mark a message as spam. + This message scored -0.1 points. + Summary of the scoring: + * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail + provider * (markwalters1009[at]gmail.com) + * -0.1 AWL AWL: From: address is in the auto white-list +X-QM-Scan-Virus: ClamAV says the message is clean +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:09:01 -0000 + + +> 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? + +> +>> +>> (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. + +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." +>> -- +>> 1.7.10.4 -- 2.26.2