Subject: Re: bug#20092: 24.4.91; False matches with incremental search in Info

From: Juri Linkov <[email-masked]>
Date: Thu, 12 Mar 2015 21:45:33 +0200

>> confusing behaviour that prompted me to report this bug.); and 3) if the
>> value of search-invisible is `open' then the chunk of invisible text is
>> made visible ("opened") temporarilly, and the match shown within it.
>
> That's right.  But currently `open' doesn't actually work for text
> that's hidden via text-properties (as opposed to overlays).  I think
> that's the problem you bumped into.

Since Info doesn't open invisible text, then maybe `Info-mode' should
set the buffer-local value of `search-invisible' to nil?

diff --git a/lisp/info.el b/lisp/info.el
index 0159661..2c73639 100644
--- a/lisp/info.el
+++ b/lisp/info.el
@@ -4305,6 +4305,7 @@ (define-derived-mode Info-mode nil "Info" ;FIXME: Derive from special-mode?
   (setq-local isearch-wrap-function #'Info-isearch-wrap)
   (setq-local isearch-push-state-function #'Info-isearch-push-state)
   (setq-local isearch-filter-predicate #'Info-isearch-filter)
+  (setq-local search-invisible nil)
   (setq-local revert-buffer-function #'Info-revert-buffer-function)
   (setq-local font-lock-defaults '(Info-mode-font-lock-keywords t t))
   (Info-set-mode-line)

> I'm not sure what's the best and/or simplest way to fix it.
> Maybe a first step would be to emit a message explaining that the match
> is inside hidden text (at least so the user gets a clue about what's
> going on).

Like in the message prefix?

diff --git a/lisp/isearch.el b/lisp/isearch.el
index 191ec82..4bc2129 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -2526,6 +2526,7 @@ (defun isearch-message-prefix (&optional ellipsis nonincremental)
 		    (multi-isearch-buffer-list "multi-buffer ")
 		    (t ""))
 		   (or isearch-message-prefix-add "")
+		   (if isearch-hidden "hidden " "")
 		   (if nonincremental "search" "I-search")
 		   (if isearch-forward "" " backward")
 		   (if current-input-method

Or maybe better in the message suffix?

diff --git a/lisp/isearch.el b/lisp/isearch.el
index 191ec82..4bc2129 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -2544,6 +2545,7 @@ (defun isearch-message-suffix (&optional c-q-hack)
 	  (if isearch-error
 	      (concat " [" isearch-error "]")
 	    "")
+	  (if isearch-hidden " [hidden]" "")
 	  (or isearch-message-suffix-add "")))

>> In any case looking at the code, it does actually toggle
>> (between nil and t), but also changes `open' to nil, and then one can
>> never "toggle" back to `open'.
>
> That's indeed another problem that should be fixed.

I can't reproduce this problem: after `C-s M-s i M-s i'
isearch-invisible is still `open'.