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 6C358431FCB for ; Fri, 31 May 2013 16:00:01 -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 CfjegQsiWoDi for ; Fri, 31 May 2013 15:59:55 -0700 (PDT) Received: from dmz-mailsec-scanner-1.mit.edu (dmz-mailsec-scanner-1.mit.edu [18.9.25.12]) by olra.theworths.org (Postfix) with ESMTP id 22D31431FBD for ; Fri, 31 May 2013 15:59:55 -0700 (PDT) X-AuditID: 1209190c-b7f566d000004c69-88-51a92b69f8e4 Received: from mailhub-auth-4.mit.edu ( [18.7.62.39]) by dmz-mailsec-scanner-1.mit.edu (Symantec Messaging Gateway) with SMTP id AB.FF.19561.96B29A15; Fri, 31 May 2013 18:59:53 -0400 (EDT) Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11]) by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id r4VMxpuG007258; Fri, 31 May 2013 18:59:52 -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 r4VMxn9L025014 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT); Fri, 31 May 2013 18:59:51 -0400 Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80) (envelope-from ) id 1UiYIX-00055h-3h; Fri, 31 May 2013 18:59:49 -0400 From: Austin Clements To: Mark Walters , notmuch@notmuchmail.org, Adam Wolfe Gordon Subject: Re: [PATCH v3 3/5] emacs: show: pass button to create-overlays In-Reply-To: <1370024806-6616-4-git-send-email-markwalters1009@gmail.com> References: <1370024806-6616-1-git-send-email-markwalters1009@gmail.com> <1370024806-6616-4-git-send-email-markwalters1009@gmail.com> User-Agent: Notmuch/0.15.2+83~g8bee3c4 (http://notmuchmail.org) Emacs/23.4.1 (i486-pc-linux-gnu) Date: Fri, 31 May 2013 18:59:48 -0400 Message-ID: <874ndi3gd7.fsf@awakening.csail.mit.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrGIsWRmVeSWpSXmKPExsUixG6nrpupvTLQYPd+dYsje2axW6yey2Nx /eZMZgdmj52z7rJ7PFt1i9mj6cdi1gDmKC6blNSczLLUIn27BK6MCbM+sRQsk6y4vvU9YwPj beEuRk4OCQETiR8ndzJC2GISF+6tZwOxhQT2MUrM2yrTxcgFZG9klOif+IYJwjnNJLGgZRYb hLOEUeL/1Plg7WwC+hIr1k5iBbFFBMoktkyfxQRiMwvoSJzYvQ2sRljAXWLhzl6wFZwCnhIr 2qZDDWpllLj07g8zSEJUIEFi5d0TQA0cHCwCqhKPj6eChHmBTm3c2csIYQtKnJz5hAVivpbE jX8vmSYwCs5CkpqFJLWAkWkVo2xKbpVubmJmTnFqsm5xcmJeXmqRrqFebmaJXmpK6SZGUPBy SvLsYHxzUOkQowAHoxIPb8eqFYFCrIllxZW5hxglOZiURHnr1VcGCvEl5adUZiQWZ8QXleak Fh9ilOBgVhLhzZ8DVM6bklhZlVqUD5OS5mBREue9nHLTX0ggPbEkNTs1tSC1CCYrw8GhJMG7 XAtoqGBRanpqRVpmTglCmomDE2Q4D9DwLpAa3uKCxNzizHSI/ClGRSlx3l6QhABIIqM0D64X llxeMYoDvSIMUcUDTExw3a+ABjMBDX5ivRxkcEkiQkqqgVHR7dX57GCbiI8B9kbLD5c9blrx 7oL2+gndryd/e3Nf9JnbzVu3i3x/7v227s6Uy8EcOedLrmkZML49tLCp+fHB9YH/FVdd5fpR rXWWvelh+42dnxKKvmoE3Xqp9JXxZYibgcD80KPJH4SL2ievPvKq8PnBDjdBXh63DvZ2/UbX dT1Ty67WtF5WYinOSDTUYi4qTgQAbVL0IgkDAAA= 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:00: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? > > (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? > > (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