bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#24305: 25.1; dired can't replace '\n' in file content (dired-do-find


From: Tino Calancha
Subject: bug#24305: 25.1; dired can't replace '\n' in file content (dired-do-find-regexp-and-replace)
Date: Thu, 25 Aug 2016 14:35:52 +0900 (JST)
User-agent: Alpine 2.20 (DEB 67 2015-01-07)


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






reply via email to

[Prev in Thread] Current Thread [Next in Thread]