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 458D4431FC4 for ; Tue, 18 Dec 2012 11:28:23 -0800 (PST) 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 Dc1FdZlhOnay for ; Tue, 18 Dec 2012 11:28:20 -0800 (PST) Received: from mail-wg0-f46.google.com (mail-wg0-f46.google.com [74.125.82.46]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 9030A431FC0 for ; Tue, 18 Dec 2012 11:28:15 -0800 (PST) Received: by mail-wg0-f46.google.com with SMTP id dr13so496019wgb.25 for ; Tue, 18 Dec 2012 11:28:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=InAVV0YcuvsgzhQiDyiMpqLnbTKCgNAtbBOy0YRNF7U=; b=JK9vXopvppzBwLz3C3IdzWnO6wNgZ9yEvq3mzWuSVhal5Z9Omo/oqw68+dTc2Cvv99 2aH9sQ6XqaZcZUKfFKhEjn/pvQLYA2s6S9Wwn4MuC0YIkeNrjKZLVWZfF2gAhZsjjKlI vTqjKA0jES2OIJYCTu9iQoJyPpQL7vKcdhtW+OWHpFOoScMADCpxENL1XVJcEih2k1ct IXrLoeF5DMGgZVTjNcUQiZZntHNNqs5cThL1UphDlRWWUKT8ui3sz05dBnsCo5HQnWpS ujCCe9fxDG3AOWgXC1e6hkajz6wEFQp0fJ1aX97fEf5vJz2eWIRtpOhE3hWzr2mOXyg9 Jp4A== X-Received: by 10.194.174.196 with SMTP id bu4mr6689652wjc.35.1355858894408; Tue, 18 Dec 2012 11:28:14 -0800 (PST) Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31]) by mx.google.com with ESMTPS id h19sm17169972wiv.7.2012.12.18.11.28.12 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 18 Dec 2012 11:28:13 -0800 (PST) From: Mark Walters To: notmuch@notmuchmail.org Subject: [PATCH v5 2/4] emacs: show: add overlays for each part Date: Tue, 18 Dec 2012 19:27:58 +0000 Message-Id: <1355858880-16329-3-git-send-email-markwalters1009@gmail.com> X-Mailer: git-send-email 1.7.9.1 In-Reply-To: <1355858880-16329-1-git-send-email-markwalters1009@gmail.com> References: <1355858880-16329-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: Tue, 18 Dec 2012 19:28:23 -0000 This makes notmuch-show-insert-bodypart add an overlay for any non-trivial part with a button header (currently the first text/plain part does not have a button). At this point the overlay is available to the button but there is no action using it yet. In addition the argument HIDE is passed down to notmuch-show-insert-part-overlays to request that the part be hidden by default but this is not acted on yet. --- emacs/notmuch-show.el | 45 ++++++++++++++++++++++++++++++--------------- 1 files changed, 30 insertions(+), 15 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index 5248fba..dc86b43 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -567,11 +567,10 @@ message at DEPTH in the current thread." ;; but it's not clear that this is the wrong thing to do - which ;; should be chosen if there are more than one that match? (mapc (lambda (inner-part) - (let ((inner-type (plist-get inner-part :content-type))) - (if (or notmuch-show-all-multipart/alternative-parts - (string= chosen-type inner-type)) - (notmuch-show-insert-bodypart msg inner-part depth) - (notmuch-show-insert-part-header (plist-get inner-part :id) inner-type inner-type nil " (not shown)")))) + (let* ((inner-type (plist-get inner-part :content-type)) + (hide (not (or notmuch-show-all-multipart/alternative-parts + (string= chosen-type inner-type))))) + (notmuch-show-insert-bodypart msg inner-part depth hide))) inner-parts) (when notmuch-show-indent-multipart @@ -839,17 +838,33 @@ message at DEPTH in the current thread." (setq handlers (cdr handlers)))) t) -(defun notmuch-show-insert-bodypart (msg part depth) - "Insert the body part PART at depth DEPTH in the current thread." +(defun notmuch-show-create-part-overlays (msg 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))))) + +(defun notmuch-show-insert-bodypart (msg part depth &optional hide) + "Insert the body part PART at depth DEPTH in the current thread. + +If HIDE is non-nil then initially hide this part." (let ((content-type (downcase (plist-get part :content-type))) - (nth (plist-get part :id))) - (notmuch-show-insert-bodypart-internal msg part content-type nth depth content-type)) - ;; Some of the body part handlers leave point somewhere up in the - ;; part, so we make sure that we're down at the end. - (goto-char (point-max)) - ;; Ensure that the part ends with a carriage return. - (unless (bolp) - (insert "\n"))) + (nth (plist-get part :id)) + (beg (point))) + + (notmuch-show-insert-bodypart-internal msg part content-type nth depth content-type) + ;; Some of the body part handlers leave point somewhere up in the + ;; part, so we make sure that we're down at the end. + (goto-char (point-max)) + ;; Ensure that the part ends with a carriage return. + (unless (bolp) + (insert "\n")) + (notmuch-show-create-part-overlays msg beg (point) hide))) (defun notmuch-show-insert-body (msg body depth) "Insert the body BODY at depth DEPTH in the current thread." -- 1.7.9.1