unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: Michael Heerdegen <michael_heerdegen@web.de>
Cc: 57293@debbugs.gnu.org, Stefan Kangas <stefankangas@gmail.com>,
	Mike Kupfer <mkupfer@alum.berkeley.edu>
Subject: bug#57293: 29.0.50; query-replace with Wdired skips symlink target
Date: Tue, 23 Aug 2022 22:27:57 +0300	[thread overview]
Message-ID: <861qt6oj42.fsf@mail.linkov.net> (raw)
In-Reply-To: <877d2z2a4u.fsf@web.de> (Michael Heerdegen's message of "Tue, 23 Aug 2022 00:20:33 +0200")

[-- Attachment #1: Type: text/plain, Size: 420 bytes --]

>> Maybe then it's possible to add a new text property on symlink file names?
>> Then query-replace could check for two text properties:
>> 'dired-filename' and 'dired-symlink-filename'.
>
> Yes, I think we could do that.
>
> Note that `dired-insert-set-properties' already sets the invisible text
> property to 'dired-hide-details-link'.

Ok, here is the fix to support search and query-replace of e.g. "fo* → baz":


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: dired-symlink-filename.patch --]
[-- Type: text/x-diff, Size: 4690 bytes --]

diff --git a/etc/NEWS b/etc/NEWS
index 83fa28b325..596e52b4a2 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -2002,7 +2002,9 @@ 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.  In Wdired this can
+be used when the new user option 'wdired-search-replace-filenames' is
+non-nil (which is the default).
 
 ** Bookmarks
 
diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index 94b2baf72d..06f0b86fc4 100644
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -3544,7 +3544,8 @@ dired-isearch-search-filenames
 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 ()
diff --git a/lisp/dired.el b/lisp/dired.el
index f45d215ed6..fa06c8fd44 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -786,7 +786,7 @@ dired-font-lock-keywords
                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 @@ dired-font-lock-keywords
                '(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 @@ dired-font-lock-keywords
                '(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
diff --git a/lisp/isearch.el b/lisp/isearch.el
index 31fcf01949..7fdae06c96 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -4512,21 +4522,34 @@ isearch-search-fun-in-noncontiguous-region
            (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.
+these list of PROPERTIES in the current buffer.
 The argument SEARCH-FUN provides the function to search text, and
 defaults to the value of `isearch-search-fun-default' when nil."
   (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))
+                 (ensure-list properties))))
+   (lambda (pos)
+     (let ((pos-list (if isearch-forward
+                         (mapcar (lambda (property)
+                                   (next-single-property-change
+                                    pos property))
+                                 (ensure-list properties))
+                       (mapcar (lambda (property)
+                                 (previous-single-property-change
+                                  pos property))
+                               (ensure-list 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)

  reply	other threads:[~2022-08-23 19:27 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-19  3:11 bug#57293: 29.0.50; query-replace with Wdired skips symlink target Mike Kupfer
2022-08-21  0:47 ` Michael Heerdegen
2022-08-21  1:07   ` Stefan Kangas
2022-08-21  1:46     ` Michael Heerdegen
2022-08-21  1:54     ` Mike Kupfer
2022-08-21 16:37       ` Juri Linkov
2022-08-22  6:16         ` Michael Heerdegen
2022-08-22  6:52           ` Juri Linkov
2022-08-22 22:20             ` Michael Heerdegen
2022-08-23 19:27               ` Juri Linkov [this message]
2022-08-23 23:39                 ` Michael Heerdegen
2022-08-24  1:15                   ` Mike Kupfer
2022-08-27  4:03                   ` Mike Kupfer
2022-08-27 19:45                     ` Juri Linkov
2022-08-27 19:44                   ` Juri Linkov
2022-08-28  2:34                     ` Michael Heerdegen

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=861qt6oj42.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=57293@debbugs.gnu.org \
    --cc=michael_heerdegen@web.de \
    --cc=mkupfer@alum.berkeley.edu \
    --cc=stefankangas@gmail.com \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).