bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#14013: 24.3.50; dired-isearch-filenames-regexp is matching text outs


From: Juri Linkov
Subject: bug#14013: 24.3.50; dired-isearch-filenames-regexp is matching text outside filenames
Date: Fri, 10 Jun 2022 20:17:25 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu)

>> This works surprisingly well.  Maybe there are more corner cases,
>> but something already works with quick tests:
>>
>> diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
>
> Yes, not bad indeed.  Did you find any corner cases?

Using a temporary buffer like you proposed works fine,
and handles all possible regexps including corner cases.
However, wouldn't this make the search too inefficient?

diff --git a/lisp/isearch.el b/lisp/isearch.el
index 5fbfb724a3..8470170f24 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -4482,12 +4545,25 @@ isearch-search-fun-in-text-property
         (setq end (if isearch-forward
                       (next-single-property-change beg property)
                     (previous-single-property-change beg property)))
-        (setq found (funcall (or search-fun (isearch-search-fun-default))
-                             string (if bound (if isearch-forward
-                                                  (min bound end)
-                                                (max bound end))
-                                      end)
-                             noerror count))
+        (if (and isearch-regexp (string-match-p "\\(\\^\\)\\|\\$" string))
+            (let ((substring (buffer-substring beg end))
+                  match-data)
+              (with-temp-buffer
+                (insert substring)
+                (goto-char (point-min))
+                (setq found (funcall (or search-fun 
(isearch-search-fun-default))
+                                     string (if bound (- bound beg) (1+ (- end 
beg)))
+                                     noerror count))
+                (when found
+                  (setq found (+ found beg)
+                        match-data (mapcar (lambda (m) (1- (+ m beg))) 
(match-data)))))
+              (when match-data (set-match-data match-data)))
+          (setq found (funcall (or search-fun (isearch-search-fun-default))
+                               string (if bound (if isearch-forward
+                                                    (min bound end)
+                                                  (max bound end))
+                                        end)
+                               noerror count)))
         (unless found
           (setq beg (if isearch-forward
                         (next-single-property-change end property)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]