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 89879429E2A for ; Thu, 26 May 2011 14:38:19 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.799 X-Spam-Level: X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.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 HCzpEyxpKJ+N for ; Thu, 26 May 2011 14:38:18 -0700 (PDT) Received: from mail-fx0-f53.google.com (mail-fx0-f53.google.com [209.85.161.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id D493D429E25 for ; Thu, 26 May 2011 14:38:17 -0700 (PDT) Received: by mail-fx0-f53.google.com with SMTP id 8so1052886fxm.26 for ; Thu, 26 May 2011 14:38:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=8SnJWrkUxy03QbIlouFFns24JV2tu3uxZl1PB79vQX0=; b=qWq09Qa1bBIGCCK2EQMsXm5bNJE072A3O7viOATSyEpt1c+uKG5CQviQ9bD+vKpuqW s7tTeridA0/W7svAOr3uD/wm36b8U+vKUJTlc1bRdo21ty/4jTkgUWHspFk7shxE68fw SUXZa47BNaLjWaH6N9Jzs9RsVpgXPXocp0XVU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=k7IIz8uHU4v4qkwLjQMjJGqf9Zb3wwOLF6J1PQcJPa77SU8FP5Tz939MsvmiDG4Bby KWoDwfQXbT5ByIWwvlXP1qyveDXW13ZuaiLNA9/lCr+zn2DoTE9vojVrXffCSUbvCwUj VebBN75SrnIY4tLgDgqYZXY5HEaTUxXMk8hWk= Received: by 10.223.9.137 with SMTP id l9mr1479801fal.25.1306445897509; Thu, 26 May 2011 14:38:17 -0700 (PDT) Received: from localhost ([91.144.186.21]) by mx.google.com with ESMTPS id l26sm446553fam.21.2011.05.26.14.38.16 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 26 May 2011 14:38:16 -0700 (PDT) From: Dmitry Kurochkin To: notmuch@notmuchmail.org Subject: [PATCH 2/2] Workaround for Emacs bug #8721. Date: Fri, 27 May 2011 01:38:35 +0400 Message-Id: <1306445915-9474-2-git-send-email-dmitry.kurochkin@gmail.com> X-Mailer: git-send-email 1.7.5.1 In-Reply-To: <1306445915-9474-1-git-send-email-dmitry.kurochkin@gmail.com> References: <1306361416-5019-1-git-send-email-dmitry.kurochkin@gmail.com> <1306445915-9474-1-git-send-email-dmitry.kurochkin@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: Thu, 26 May 2011 21:38:19 -0000 The patch adds `notmuch-isearch-range-invisible' function which is the same as `isearch-range-invisible' but with fixed Emacs bug `notmuch-isearch-range-invisible' instead of the original `isearch-range-invisible' when in `notmuch-show-mode'. --- emacs/notmuch-wash.el | 67 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 67 insertions(+), 0 deletions(-) diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el index 992fa8f..f37fd95 100644 --- a/emacs/notmuch-wash.el +++ b/emacs/notmuch-wash.el @@ -298,4 +298,71 @@ for error." ;; +;; Temporary workaround for Emacs bug #8721 +;; http://debbugs.gnu.org/cgi/bugreport.cgi?bug=8721 + +(defun notmuch-isearch-range-invisible (beg end) + "Same as `isearch-range-invisible' but with fixed Emacs bug #8721." + (when (/= beg end) + ;; Check that invisibility runs up to END. + (save-excursion + (goto-char beg) + (let (;; can-be-opened keeps track if we can open some overlays. + (can-be-opened (eq search-invisible 'open)) + ;; the list of overlays that could be opened + (crt-overlays nil)) + (when (and can-be-opened isearch-hide-immediately) + (isearch-close-unnecessary-overlays beg end)) + ;; If the following character is currently invisible, + ;; skip all characters with that same `invisible' property value. + ;; Do that over and over. + (while (and (< (point) end) (invisible-p (point))) + (if (get-text-property (point) 'invisible) + (progn + (goto-char (next-single-property-change (point) 'invisible + nil end)) + ;; if text is hidden by an `invisible' text property + ;; we cannot open it at all. + (setq can-be-opened nil)) + (when can-be-opened + (let ((overlays (overlays-at (point))) + ov-list + o + invis-prop) + (while overlays + (setq o (car overlays) + invis-prop (overlay-get o 'invisible)) + (if (invisible-p invis-prop) + (if (overlay-get o 'isearch-open-invisible) + (setq ov-list (cons o ov-list)) + ;; We found one overlay that cannot be + ;; opened, that means the whole chunk + ;; cannot be opened. + (setq can-be-opened nil))) + (setq overlays (cdr overlays))) + (if can-be-opened + ;; It makes sense to append to the open + ;; overlays list only if we know that this is + ;; t. + (setq crt-overlays (append ov-list crt-overlays))))) + (goto-char (next-overlay-change (point))))) + ;; See if invisibility reaches up thru END. + (if (>= (point) end) + (if (and can-be-opened (consp crt-overlays)) + (progn + (setq isearch-opened-overlays + (append isearch-opened-overlays crt-overlays)) + (mapc 'isearch-open-overlay-temporary crt-overlays) + nil) + (setq isearch-hidden t))))))) + +(defadvice isearch-range-invisible (around notmuch-isearch-range-invisible-advice activate) + "Call `notmuch-isearch-range-invisible' instead of the original +`isearch-range-invisible' when in `notmuch-show-mode' mode." + (if (eq major-mode 'notmuch-show-mode) + (setq ad-return-value (notmuch-isearch-range-invisible beg end)) + ad-do-it)) + +;; + (provide 'notmuch-wash) -- 1.7.5.1