GNU bug report logs - #8721
isearch does not handle list values for `invisible' property

Previous Next

Package: emacs;

Reported by: Dmitry Kurochkin <dmitry.kurochkin <at> gmail.com>

Date: Mon, 23 May 2011 23:53:01 UTC

Severity: normal

Tags: patch

Found in version 24.0.50

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 8721 in the body.
You can then email your comments to 8721 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8721; Package emacs. (Mon, 23 May 2011 23:53:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Dmitry Kurochkin <dmitry.kurochkin <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 23 May 2011 23:53:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Kurochkin <dmitry.kurochkin <at> gmail.com>
To: submit <at> debbugs.gnu.org
Subject: isearch does not handle list values for `invisible' property
Date: Tue, 24 May 2011 03:46:56 +0400
[Message part 1 (text/plain, inline)]
Package: emacs
Version: 24.0.50
Tags: patch

Isearch allows searching in hidden text by showing invisible overlays.
But it does not work with overlays which have a list value for
`invisible' property.

Attached patch fixes the issue by using `invalid-p' function instead of
custom checks.

The second patch fixes another related issue.

Regards,
  Dmitry
[1-use-invisible-p-in-isearch-range-invisible.patch (text/x-diff, inline)]
isearch.el (isearch-range-invisible): use `invisible-p' instead of custom checks

Isearch allows searching in hidden text by showing invisible overlays.
The `isearch-range-invisible' function needs to check if a character
is visible and which overlays make it invisible.  Before the change,
this was done using direct checks of properties and
`buffer-invisibility-spec' variable.  Besides making code more
complex, the checks were not complete: it did not handle case when
`invisible' property is a list.  The patch replaces the custom checks
with `invisible-p' function.

=== modified file 'lisp/isearch.el'
--- lisp/isearch.el	2011-05-03 03:34:26 +0000
+++ lisp/isearch.el	2011-05-23 23:20:05 +0000
@@ -2417,66 +2417,57 @@ update the match data, and return point.
 	    (overlay-put ov 'intangible (overlay-get ov 'isearch-intangible))
 	    (overlay-put ov 'isearch-invisible nil)
 	    (overlay-put ov 'isearch-intangible nil)))))))
 
 
 (defun isearch-range-invisible (beg end)
   "Return t if all the text from BEG to END is invisible."
   (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)
-		    (let ((prop
-			   (get-char-property (point) 'invisible)))
-		      (if (eq buffer-invisibility-spec t)
-			  prop
-			(or (memq prop buffer-invisibility-spec)
-			    (assq prop buffer-invisibility-spec)))))
+	(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 (if (eq buffer-invisibility-spec t)
-			  invis-prop
-			(or (memq invis-prop buffer-invisibility-spec)
-			    (assq invis-prop buffer-invisibility-spec)))
+		  (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)

[2-improve-invisible-text-propery-check-in-isearch-range-invisible.patch (text/x-diff, inline)]
isearch.el (isearch-range-invisible): improve `invisible' text property check

Isearch does not search in text hidden with `invisible' text property.
Before the change, `isearch-range-invisible' function checked if
`invisible' text property is set.  But it did not check if the text
property really makes the text invisible.  This results in isearch not
searching a visible text in some cases.  The patch uses `invisible-p'
function to check if the `invisible' text property really makes the
text invisible.

=== modified file 'lisp/isearch.el'
--- lisp/isearch.el	2011-05-23 23:20:05 +0000
+++ lisp/isearch.el	2011-05-23 23:44:16 +0000
@@ -2418,41 +2418,41 @@ update the match data, and return point.
 	    (overlay-put ov 'isearch-invisible nil)
 	    (overlay-put ov 'isearch-intangible nil)))))))
 
 
 (defun isearch-range-invisible (beg end)
   "Return t if all the text from BEG to END is invisible."
   (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)
+	  (if (invisible-p (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.


Reply sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
You have taken responsibility. (Tue, 24 May 2011 18:16:02 GMT) Full text and rfc822 format available.

Notification sent to Dmitry Kurochkin <dmitry.kurochkin <at> gmail.com>:
bug acknowledged by developer. (Tue, 24 May 2011 18:16:02 GMT) Full text and rfc822 format available.

Message #10 received at 8721-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Dmitry Kurochkin <dmitry.kurochkin <at> gmail.com>
Cc: 8721-done <at> debbugs.gnu.org
Subject: Re: bug#8721: isearch does not handle list values for `invisible'
	property
Date: Tue, 24 May 2011 15:15:50 -0300
> Attached patch fixes the issue by using `invisible-p' function instead of
> custom checks.

Thanks for catching this.  I installed your very nice patch on the trunk,


        Stefan




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8721; Package emacs. (Tue, 24 May 2011 18:26:01 GMT) Full text and rfc822 format available.

Message #13 received at 8721 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Kurochkin <dmitry.kurochkin <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 8721 <at> debbugs.gnu.org
Subject: Re: bug#8721: isearch does not handle list values for `invisible'
	property
Date: Tue, 24 May 2011 22:26:01 +0400
On Tue, 24 May 2011 15:15:50 -0300, Stefan Monnier <monnier <at> iro.umontreal.ca> wrote:
> > Attached patch fixes the issue by using `invisible-p' function instead of
> > custom checks.
> 
> Thanks for catching this.  I installed your very nice patch on the trunk,
> 

Thank you.  Please consider pushing the second patch to the trunk as
well.

Regards,
  Dmitry

> 
>         Stefan




Message #14 received at 8721-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Dmitry Kurochkin <dmitry.kurochkin <at> gmail.com>
Cc: 8721-done <at> debbugs.gnu.org
Subject: Re: bug#8721: isearch does not handle list values for `invisible'
	property
Date: Fri, 27 May 2011 22:16:25 -0300
>> > Attached patch fixes the issue by using `invisible-p' function instead of
>> > custom checks.
>> Thanks for catching this.  I installed your very nice patch on the trunk,
> Thank you.  Please consider pushing the second patch to the trunk as well.

Duh!  Sorry I missed it and thanks for the heads up.
I just installed the second installment.  I hope you didn't a third one
in there somewhere.


        Stefan




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 25 Jun 2011 11:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 14 years and 56 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.