]> git.eshelyaron.com Git - emacs.git/commitdiff
Use a list of text properties to search in symlink filenames in Wdired
authorJuri Linkov <juri@linkov.net>
Sat, 27 Aug 2022 19:43:40 +0000 (22:43 +0300)
committerJuri Linkov <juri@linkov.net>
Sat, 27 Aug 2022 19:43:40 +0000 (22:43 +0300)
* lisp/dired-aux.el (dired-isearch-search-filenames):
Use text properties 'dired-filename' and 'dired-symlink-filename'.

* lisp/dired.el (dired-font-lock-keywords): Add text property
'dired-symlink-filename' on symlinks.

* lisp/isearch.el (isearch-search-fun-in-text-property):
Support a list of text properties (bug#57293).

etc/NEWS
lisp/dired-aux.el
lisp/dired.el
lisp/isearch.el

index 1fd05d7dcc6b744f595e2e2aafdbbf4aff080dbd..1317cd0128331c18d435e1aa412af0b66423bc15 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -2023,7 +2023,10 @@ the buffer will take you to that directory.
 *** Search and replace in Dired/Wdired supports more regexps.
 For example, the regexp ".*" will match only characters that are part
 of the file name.  Also "^.*$" can be used to match at the beginning
-of the file name and at the end of the file name.
+of the file name and at the end of the file name.  This is used only
+when searching on file names.  In Wdired this can be used when the new
+user option 'wdired-search-replace-filenames' is non-nil (which is the
+default).
 
 ** Bookmarks
 
index 94b2baf72d089c023ab04160c8548cbfec3b8e36..06f0b86fc43fd59f9e662b4c28c9c11410b08de9 100644 (file)
@@ -3544,7 +3544,8 @@ Intended to be added to `isearch-mode-hook'."
 The returned function narrows the search to match the search string
 only as part of a file name enclosed by the text property `dired-filename'.
 It's intended to override the default search function."
-  (isearch-search-fun-in-text-property (funcall orig-fun) 'dired-filename))
+  (isearch-search-fun-in-text-property
+   (funcall orig-fun) '(dired-filename dired-symlink-filename)))
 
 ;;;###autoload
 (defun dired-isearch-filenames ()
index f45d215ed605686cb9f813e0852814970b92321f..fa06c8fd4416272462f36848fe0afaa2e7bbb62f 100644 (file)
@@ -786,7 +786,7 @@ Subexpression 2 must end right before the \\n.")
                nil
                '(1 'dired-broken-symlink)
                '(2 dired-symlink-face)
-               '(3 'dired-broken-symlink)))
+               '(3 '(face dired-broken-symlink dired-symlink-filename t))))
    ;;
    ;; Symbolic link to a directory.
    (list dired-re-sym
@@ -798,7 +798,7 @@ Subexpression 2 must end right before the \\n.")
                '(dired-move-to-filename)
                nil
                '(1 dired-symlink-face)
-               '(2 dired-directory-face)))
+               '(2 '(face dired-directory-face dired-symlink-filename t))))
    ;;
    ;; Symbolic link to a non-directory.
    (list dired-re-sym
@@ -812,7 +812,7 @@ Subexpression 2 must end right before the \\n.")
                '(dired-move-to-filename)
                nil
                '(1 dired-symlink-face)
-               '(2 'default)))
+               '(2 '(face default dired-symlink-filename t))))
    ;;
    ;; Sockets, pipes, block devices, char devices.
    (list dired-re-special
index 31fcf01949f0a38ec9b9ed84bbb4af668910cf07..9f1fbb14a4a00981d0b3fc25ccd9fbac1baa93d4 100644 (file)
@@ -4512,21 +4512,35 @@ is a list of cons cells of the form (START . END)."
            (setq bounds (cdr bounds))))
        found))))
 
-(defun isearch-search-fun-in-text-property (search-fun property)
-  "Return the function to search inside text that has the specified PROPERTY.
+(defun isearch-search-fun-in-text-property (search-fun properties)
+  "Return the function to search inside text that has the specified PROPERTIES.
 The function will limit the search for matches only inside text which has
-this property in the current buffer.
+at least one of the text PROPERTIES.
 The argument SEARCH-FUN provides the function to search text, and
 defaults to the value of `isearch-search-fun-default' when nil."
+  (setq properties (ensure-list properties))
   (apply-partially
    #'search-within-boundaries
    search-fun
-   (lambda (pos) (get-text-property (if isearch-forward pos
-                                      (max (1- pos) (point-min)))
-                                    property))
-   (lambda (pos) (if isearch-forward
-                     (next-single-property-change pos property)
-                   (previous-single-property-change pos property)))))
+   (lambda (pos)
+     (let ((pos (if isearch-forward pos (max (1- pos) (point-min)))))
+       (seq-some (lambda (property)
+                   (get-text-property pos property))
+                 properties)))
+   (lambda (pos)
+     (let ((pos-list (if isearch-forward
+                         (mapcar (lambda (property)
+                                   (next-single-property-change
+                                    pos property))
+                                 properties)
+                       (mapcar (lambda (property)
+                                 (previous-single-property-change
+                                  pos property))
+                               properties))))
+       (setq pos-list (delq nil pos-list))
+       (when pos-list (if isearch-forward
+                          (seq-min pos-list)
+                        (seq-max pos-list)))))))
 
 (defun search-within-boundaries ( search-fun get-fun next-fun
                                   string &optional bound noerror count)