From 70713b37ac5795bc001553160bbcdc24ddab7d68 Mon Sep 17 00:00:00 2001
From: York Zhao <gtdplatform@gmail.com>
Date: Wed, 22 Jun 2011 17:57:05 -0400
Subject: [PATCH] "search-next" opens invisible area

Added a feature for the search next/previous command 'n' and 'N' so that if
"search-invisible" is "open" these commands will be able to open an invisible
area when the match enters that area, at the same time re-close the previouly
opened invisible area the match has just moved away from (provided that the
subsequent 'n/N' is pressed within "vimpulse-flash-delay" and no "non-search"
commands had been executed between the two "n/N" commands).
---
 vimpulse-compatibility.el                |    1 +
 vimpulse-viper-function-redefinitions.el |    6 ++++++
 2 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/vimpulse-compatibility.el b/vimpulse-compatibility.el
index c37f49e..3733af1 100644
--- a/vimpulse-compatibility.el
+++ b/vimpulse-compatibility.el
@@ -237,6 +237,7 @@ Disable anyway if FORCE is t."
          (isearch-highlight-all-cleanup))
     (and (fboundp 'lazy-highlight-cleanup)
          (lazy-highlight-cleanup t))
+    (isearch-clean-overlays)
     (when vimpulse-flash-timer
       (cancel-timer vimpulse-flash-timer)))
   (remove-hook 'pre-command-hook 'vimpulse-flash-hook))
diff --git a/vimpulse-viper-function-redefinitions.el b/vimpulse-viper-function-redefinitions.el
index 73bbce8..0a9695b 100644
--- a/vimpulse-viper-function-redefinitions.el
+++ b/vimpulse-viper-function-redefinitions.el
@@ -1022,6 +1022,9 @@ docstring. The variable becomes buffer-local whenever set.")
                         (re-search-backward string))
                     (search-forward string nil nil val)
                     (search-backward string))
+		  ;; Handles opening and closing of invisble area
+		  (funcall isearch-filter-predicate
+			   (match-beginning 0) (match-end 0))
                   (if (not (equal (point) start-point))
                       (push-mark start-point t)))
               (search-failed
@@ -1052,6 +1055,9 @@ docstring. The variable becomes buffer-local whenever set.")
                 (if viper-re-search
                     (re-search-backward string nil nil val)
                   (search-backward string nil nil val))
+		;; Handles opening and closing of invisble area
+		(funcall isearch-filter-predicate
+			 (match-beginning 0) (match-end 0))
                 (if (not (equal (point) start-point))
                     (push-mark start-point t)))
             (search-failed
-- 
1.7.4

