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 14772429E36 for ; Wed, 25 Jan 2012 07:45:36 -0800 (PST) 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 eypciul20usm for ; Wed, 25 Jan 2012 07:45:35 -0800 (PST) Received: from mail-ww0-f45.google.com (mail-ww0-f45.google.com [74.125.82.45]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 9AA8F431FBC for ; Wed, 25 Jan 2012 07:45:34 -0800 (PST) Received: by wgbdt12 with SMTP id dt12so4941148wgb.2 for ; Wed, 25 Jan 2012 07:45:33 -0800 (PST) MIME-Version: 1.0 Received: by 10.216.139.223 with SMTP id c73mr3144582wej.1.1327506333461; Wed, 25 Jan 2012 07:45:33 -0800 (PST) Received: from hotblack-desiato.hh.sledj.net (host81-149-164-25.in-addr.btopenworld.com. [81.149.164.25]) by mx.google.com with ESMTPS id n5sm2655383wiw.7.2012.01.25.07.45.31 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 25 Jan 2012 07:45:31 -0800 (PST) Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000) id E04099FFA4; Wed, 25 Jan 2012 15:45:29 +0000 (GMT) From: David Edmondson To: notmuch@notmuchmail.org Subject: [PATCH 4/4 v2] emacs: Take more care when hiding regions with buttons. Date: Wed, 25 Jan 2012 15:45:28 +0000 Message-Id: <1327506328-22126-5-git-send-email-dme@dme.org> X-Mailer: git-send-email 1.7.8.3 In-Reply-To: <1327506328-22126-1-git-send-email-dme@dme.org> References: <1327503908-17226-1-git-send-email-dme@dme.org> <1327506328-22126-1-git-send-email-dme@dme.org> X-Gm-Message-State: ALoCoQlmEyQKdVun6QAZeiQoZ6BzMHsXrixeS/0IQgdll+Ja0bYQfmBR6lRlv/rdmq+NcOVPo6Z3 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: Wed, 25 Jan 2012 15:45:36 -0000 If the region to be hidden with a button by `notmuch-wash-region-to-button' starts at the beginning of the buffer, the invisible region will include the inserted button. This is unfortunate, as it means that it is not possible to see the button to be pressed. Make a little space at the start of the buffer before inserting the button to avoid this, not forgetting to remove the inserted space upon completion. Mark the relevant test as no longer broken. --- emacs/notmuch-wash.el | 57 ++++++++++++++++++++++----------- test/emacs-original-message-hiding.sh | 1 - 2 files changed, 38 insertions(+), 20 deletions(-) diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el index 5c1e830..4afd3b3 100644 --- a/emacs/notmuch-wash.el +++ b/emacs/notmuch-wash.el @@ -147,25 +147,44 @@ insert before the button, probably for indentation." ;; symbols because of the way the button code works. Note that ;; replacing intern-soft with make-symbol will cause this to fail, ;; since the newly created symbol has no plist. - - (let ((overlay (make-overlay beg end)) - (message-invis-spec (plist-get msg :message-invis-spec)) - (invis-spec (make-symbol (concat "notmuch-" type "-region"))) - (button-type (intern-soft (concat "notmuch-wash-button-" - type "-toggle-type")))) - (add-to-invisibility-spec invis-spec) - (overlay-put overlay 'invisible (list invis-spec message-invis-spec)) - (overlay-put overlay 'isearch-open-invisible #'notmuch-wash-region-isearch-show) - (overlay-put overlay 'priority 10) - (overlay-put overlay 'type type) - (goto-char (1+ end)) - (save-excursion - (goto-char (1- beg)) - (insert prefix) - (insert-button (notmuch-wash-button-label overlay) - 'invisibility-spec invis-spec - 'overlay overlay - :type button-type)))) + (save-excursion + ;; If the beginning of the region to be converted to a button is the + ;; beginning of the buffer we must move forward a little to avoid + ;; creating an overlay that will hide the button intended to be used + ;; to reveal the hidden region. + (let (scene-of-crime) + (when (eq beg (point-min)) + (goto-char (point-min)) + (insert "\n") + (setq scene-of-crime (point-min) + beg (point))) + + ;; This uses some slightly tricky conversions between strings and + ;; symbols because of the way the button code works. Note that + ;; replacing intern-soft with make-symbol will cause this to fail, + ;; since the newly created symbol has no plist. + + (let ((overlay (make-overlay beg end)) + (message-invis-spec (plist-get msg :message-invis-spec)) + (invis-spec (make-symbol (concat "notmuch-" type "-region"))) + (button-type (intern-soft (concat "notmuch-wash-button-" + type "-toggle-type")))) + (add-to-invisibility-spec invis-spec) + (overlay-put overlay 'invisible (list invis-spec message-invis-spec)) + (overlay-put overlay 'isearch-open-invisible #'notmuch-wash-region-isearch-show) + (overlay-put overlay 'priority 10) + (overlay-put overlay 'type type) + + (goto-char (1- beg)) + (insert prefix) + (insert-button (notmuch-wash-button-label overlay) + 'invisibility-spec invis-spec + 'overlay overlay + :type button-type)) + + (when scene-of-crime + (goto-char scene-of-crime) + (delete-char 1))))) (defun notmuch-wash-excerpt-citations (msg depth) "Excerpt citations and up to one signature." diff --git a/test/emacs-original-message-hiding.sh b/test/emacs-original-message-hiding.sh index 01cf98d..038ef4f 100755 --- a/test/emacs-original-message-hiding.sh +++ b/test/emacs-original-message-hiding.sh @@ -13,7 +13,6 @@ add_message \ '[body]="-----Original Message----- Text here. "' -test_subtest_known_broken test_emacs_expect_t \ '(load "emacs-original-message-hiding.el") (notmuch-test-original-message-hiding)' -- 1.7.8.3