aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/replace.el
diff options
context:
space:
mode:
authorJuri Linkov2025-11-20 20:39:29 +0200
committerJuri Linkov2025-11-20 20:39:29 +0200
commitf4d353f9c9e7dea67f04020a9218c7dfb244d44b (patch)
treef332ad4a5b35868dcfadea130bf9f74393174aa9 /lisp/replace.el
parentae5c361d3204146e455331e3e7a42cc9f6252f10 (diff)
downloademacs-f4d353f9c9e7dea67f04020a9218c7dfb244d44b.tar.gz
emacs-f4d353f9c9e7dea67f04020a9218c7dfb244d44b.zip
Show the diff buffer with replacements by typing 'd' in 'query-replace'
* doc/emacs/search.texi (Query Replace): Mention new key 'd'. * lisp/replace.el (query-replace-help): Mention the key 'd'. (query-replace-map): Bind the key 'd' to 'diff'. (perform-replace): When 'def' is equal to 'diff', call 'multi-file-replace-as-diff' to show the diff buffer with replacements (bug#79761).
Diffstat (limited to 'lisp/replace.el')
-rw-r--r--lisp/replace.el14
1 files changed, 13 insertions, 1 deletions
diff --git a/lisp/replace.el b/lisp/replace.el
index 6635cc6afe4..b0689b93e06 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -2459,6 +2459,7 @@ To be added to `context-menu-functions'."
2459\\`U' to undo all replacements, 2459\\`U' to undo all replacements,
2460\\`e' to edit the replacement string. 2460\\`e' to edit the replacement string.
2461\\`E' to edit the replacement string with exact case. 2461\\`E' to edit the replacement string with exact case.
2462\\`d' to display the diff buffer with all replacements.
2462\\`C-l' to clear the screen, redisplay, and offer same replacement again, 2463\\`C-l' to clear the screen, redisplay, and offer same replacement again,
2463\\`Y' to replace all remaining matches in all remaining buffers (in 2464\\`Y' to replace all remaining matches in all remaining buffers (in
2464multi-buffer replacements) with no more questions, 2465multi-buffer replacements) with no more questions,
@@ -2492,6 +2493,7 @@ re-executed as a normal key sequence."
2492 (define-key map "^" 'backup) 2493 (define-key map "^" 'backup)
2493 (define-key map "u" 'undo) 2494 (define-key map "u" 'undo)
2494 (define-key map "U" 'undo-all) 2495 (define-key map "U" 'undo-all)
2496 (define-key map "d" 'diff)
2495 (define-key map "\C-h" 'help) 2497 (define-key map "\C-h" 'help)
2496 (define-key map [f1] 'help) 2498 (define-key map [f1] 'help)
2497 (define-key map [help] 'help) 2499 (define-key map [help] 'help)
@@ -2518,7 +2520,7 @@ The valid answers include `act', `skip', `act-and-show',
2518`scroll-down', `scroll-other-window', `scroll-other-window-down', 2520`scroll-down', `scroll-other-window', `scroll-other-window-down',
2519`edit', `edit-replacement', `edit-replacement-exact-case', 2521`edit', `edit-replacement', `edit-replacement-exact-case',
2520`delete-and-edit', `automatic', `backup', `undo', `undo-all', 2522`delete-and-edit', `automatic', `backup', `undo', `undo-all',
2521`quit', and `help'. 2523`diff', `quit', and `help'.
2522 2524
2523This keymap is used by `y-or-n-p' as well as `query-replace'.") 2525This keymap is used by `y-or-n-p' as well as `query-replace'.")
2524 2526
@@ -3334,6 +3336,16 @@ characters."
3334 (replace-dehighlight) 3336 (replace-dehighlight)
3335 (save-excursion (recursive-edit)) 3337 (save-excursion (recursive-edit))
3336 (setq replaced t)) 3338 (setq replaced t))
3339
3340 ((eq def 'diff)
3341 (let ((display-buffer-overriding-action
3342 '(nil (inhibit-same-window . t))))
3343 (save-selected-window
3344 (multi-file-replace-as-diff
3345 (list (or buffer-file-name (current-buffer)))
3346 from-string (or replacements next-replacement)
3347 regexp-flag delimited-flag))))
3348
3337 ((commandp def t) 3349 ((commandp def t)
3338 (call-interactively def)) 3350 (call-interactively def))
3339 ;; Note: we do not need to treat `exit-prefix' 3351 ;; Note: we do not need to treat `exit-prefix'