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

From: [email-masked] (N. Jackson)
Date: Thu, 12 Mar 2015 00:31:56 -0300

At 21:57 -0300 on Wednesday 2015-03-11, N. Jackson wrote:

> In the top level node of Emacs Info, incremental search is matching text
> that isn't there.
>
> My search text was "sage". Repeatedly pressing C-s, I get four or five
> correct matches, then I end up in the "GNU C library functions and
> macros" section where I get several false matches with point placed at
> the end of the line. (E.g. On the entry "err: (libc)".)
>
> I'm guessing there is some invisible text there (I don't know how I can
> check; switching to fundamental mode reveals nothing), but probably
> I-search shouldn't be finding it.

Further to my report, I did a bit of poking around.

Setting the variable Info-hide-note-references to nil allows me to see
the invisible text.

An example of an entry that was showing a false match for "sage" was

    * err: (libc)

and setting Info-hide-note-references to nil, this displays as

    * err: (libc)Error Messages.
                          ^^^^
which at least shows what I-search was finding.

For me the value of search-invisible is `open' (which I assume is the
default). The bug does *not* manifest itself when I set search-invisible
to nil.

I found this function in info.el:

#+BEGIN_SRC emacs-lisp
    (defun Info-isearch-filter (beg-found found)
      "Test whether the current search hit is a visible useful text.
    Return non-nil if the text from BEG-FOUND to FOUND is visible
    and is not in the header line or a tag table."
      (save-match-data
	(let ((backward (< found beg-found)))
	  (not
	   (or
	    (and (not search-invisible)
		 (if backward
		     (or (text-property-not-all found beg-found 'invisible nil)
			 (text-property-not-all found beg-found 'display nil))
		   (or (text-property-not-all beg-found found 'invisible nil)
		       (text-property-not-all beg-found found 'display nil))))
	    ;; Skip node header line
	    (and (save-excursion (forward-line -1)
				 (looking-at "\^_"))
		 (forward-line (if backward -1 1)))
	    ;; Skip Tag Table node
	    (save-excursion
	      (and (search-backward "\^_" nil t)
		   (looking-at
		    "\^_\n\\(Tag Table\\|Local Variables\\)"))))))))
#+END_SRC

I don't know elisp, but if this function is relevant here (I have no
idea if it is and I don't even know if runs in this context; I didn't
try running the debugger yet as I don't yet know how) and if it is
intended to make I-search ignore the invisible text, then the

    (not search-invisible)

form looks suspect perhaps?

    (not 'open) => nil
    (not t)  => nil
    (not nil) => t

So here, for search-invisible to be `open' is equivalent to it being t
which would explain the buggy behaviour that I see. Or am I missing
something?

Thanks.