From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 95B03429E43 for ; Fri, 31 May 2013 11:27:41 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0.201 X-Spam-Level: X-Spam-Status: No, score=0.201 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001, 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 j4eOyHN4WAki for ; Fri, 31 May 2013 11:27:36 -0700 (PDT) Received: from mail-wi0-f172.google.com (mail-wi0-f172.google.com [209.85.212.172]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id DAABD431FDA for ; Fri, 31 May 2013 11:27:22 -0700 (PDT) Received: by mail-wi0-f172.google.com with SMTP id m6so967961wiv.17 for ; Fri, 31 May 2013 11:27:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=xfabkqI6AhNDuC/K5386ZB4UBfvf6zv7lLeNwLl3QHQ=; b=Wr0pdzEOgntsjd37OFK678v0jINZHfT9oCSTdJb+fThNqBHFDhinyzsW9MWU8Kd7Rw D/wnLSd2k3QltXOV0OO6YmJPbJc3b+RWmG+r8wVVFkDVijrw5YiPMP3tLlSvVH/Qoo/G 9DpnAOQPEbcsE5MNedup9+mIX5R53uaosaIhyb71sq9nKQy2WK2/mSt/MXmQ5xJ5k9ZT ItF0K++E5KN9R8q7OKq1wa8NnyN3+qJx4Y+VVAW64lwFwOWkq84FuFXSGzC+YdI0XKBd RKUpswEU545FR5jHU/Oylt9iUO0531xETbiHxor4wt5om9HQmh7Hu9mPX4+fB4T+6g0L 6WvA== X-Received: by 10.180.36.147 with SMTP id q19mr4501563wij.26.1370024841834; Fri, 31 May 2013 11:27:21 -0700 (PDT) Received: from localhost (92.40.240.237.threembb.co.uk. [92.40.240.237]) by mx.google.com with ESMTPSA id fz8sm5734304wib.2.2013.05.31.11.27.20 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 31 May 2013 11:27:21 -0700 (PDT) From: Mark Walters To: notmuch@notmuchmail.org, Austin Clements , Adam Wolfe Gordon Subject: [PATCH v3 3/5] emacs: show: pass button to create-overlays Date: Fri, 31 May 2013 19:26:44 +0100 Message-Id: <1370024806-6616-4-git-send-email-markwalters1009@gmail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1370024806-6616-1-git-send-email-markwalters1009@gmail.com> References: <1370024806-6616-1-git-send-email-markwalters1009@gmail.com> 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 18:27:42 -0000 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))))) (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))) (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