GNU bug report logs - #64178
replace-regexp ignoring value of org-search-invisible

Previous Next

Package: emacs;

Reported by: bobf32 <at> gmail.com

Date: Mon, 19 Jun 2023 20:17:01 UTC

Severity: normal

Full log


View this message in rfc822 format

From: Juri Linkov <juri <at> linkov.net>
To: Ihor Radchenko <yantar92 <at> posteo.net>
Cc: bobf32 <at> gmail.com, 64178 <at> debbugs.gnu.org
Subject: bug#64178: replace-regexp ignoring value of org-search-invisible
Date: Thu, 22 Jun 2023 19:52:25 +0300
>>> Ok. Then, it is not an Org mode bug.
>>
>> Actually, Isearch never supported zero-length invisible matches.
>> The following condition was in isearch.el since day 1:
>>
>>   (defun isearch-range-invisible (beg end)
>>     "Return t if all the text from BEG to END is invisible."
>>     (when (/= beg end)
>>
>> So any zero-length match is deemed visible by Isearch.
>
> Which is unexpected.
> It is natural to expect that zero-width matches are considered invisible
> when the surrounding text is invisible.
>
> Also, is this documented anywhere?

This corner case doesn't seem to be documented.  Probably not for
emacs-29, but something like this would require more testing:

#+begin_src diff
diff --git a/lisp/isearch.el b/lisp/isearch.el
index 3d2bbda4975..162b99233d7 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -3798,7 +3798,7 @@ isearch-close-unnecessary-overlays
 
 (defun isearch-range-invisible (beg end)
   "Return t if all the text from BEG to END is invisible."
-  (when (/= beg end)
+  (when t
     ;; Check that invisibility runs up to END.
     (save-excursion
       (goto-char beg)
@@ -3812,7 +3812,8 @@ isearch-range-invisible
 	;; 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)))
+	(while (and (or (= beg end (point)) (< (point) end))
+                    (invisible-p (point)))
 	  (if (invisible-p (get-text-property (point) 'invisible))
 	      (progn
 		(goto-char (next-single-property-change (point) 'invisible
@@ -3843,7 +3844,7 @@ isearch-range-invisible
 		    (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 (not (= beg end (point))) (>= (point) end))
 	    (if (and can-be-opened (consp crt-overlays))
 		(progn
 		  (unless (eq search-invisible 'can-be-opened)
#+end_src




This bug report was last modified 15 days ago.

Previous Next


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