--- /dev/null
+Return-Path: <dme@dme.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id 6C007431FAF\r
+ for <notmuch@notmuchmail.org>; Wed, 25 Jan 2012 23:19:48 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+ tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id 7CbJoyGac+lA for <notmuch@notmuchmail.org>;\r
+ Wed, 25 Jan 2012 23:19:47 -0800 (PST)\r
+Received: from mail-ww0-f45.google.com (mail-ww0-f45.google.com\r
+ [74.125.82.45]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client\r
+ certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
+ 405D6431FAE for <notmuch@notmuchmail.org>; Wed, 25 Jan 2012 23:19:47 -0800\r
+ (PST)\r
+Received: by wgbdt12 with SMTP id dt12so226465wgb.2\r
+ for <notmuch@notmuchmail.org>; Wed, 25 Jan 2012 23:19:46 -0800 (PST)\r
+Received: by 10.180.99.100 with SMTP id ep4mr1424595wib.7.1327562386000;\r
+ Wed, 25 Jan 2012 23:19:46 -0800 (PST)\r
+Received: from hotblack-desiato.hh.sledj.net\r
+ (host81-149-164-25.in-addr.btopenworld.com. [81.149.164.25])\r
+ by mx.google.com with ESMTPS id em13sm3802465wid.7.2012.01.25.23.19.42\r
+ (version=TLSv1/SSLv3 cipher=OTHER);\r
+ Wed, 25 Jan 2012 23:19:43 -0800 (PST)\r
+Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000)\r
+ id 8AB2C9FFA4; Thu, 26 Jan 2012 07:19:41 +0000 (GMT)\r
+From: David Edmondson <dme@dme.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 4/4 v3] emacs: Take more care when hiding regions with\r
+ buttons.\r
+Date: Thu, 26 Jan 2012 07:19:40 +0000\r
+Message-Id: <1327562380-12894-5-git-send-email-dme@dme.org>\r
+X-Mailer: git-send-email 1.7.8.3\r
+In-Reply-To: <1327562380-12894-1-git-send-email-dme@dme.org>\r
+References: <1327503908-17226-1-git-send-email-dme@dme.org>\r
+ <1327562380-12894-1-git-send-email-dme@dme.org>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Thu, 26 Jan 2012 07:19:48 -0000\r
+\r
+If the region to be hidden with a button by\r
+`notmuch-wash-region-to-button' starts at the beginning of the buffer,\r
+the invisible region will include the inserted button. This is\r
+unfortunate, as it means that it is not possible to see the button to\r
+be pressed.\r
+\r
+Make a little space at the start of the buffer before inserting the\r
+button to avoid this, not forgetting to remove the inserted space upon\r
+completion.\r
+\r
+Mark the relevant test as no longer broken.\r
+---\r
+ emacs/notmuch-wash.el | 57 ++++++++++++++++++++++++++++--------------\r
+ test/emacs-message-hiding.sh | 1 -\r
+ 2 files changed, 38 insertions(+), 20 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el\r
+index 5c1e830..4afd3b3 100644\r
+--- a/emacs/notmuch-wash.el\r
++++ b/emacs/notmuch-wash.el\r
+@@ -147,25 +147,44 @@ insert before the button, probably for indentation."\r
+ ;; symbols because of the way the button code works. Note that\r
+ ;; replacing intern-soft with make-symbol will cause this to fail,\r
+ ;; since the newly created symbol has no plist.\r
+-\r
+- (let ((overlay (make-overlay beg end))\r
+- (message-invis-spec (plist-get msg :message-invis-spec))\r
+- (invis-spec (make-symbol (concat "notmuch-" type "-region")))\r
+- (button-type (intern-soft (concat "notmuch-wash-button-"\r
+- type "-toggle-type"))))\r
+- (add-to-invisibility-spec invis-spec)\r
+- (overlay-put overlay 'invisible (list invis-spec message-invis-spec))\r
+- (overlay-put overlay 'isearch-open-invisible #'notmuch-wash-region-isearch-show)\r
+- (overlay-put overlay 'priority 10)\r
+- (overlay-put overlay 'type type)\r
+- (goto-char (1+ end))\r
+- (save-excursion\r
+- (goto-char (1- beg))\r
+- (insert prefix)\r
+- (insert-button (notmuch-wash-button-label overlay)\r
+- 'invisibility-spec invis-spec\r
+- 'overlay overlay\r
+- :type button-type))))\r
++ (save-excursion\r
++ ;; If the beginning of the region to be converted to a button is the\r
++ ;; beginning of the buffer we must move forward a little to avoid\r
++ ;; creating an overlay that will hide the button intended to be used\r
++ ;; to reveal the hidden region.\r
++ (let (scene-of-crime)\r
++ (when (eq beg (point-min))\r
++ (goto-char (point-min))\r
++ (insert "\n")\r
++ (setq scene-of-crime (point-min)\r
++ beg (point)))\r
++\r
++ ;; This uses some slightly tricky conversions between strings and\r
++ ;; symbols because of the way the button code works. Note that\r
++ ;; replacing intern-soft with make-symbol will cause this to fail,\r
++ ;; since the newly created symbol has no plist.\r
++\r
++ (let ((overlay (make-overlay beg end))\r
++ (message-invis-spec (plist-get msg :message-invis-spec))\r
++ (invis-spec (make-symbol (concat "notmuch-" type "-region")))\r
++ (button-type (intern-soft (concat "notmuch-wash-button-"\r
++ type "-toggle-type"))))\r
++ (add-to-invisibility-spec invis-spec)\r
++ (overlay-put overlay 'invisible (list invis-spec message-invis-spec))\r
++ (overlay-put overlay 'isearch-open-invisible #'notmuch-wash-region-isearch-show)\r
++ (overlay-put overlay 'priority 10)\r
++ (overlay-put overlay 'type type)\r
++\r
++ (goto-char (1- beg))\r
++ (insert prefix)\r
++ (insert-button (notmuch-wash-button-label overlay)\r
++ 'invisibility-spec invis-spec\r
++ 'overlay overlay\r
++ :type button-type))\r
++\r
++ (when scene-of-crime\r
++ (goto-char scene-of-crime)\r
++ (delete-char 1)))))\r
+ \r
+ (defun notmuch-wash-excerpt-citations (msg depth)\r
+ "Excerpt citations and up to one signature."\r
+diff --git a/test/emacs-message-hiding.sh b/test/emacs-message-hiding.sh\r
+index 70bc66d..36708d7 100755\r
+--- a/test/emacs-message-hiding.sh\r
++++ b/test/emacs-message-hiding.sh\r
+@@ -31,7 +31,6 @@ test_emacs '\r
+ (visible-buffer-string)))\r
+ '\r
+ \r
+-test_subtest_known_broken\r
+ test_expect_equal_file EXPECTED OUTPUT\r
+ \r
+ test_done\r
+-- \r
+1.7.8.3\r
+\r