--- /dev/null
+Return-Path: <dmitry.kurochkin@gmail.com>\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 B1EBA431FD0\r
+ for <notmuch@notmuchmail.org>; Fri, 27 May 2011 18:28:56 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.799\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
+ tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+ FREEMAIL_FROM=0.001, 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 JKyN67Q5y9V6 for <notmuch@notmuchmail.org>;\r
+ Fri, 27 May 2011 18:28:56 -0700 (PDT)\r
+Received: from mail-fx0-f53.google.com (mail-fx0-f53.google.com\r
+ [209.85.161.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id C8959431FB6\r
+ for <notmuch@notmuchmail.org>; Fri, 27 May 2011 18:28:55 -0700 (PDT)\r
+Received: by fxm8 with SMTP id 8so1788845fxm.26\r
+ for <notmuch@notmuchmail.org>; Fri, 27 May 2011 18:28:54 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
+ h=domainkey-signature:from:to:subject:in-reply-to:references\r
+ :user-agent:date:message-id:mime-version:content-type;\r
+ bh=aXSDq5M1BIGcE6EhAz1Lgp0y2wlM2vY8rsqKoNg9sE4=;\r
+ b=k5kaQYOgTq0hlfchK1IkeX/ZWsMVnbHTUItfFm9F39BkPvRSfvHCj4vtxsjpr1SonS\r
+ gYK/UI3oZsK6HKU4g37a5xtLpWse17eKiGuzn/bituff2J8zwO3WKu7KTjMyhQmW897z\r
+ 48+p2Xk35ocuMMWMPx57KS5orBGUBVG1SlNng=\r
+DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;\r
+ h=from:to:subject:in-reply-to:references:user-agent:date:message-id\r
+ :mime-version:content-type;\r
+ b=t+t8YjIVnwbeg15KFEmuOS2HWRk/hIQwfBAObfiRAVvx0AyFh/VsXMRj+ubTtXdGUn\r
+ L23z0ld/OsqeqwLEJdVnL8kIX6styHh6jaifCpMstGaFSLk934h7WJCDqfaXw4PsSwot\r
+ ZigOlEkTpxXllmkTdUHUOrGClGMP+4CL28ARo=\r
+Received: by 10.223.7.8 with SMTP id b8mr1410766fab.19.1306546134557;\r
+ Fri, 27 May 2011 18:28:54 -0700 (PDT)\r
+Received: from localhost ([91.144.186.21])\r
+ by mx.google.com with ESMTPS id e16sm22463fak.17.2011.05.27.18.28.52\r
+ (version=TLSv1/SSLv3 cipher=OTHER);\r
+ Fri, 27 May 2011 18:28:53 -0700 (PDT)\r
+From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: Re: [PATCH 2/2] Workaround for Emacs bug #8721.\r
+In-Reply-To: <874o4hp205.fsf@gmail.com>\r
+References: <1306361416-5019-1-git-send-email-dmitry.kurochkin@gmail.com>\r
+ <1306445915-9474-1-git-send-email-dmitry.kurochkin@gmail.com>\r
+ <1306445915-9474-2-git-send-email-dmitry.kurochkin@gmail.com>\r
+ <874o4hp205.fsf@gmail.com>\r
+User-Agent: Notmuch/0.5-216-g0104e23 (http://notmuchmail.org) Emacs/23.3.1\r
+ (x86_64-pc-linux-gnu)\r
+Date: Sat, 28 May 2011 05:29:17 +0400\r
+Message-ID: <871uzjpq8i.fsf@gmail.com>\r
+MIME-Version: 1.0\r
+Content-Type: multipart/mixed; boundary="=-=-="\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: Sat, 28 May 2011 01:28:56 -0000\r
+\r
+--=-=-=\r
+\r
+This is an amended patch which uses `isearch-range-invisible' from Emacs\r
+trunk r104393 (includes the second patch from #8721).\r
+\r
+Regards,\r
+ Dmitry\r
+\r
+--=-=-=\r
+Content-Type: text/x-diff\r
+Content-Disposition: inline;\r
+ filename=0001-Workaround-for-Emacs-bug-8721.patch\r
+\r
+>From d56f2c308c995639aad04f0e5388b52912e603b0 Mon Sep 17 00:00:00 2001\r
+From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>\r
+Date: Fri, 27 May 2011 01:35:09 +0400\r
+Subject: [PATCH] Workaround for Emacs bug #8721.\r
+\r
+The patch adds `notmuch-isearch-range-invisible' function which\r
+is the same as `isearch-range-invisible' but with fixed Emacs bug\r
+ #8721. Advice added for `isearch-range-invisible' which calls\r
+`notmuch-isearch-range-invisible' instead of the original\r
+`isearch-range-invisible' when in `notmuch-show-mode'.\r
+---\r
+ emacs/notmuch-wash.el | 67 +++++++++++++++++++++++++++++++++++++++++++++++++\r
+ 1 files changed, 67 insertions(+), 0 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el\r
+index 992fa8f..e046d62 100644\r
+--- a/emacs/notmuch-wash.el\r
++++ b/emacs/notmuch-wash.el\r
+@@ -298,4 +298,71 @@ for error."\r
+ \r
+ ;;\r
+ \r
++;; Temporary workaround for Emacs bug #8721\r
++;; http://debbugs.gnu.org/cgi/bugreport.cgi?bug=8721\r
++\r
++(defun notmuch-isearch-range-invisible (beg end)\r
++ "Same as `isearch-range-invisible' but with fixed Emacs bug #8721."\r
++ (when (/= beg end)\r
++ ;; Check that invisibility runs up to END.\r
++ (save-excursion\r
++ (goto-char beg)\r
++ (let (;; can-be-opened keeps track if we can open some overlays.\r
++ (can-be-opened (eq search-invisible 'open))\r
++ ;; the list of overlays that could be opened\r
++ (crt-overlays nil))\r
++ (when (and can-be-opened isearch-hide-immediately)\r
++ (isearch-close-unnecessary-overlays beg end))\r
++ ;; If the following character is currently invisible,\r
++ ;; skip all characters with that same `invisible' property value.\r
++ ;; Do that over and over.\r
++ (while (and (< (point) end) (invisible-p (point)))\r
++ (if (invisible-p (get-text-property (point) 'invisible))\r
++ (progn\r
++ (goto-char (next-single-property-change (point) 'invisible\r
++ nil end))\r
++ ;; if text is hidden by an `invisible' text property\r
++ ;; we cannot open it at all.\r
++ (setq can-be-opened nil))\r
++ (when can-be-opened\r
++ (let ((overlays (overlays-at (point)))\r
++ ov-list\r
++ o\r
++ invis-prop)\r
++ (while overlays\r
++ (setq o (car overlays)\r
++ invis-prop (overlay-get o 'invisible))\r
++ (if (invisible-p invis-prop)\r
++ (if (overlay-get o 'isearch-open-invisible)\r
++ (setq ov-list (cons o ov-list))\r
++ ;; We found one overlay that cannot be\r
++ ;; opened, that means the whole chunk\r
++ ;; cannot be opened.\r
++ (setq can-be-opened nil)))\r
++ (setq overlays (cdr overlays)))\r
++ (if can-be-opened\r
++ ;; It makes sense to append to the open\r
++ ;; overlays list only if we know that this is\r
++ ;; t.\r
++ (setq crt-overlays (append ov-list crt-overlays)))))\r
++ (goto-char (next-overlay-change (point)))))\r
++ ;; See if invisibility reaches up thru END.\r
++ (if (>= (point) end)\r
++ (if (and can-be-opened (consp crt-overlays))\r
++ (progn\r
++ (setq isearch-opened-overlays\r
++ (append isearch-opened-overlays crt-overlays))\r
++ (mapc 'isearch-open-overlay-temporary crt-overlays)\r
++ nil)\r
++ (setq isearch-hidden t)))))))\r
++\r
++(defadvice isearch-range-invisible (around notmuch-isearch-range-invisible-advice activate)\r
++ "Call `notmuch-isearch-range-invisible' instead of the original\r
++`isearch-range-invisible' when in `notmuch-show-mode' mode."\r
++ (if (eq major-mode 'notmuch-show-mode)\r
++ (setq ad-return-value (notmuch-isearch-range-invisible beg end))\r
++ ad-do-it))\r
++\r
++;;\r
++\r
+ (provide 'notmuch-wash)\r
+-- \r
+1.7.5.1\r
+\r
+\r
+--=-=-=--\r