GNU bug report logs -
#14013
24.3.50; dired-isearch-filenames-regexp is matching text outside filenames
Previous Next
Reported by: michael_heerdegen <at> web.de
Date: Wed, 20 Mar 2013 23:42:01 UTC
Severity: normal
Tags: patch
Merged with 29215
Found in versions 24.3.50, 26.0
Fixed in version 29.0.50
Done: Juri Linkov <juri <at> jurta.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
>> I wonder if it is realistic to use a temporary helper buffer to
>> implement ^.
>
> Good idea. Maybe even not a buffer, but just a string.
> Are there any differences between buffer matching and string matching?
>
> Then first we could remove ^ from the search regexp, and when it finds
> something, then get the found buffer-substring using text properties
> and match it with the original regexp that contains ^.
This works surprisingly well. Maybe there are more corner cases,
but something already works with quick tests:
[dired-isearch-search-filenames.patch (text/x-diff, inline)]
diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index c49e4e91d8..0832ea1ddb 100644
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -3202,7 +3202,16 @@ dired-isearch-search-filenames
(if isearch-forward old (max (1- old) (point-min)))
property)
old))
- end found)
+ end found regexp (i 0))
+ (when isearch-regexp
+ (setq regexp string)
+ (while (string-match "\\^\\|\\$\\|\\\\`\\|\\\\'" string i)
+ (setq i (- (match-end 0) (length (match-string 0 string))))
+ (if (save-match-data (not (subregexp-context-p
+ string (match-beginning 0))))
+ ;; The ^/$ is inside a char-range or escaped or something.
+ nil
+ (setq string (replace-match "" t t string)))))
;; Otherwise, try to search for the next property.
(unless beg
(setq beg (if isearch-forward
@@ -3221,6 +3230,9 @@ dired-isearch-search-filenames
(max bound end))
end)
noerror count))
+ (when (and regexp (not (string-match-p
+ regexp (buffer-substring beg end))))
+ (setq found nil))
(unless found
(setq beg (if isearch-forward
(next-single-property-change end property)
This bug report was last modified 1 year and 352 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.