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

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

bug#31796: 27.1; dired-do-find-regexp-and-replace fails to find multilin


From: Juri Linkov
Subject: bug#31796: 27.1; dired-do-find-regexp-and-replace fails to find multiline regexps
Date: Wed, 25 Nov 2020 09:31:23 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu)

>> >  Multiple > Search >
>> >    Query Replace Using TAGS Table...   M-q
>> >    Query Replace Using `find'...       Q
>>
>> dired-do-find-regexp-and-replace could be left bound to Q, but
>> dired-do-query-replace-regexp could be bound to M-% in Dired.
>
> For the latter, I use `M-q' (not `M-%').
> I suggest that vanilla Emacs do the same.
>
> These two commands have quite similar purposes.
> I suggest that they have similar keys.
>
> Also, `M-%' has its normal meaning when Dired
> has been toggled to writable (WDired).  That
> key should be kept for its normal purpose, IMO.

'M-q' has its normal meaning of filling the paragraph,
so it would be confusing to use other meaning in Dired.

While finding a good short key would be nice, here is a patch
that for consistency with 'M-s a M-C-s' also adds 'M-s a M-C-%':

diff --git a/lisp/vc/vc-dir.el b/lisp/vc/vc-dir.el
index cdf8ab984e..bed779104c 100644
--- a/lisp/vc/vc-dir.el
+++ b/lisp/vc/vc-dir.el
@@ -308,6 +308,7 @@ vc-dir-mode-map
     (define-key map "Q" 'vc-dir-query-replace-regexp)
     (define-key map (kbd "M-s a C-s")   'vc-dir-isearch)
     (define-key map (kbd "M-s a M-C-s") 'vc-dir-isearch-regexp)
+    (define-key map (kbd "M-s a M-C-%") 'vc-dir-query-replace-regexp)
     (define-key map "G" 'vc-dir-ignore)
 
     (let ((branch-map (make-sparse-keymap)))
diff --git a/lisp/dired.el b/lisp/dired.el
index 08b19a0225..6cbcc17852 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -1932,6 +1932,7 @@ dired-mode-map
     ;; isearch
     (define-key map (kbd "M-s a C-s")   'dired-do-isearch)
     (define-key map (kbd "M-s a M-C-s") 'dired-do-isearch-regexp)
+    (define-key map (kbd "M-s a M-C-%") 'dired-do-query-replace-regexp)
     (define-key map (kbd "M-s f C-s")   'dired-isearch-filenames)
     (define-key map (kbd "M-s f M-C-s") 'dired-isearch-filenames-regexp)
     ;; misc
@@ -2214,9 +2215,12 @@ dired-mode-map
     (define-key map [menu-bar operate dashes-3]
       '("--"))
 
-    (define-key map [menu-bar operate query-replace]
-      '(menu-item "Query Replace in Files..." dired-do-find-regexp-and-replace
-                 :help "Replace regexp matches in marked files"))
+    (define-key map [menu-bar operate find-regexp-and-replace]
+      '(menu-item "Replace Regexp in Files..." dired-do-find-regexp-and-replace
+                 :help "Replace regexp matches in marked files"))
+    (define-key map [menu-bar operate query-replace-regexp]
+      '(menu-item "Query Replace in Files..." dired-do-query-replace-regexp
+                 :help "Replace regexp matches in marked files"))
     (define-key map [menu-bar operate search]
       '(menu-item "Search Files..." dired-do-find-regexp
                  :help "Search marked files for matches of regexp"))
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index a395453491..7b8dcc2096 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -598,7 +598,7 @@ project-prefix-map
     (define-key map "p" 'project-switch-project)
     (define-key map "g" 'project-find-regexp)
     (define-key map "G" 'project-or-external-find-regexp)
-    (define-key map "r" 'project-query-replace-regexp)
+    (define-key map [?\C-\M-%] 'project-query-replace-regexp)
     map)
   "Keymap for project commands.")
 

reply via email to

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