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 9B70D431FAF for ; Tue, 18 Dec 2012 11:28:11 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 2.7 X-Spam-Level: ** X-Spam-Status: No, score=2.7 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, FREEMAIL_REPLY=2.499, 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 EOZ6o5apODAN for ; Tue, 18 Dec 2012 11:28:11 -0800 (PST) Received: from mail-wg0-f52.google.com (mail-wg0-f52.google.com [74.125.82.52]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 7D8C4431FAE for ; Tue, 18 Dec 2012 11:28:10 -0800 (PST) Received: by mail-wg0-f52.google.com with SMTP id 12so496982wgh.31 for ; Tue, 18 Dec 2012 11:28:09 -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; bh=WbrqUykMafe+qR1Y6fmZb6pAGyKZN1kVLK9nywv9Clo=; b=ij9xh3aI2lLGMj84MG3qCPEq/behGHDFm3azU34Y+gwmjbeThN4pfJ8YdF+6G3MVwq WvmdSHkdHvdb4y9rVS9l/IMhYa5dtMJyFDlr9qCkW1TbOad6dK/50VjPgTuGMOSeJOtH TxPP7porW2a61h22dcvMPSAKxShobWMJH10HqzQx+zBrYYJ8mW7ZAU2ZAjOuV1jaflvZ VeJ/JeWgbW0aymKuDOVGwFRPj13DljyuTC1NMoQjXijqOC6EbOARGKeLGNct2zSiW5NF eiT7hmLZGrcWubhYbCgWPzE3tqGYy3o5hN3VaeDkJ0u2PIDp+ehpIwzFQDdRG4DCLnpq jaKA== X-Received: by 10.194.87.200 with SMTP id ba8mr6767409wjb.22.1355858889083; Tue, 18 Dec 2012 11:28:09 -0800 (PST) Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31]) by mx.google.com with ESMTPS id bz12sm4119492wib.5.2012.12.18.11.28.04 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 18 Dec 2012 11:28:06 -0800 (PST) From: Mark Walters To: notmuch@notmuchmail.org Subject: [PATCH v5 0/4] Use invisibility to toggle display of all parts including multipart Date: Tue, 18 Dec 2012 19:27:56 +0000 Message-Id: <1355858880-16329-1-git-send-email-markwalters1009@gmail.com> X-Mailer: git-send-email 1.7.9.1 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:11 -0000 This is an alternative version of id:1355781287-6010-1-git-send-email-markwalters1009@gmail.com based on top of Austin's patch at id:1355812810-32747-1-git-send-email-amdragon@mit.edu Austin's patch significantly simplifies the invisibility handling taking this series down from 90/27 to 68/26 in diffstat terms. In general terms Austin's approach has to be the right thing to do: what we want to do just before the freeze is less clear. My view is that we should go with Austin's approach now so that at least any bugs we get from it and (more likely) from this series apply to master as well. I am posting this series to make it easier for people to judge the two approaches when finished (ie with part invisibility too). I attach a trimmed diff from v4 below the diffstat (note this was a diff with -U10 which I have trimmed so it is purely for information) Note we no longer need patch 4/5 because in this approach the overlays do not need to know about other overlays. Best wishes Mark Mark Walters (4): emacs: show: modify insert-part-header to save the button text emacs: show: add overlays for each part emacs: show: add invisibility button action emacs: show: set default show-all-multipart/alternatives to nil emacs/notmuch-show.el | 94 +++++++++++++++++++++++++++++++++++------------- 1 files changed, 68 insertions(+), 26 deletions(-) Diff from v4 emacs/notmuch-show.el | 33 ++++++--------------------------- emacs/notmuch-wash.el | 2 +- 2 files changed, 7 insertions(+), 28 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index ee67fec..5751d98 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -551,31 +551,28 @@ message at DEPTH in the current thread." ;; This is taken from notmuch-wash: maybe it should be unified? (defun notmuch-show-toggle-part-invisibility (&optional button) (interactive) (let* ((button (or button (button-at (point)))) - (overlay (button-get button 'overlay)) - (invis-spec (button-get button 'invisibility-spec)) - (show (invisible-p invis-spec))) + (overlay (button-get button 'overlay))) (when overlay - (if show - (remove-from-invisibility-spec invis-spec) - (add-to-invisibility-spec invis-spec)) - (let* ((new-start (button-start button)) + (let* ((show (overlay-get overlay 'invisible)) + (new-start (button-start button)) (button-label (button-get button :base-label)) (old-point (point)) (inhibit-read-only t)) + (overlay-put overlay 'invisible (not show)) (goto-char new-start) (insert "[ " button-label (if show " ]" " (hidden) ]")) (let ((old-end (button-end button))) (move-overlay button new-start (point)) (delete-region (point) old-end)) (goto-char (min old-point (1- (button-end button)))))))) @@ -862,39 +859,21 @@ message at 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)) - (let ((base-label (button-get button :base-label)) - (overlay (make-overlay part-beg end)) - (message-invis-spec (plist-get msg :message-invis-spec)) - (invis-spec (make-symbol "notmuch-part-region"))) - - (overlay-put overlay 'invisible (list invis-spec message-invis-spec)) - (overlay-put overlay 'priority 10) - ;; Now we have to add invis-spec to every overlay this - ;; overlay contains, otherwise these inner overlays will - ;; override this one. - (dolist (inner (overlays-in part-beg end)) - (when (and (>= (overlay-start inner) part-beg) - (<= (overlay-end inner) end)) - (overlay-put inner 'invisible - (cons invis-spec (overlay-get inner 'invisible))))) - - (button-put button 'invisibility-spec invis-spec) - (button-put button 'overlay overlay)) - + (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)))))) @@ -1992,21 +1971,21 @@ If optional argument MLA is non-nil, use the provided key instead of prompting (defun notmuch-show-part-button-default (&optional button) (interactive) (let ((button (or button (button-at (point))))) - (if (button-get button 'invisibility-spec) + (if (button-get button 'overlay) (notmuch-show-toggle-part-invisibility button) (notmuch-show-part-button-internal button notmuch-show-part-button-default-action)))) diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el index e10ab66..d6db4fa 100644 --- a/emacs/notmuch-wash.el +++ b/emacs/notmuch-wash.el @@ -365,15 +365,15 @@ for error." (save-restriction (narrow-to-region patch-start patch-end) (setq part (plist-put part :content-type "inline-patch-fake-part")) (setq part (plist-put part :content (buffer-string))) (setq part (plist-put part :id -1)) (setq part (plist-put part :filename (notmuch-wash-subject-to-patch-filename (plist-get (plist-get msg :headers) :Subject)))) (delete-region (point-min) (point-max)) - (notmuch-show-insert-bodypart msg part depth))))) + (notmuch-show-insert-bodypart nil part depth))))) ;; (provide 'notmuch-wash) -- 1.7.9.1