all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Tino Calancha <tino.calancha@gmail.com>
To: 24305@debbugs.gnu.org
Cc: mc.maxcanal@gmail.com, dgutov@yandex.ru, tino.calancha@gmail.com
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)	[thread overview]
Message-ID: <alpine.DEB.2.20.1608251432300.5579@calancha-pc> (raw)
In-Reply-To: <877fb53j8i.fsf@gmail.com>


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	other threads:[~2016-08-25  5:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-24 22:17 bug#24305: 25.1; dired can't replace '\n' in file content (dired-do-find-regexp-and-replace) Max Canal
2016-08-25  5:35 ` Tino Calancha [this message]
2016-08-25 14:33   ` Eli Zaretskii

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

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

  git send-email \
    --in-reply-to=alpine.DEB.2.20.1608251432300.5579@calancha-pc \
    --to=tino.calancha@gmail.com \
    --cc=24305@debbugs.gnu.org \
    --cc=dgutov@yandex.ru \
    --cc=mc.maxcanal@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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.