GNU bug report logs -
#24305
25.1; dired can't replace '\n' in file content (dired-do-find-regexp-and-replace)
Previous Next
Reported by: Max Canal <mc.maxcanal <at> gmail.com>
Date: Wed, 24 Aug 2016 22:58:02 UTC
Severity: normal
Merged with 23426
Found in versions 25.0.93, 25.1
Done: Dmitry Gutov <dgutov <at> yandex.ru>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
Thank you for the report.
As reported in NEWS file, since Emas 25.1 the key 'Q' is bound
to a new command 'dired-do-find-regexp-and-replace'. The key 'A'
is also bound to a new command: dired-do-find-regexp.
The old commands use Emacs regexp engine, while the new commands
use grep: this may cause that regexps which previously
matched results, with the new commands don't match anymore.
That seems the case in your example: the old command matches '\n', but
the new one cannot:
;; old command
(let ((file "/tmp/bug24305/file"))
(with-temp-file file
(insert "\n"))
(dired-other-window (file-name-directory file))
(dired-goto-file file)
(when (null (dired-do-search "\n"))
(message "Found new line!")))
;; new command
(let ((file "/tmp/bug24305/file"))
(with-temp-file file
(insert "\n"))
(dired-other-window (file-name-directory file))
(dired-goto-file file)
(save-excursion (dired-mark 1))
(dired-do-find-regexp "\n"))
In your example, 'dired-do-find-regexp-and-replace' internally builds
the following `find' command (using `xref--rgrep-command'):
find /tmp/bug24305 -type f \( -iname file \) -exec grep --color -i -nH -e
'\n' {} +
As you have noticed, this command fails.
Following commands would work:
find /tmp/bug24305 -type f \( -iname file \) -exec grep --color -i -nH -e
'^$' {} +
find /tmp/bug24305 -type f \( -iname file \) -exec grep --color -i -nH
-e '
' {} +
Maybe `xref--rgrep-command' might be updated to account for this?
In the meantime, as a temporary solution, you might wish to restore the
previous bindings. For instance, adding following in your .emacs file:
(require 'dired-aux)
(define-key dired-mode-map "A" 'dired-do-search)
(define-key dired-mode-map "Q" 'dired-do-query-replace-regexp)
Tino
This bug report was last modified 8 years and 322 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.