all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: Ihor Radchenko <yantar92@posteo.net>
Cc: bobf32@gmail.com, 64178@debbugs.gnu.org
Subject: bug#64178: replace-regexp ignoring value of org-search-invisible
Date: Thu, 22 Jun 2023 19:52:25 +0300	[thread overview]
Message-ID: <86h6qzxx2e.fsf@mail.linkov.net> (raw)
In-Reply-To: <87ttv0c4zx.fsf@localhost> (Ihor Radchenko's message of "Thu, 22 Jun 2023 07:48:02 +0000")

>>> 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





  reply	other threads:[~2023-06-22 16:52 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-19 20:15 bug#64178: replace-regexp ignoring value of org-search-invisible bobf32
2023-06-20  8:50 ` Ihor Radchenko
2023-06-20 10:09   ` bobf32
2023-06-20 10:22     ` Ihor Radchenko
2023-06-20 20:48       ` bobf32
2023-06-20 21:02         ` Ihor Radchenko
2023-06-20 21:04           ` bobf32
2023-06-21 10:21             ` Ihor Radchenko
2023-06-21 15:50               ` Juri Linkov
2023-06-22  6:50               ` Juri Linkov
2023-06-22  7:48                 ` Ihor Radchenko
2023-06-22 16:52                   ` Juri Linkov [this message]
2023-06-23 10:46                     ` Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86h6qzxx2e.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=64178@debbugs.gnu.org \
    --cc=bobf32@gmail.com \
    --cc=yantar92@posteo.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.