From: Mark Walters Date: Mon, 10 Jun 2013 04:57:10 +0000 (+0100) Subject: [PATCH v5 3/6] emacs: show: pass button to create-overlays X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=47f64adb2b45e90e3dd11a781b4abb87b42319a8;p=notmuch-archives.git [PATCH v5 3/6] emacs: show: pass button to create-overlays --- diff --git a/35/e29d760b4bfc2bf375b37a02c552ff785f1fb1 b/35/e29d760b4bfc2bf375b37a02c552ff785f1fb1 new file mode 100644 index 000000000..fbc0e936a --- /dev/null +++ b/35/e29d760b4bfc2bf375b37a02c552ff785f1fb1 @@ -0,0 +1,130 @@ +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 C46D0431FAF + for ; Sun, 9 Jun 2013 21:57:33 -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 Cs9Yj+LslPO9 for ; + Sun, 9 Jun 2013 21:57:28 -0700 (PDT) +Received: from mail-ee0-f54.google.com (mail-ee0-f54.google.com + [74.125.83.54]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client + certificate requested) by olra.theworths.org (Postfix) with ESMTPS id + 9A24E431FBC for ; Sun, 9 Jun 2013 21:57:24 -0700 + (PDT) +Received: by mail-ee0-f54.google.com with SMTP id t10so2522638eei.13 + for ; Sun, 09 Jun 2013 21:57:23 -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=yJKVdqyp6GG7n27pjQkyMlxmMiYZkNF578akPOJng9g=; + b=u/hxH4NVP/9ltRxYrilZl1YkxgWZiMqp4PuyRuVuD+C4BUmTEHULPGUOG3LUHsMwcg + fhbf6Onm+9+05Lftq9CxlU9jDOhe62Teoj+jHsvM4/xr1bmntImbOXr6jba0NaV8rwnI + HQmHCSSLhObVWcNLgtncS8hgPX/VPXe6B5e3S7aiLGDOPyQFym+LVFw6DRTYl6GLDPSq + BWtqhmAT6g9b58neUHKaPlJ+W1U684G/5DBqQNkLVlDwz3/TYwpri/fRORNvRzwqrqCK + uJX12/0ac3/fOGa5ksvNcpFaALFIOFhoDos23LPTDDC6A19EwZ+h6mN+rVr7r4VT0P/A + 4oBA== +X-Received: by 10.15.82.193 with SMTP id a41mr8971282eez.39.1370840243503; + Sun, 09 Jun 2013 21:57:23 -0700 (PDT) +Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31]) + by mx.google.com with ESMTPSA id + n42sm20180459eeh.15.2013.06.09.21.57.22 for + (version=TLSv1.2 cipher=RC4-SHA bits=128/128); + Sun, 09 Jun 2013 21:57:22 -0700 (PDT) +From: Mark Walters +To: notmuch@notmuchmail.org, + Austin Clements +Subject: [PATCH v5 3/6] emacs: show: pass button to create-overlays +Date: Mon, 10 Jun 2013 05:57:10 +0100 +Message-Id: <1370840233-23258-4-git-send-email-markwalters1009@gmail.com> +X-Mailer: git-send-email 1.7.9.1 +In-Reply-To: <1370840233-23258-1-git-send-email-markwalters1009@gmail.com> +References: <1370840233-23258-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: Mon, 10 Jun 2013 04:57:34 -0000 + +Now that the bodypart code has the button we can pass that to +create-overlays and simplify that. +--- + emacs/notmuch-show.el | 31 +++++++++++++++---------------- + 1 files changed, 15 insertions(+), 16 deletions(-) + +diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el +index c69456a..0a0451b 100644 +--- a/emacs/notmuch-show.el ++++ b/emacs/notmuch-show.el +@@ -793,21 +793,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 +- ;; button label right. +- (save-excursion +- (when hide +- (notmuch-show-toggle-part-invisibility button)))))) ++ ++ ;; 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))))) + + (defun notmuch-show-insert-bodypart (msg part depth &optional hide) + "Insert the body part PART at depth DEPTH in the current thread. +@@ -824,7 +822,8 @@ If HIDE is non-nil then initially hide this part." + (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)))) ++ (content-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 +@@ -833,7 +832,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 content-beg (point) hide) + ;; Record part information. Since we already inserted subparts, + ;; don't override existing :notmuch-part properties. + (notmuch-map-text-property beg (point) :notmuch-part +-- +1.7.9.1 +