From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#57293: 29.0.50; query-replace with Wdired skips symlink target Date: Tue, 23 Aug 2022 22:27:57 +0300 Organization: LINKOV.NET Message-ID: <861qt6oj42.fsf@mail.linkov.net> References: <40517.1661046885@alto> <86a67xk46m.fsf@mail.linkov.net> <87v8qk246x.fsf@web.de> <86ilmkixbw.fsf@mail.linkov.net> <877d2z2a4u.fsf@web.de> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39153"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) Cc: 57293@debbugs.gnu.org, Stefan Kangas , Mike Kupfer To: Michael Heerdegen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Aug 23 21:32:16 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oQZdH-0009xb-Vx for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 23 Aug 2022 21:32:16 +0200 Original-Received: from localhost ([::1]:46848 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oQZdF-0005GD-O8 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 23 Aug 2022 15:32:13 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34796) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQZd4-0005Fn-Fc for bug-gnu-emacs@gnu.org; Tue, 23 Aug 2022 15:32:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:55336) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oQZd4-00050G-3y for bug-gnu-emacs@gnu.org; Tue, 23 Aug 2022 15:32:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oQZd3-0006Hz-Sr for bug-gnu-emacs@gnu.org; Tue, 23 Aug 2022 15:32:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 23 Aug 2022 19:32:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 57293 X-GNU-PR-Package: emacs Original-Received: via spool by 57293-submit@debbugs.gnu.org id=B57293.166128310424151 (code B ref 57293); Tue, 23 Aug 2022 19:32:01 +0000 Original-Received: (at 57293) by debbugs.gnu.org; 23 Aug 2022 19:31:44 +0000 Original-Received: from localhost ([127.0.0.1]:45085 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oQZcm-0006HR-5g for submit@debbugs.gnu.org; Tue, 23 Aug 2022 15:31:44 -0400 Original-Received: from relay5-d.mail.gandi.net ([217.70.183.197]:59435) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oQZck-0006HD-1w for 57293@debbugs.gnu.org; Tue, 23 Aug 2022 15:31:43 -0400 Original-Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id A13E51C0002; Tue, 23 Aug 2022 19:31:32 +0000 (UTC) In-Reply-To: <877d2z2a4u.fsf@web.de> (Michael Heerdegen's message of "Tue, 23 Aug 2022 00:20:33 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:240570 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit >> 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": --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=dired-symlink-filename.patch 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) --=-=-=--