diff options
| -rw-r--r-- | doc/emacs/search.texi | 8 | ||||
| -rw-r--r-- | etc/NEWS | 4 | ||||
| -rw-r--r-- | lisp/replace.el | 28 |
3 files changed, 31 insertions, 9 deletions
diff --git a/doc/emacs/search.texi b/doc/emacs/search.texi index b123ef83a16..f4e12d29e99 100644 --- a/doc/emacs/search.texi +++ b/doc/emacs/search.texi | |||
| @@ -1827,12 +1827,18 @@ occurrence of @var{string}. When done, exit the recursive editing level | |||
| 1827 | with @kbd{C-M-c} to proceed to the next occurrence. | 1827 | with @kbd{C-M-c} to proceed to the next occurrence. |
| 1828 | 1828 | ||
| 1829 | @item e | 1829 | @item e |
| 1830 | @itemx E | ||
| 1831 | to edit the replacement string in the minibuffer. When you exit the | 1830 | to edit the replacement string in the minibuffer. When you exit the |
| 1832 | minibuffer by typing @key{RET}, the minibuffer contents replace the | 1831 | minibuffer by typing @key{RET}, the minibuffer contents replace the |
| 1833 | current occurrence of the pattern. They also become the new | 1832 | current occurrence of the pattern. They also become the new |
| 1834 | replacement string for any further occurrences. | 1833 | replacement string for any further occurrences. |
| 1835 | 1834 | ||
| 1835 | @item E | ||
| 1836 | is like @kbd{e}, but the next replacement will be done with exact | ||
| 1837 | case. I.e., if you have a @code{query-replace} from @samp{foo} to | ||
| 1838 | @samp{bar}, a text like @samp{Foo} will be normally be replaced with | ||
| 1839 | @samp{Bar}. Use this command to do the current replacement with exact | ||
| 1840 | case. | ||
| 1841 | |||
| 1836 | @item C-l | 1842 | @item C-l |
| 1837 | to redisplay the screen. Then you must type another character to | 1843 | to redisplay the screen. Then you must type another character to |
| 1838 | specify what to do with this occurrence. | 1844 | specify what to do with this occurrence. |
| @@ -151,6 +151,10 @@ of 'user-emacs-directory'. | |||
| 151 | 151 | ||
| 152 | * Incompatible changes in Emacs 29.1 | 152 | * Incompatible changes in Emacs 29.1 |
| 153 | 153 | ||
| 154 | +++ | ||
| 155 | ** 'E' in 'query-replace' now edits the replacement with exact case. | ||
| 156 | Previously, this command did the same as 'e'. | ||
| 157 | |||
| 154 | --- | 158 | --- |
| 155 | ** '/ a' in *Packages* now limits by package name(s) instead of regexp. | 159 | ** '/ a' in *Packages* now limits by package name(s) instead of regexp. |
| 156 | 160 | ||
diff --git a/lisp/replace.el b/lisp/replace.el index b84e6eaa655..c9d41d3fa39 100644 --- a/lisp/replace.el +++ b/lisp/replace.el | |||
| @@ -2506,7 +2506,8 @@ To be added to `context-menu-functions'." | |||
| 2506 | \\`^' to move point back to previous match, | 2506 | \\`^' to move point back to previous match, |
| 2507 | \\`u' to undo previous replacement, | 2507 | \\`u' to undo previous replacement, |
| 2508 | \\`U' to undo all replacements, | 2508 | \\`U' to undo all replacements, |
| 2509 | \\`E' to edit the replacement string. | 2509 | \\`e' to edit the replacement string. |
| 2510 | \\`E' to edit the replacement string with exact case. | ||
| 2510 | In multi-buffer replacements type \\`Y' to replace all remaining | 2511 | In multi-buffer replacements type \\`Y' to replace all remaining |
| 2511 | matches in all remaining buffers with no more questions, | 2512 | matches in all remaining buffers with no more questions, |
| 2512 | \\`N' to skip to the next buffer without replacing remaining matches | 2513 | \\`N' to skip to the next buffer without replacing remaining matches |
| @@ -2524,7 +2525,7 @@ in the current buffer." | |||
| 2524 | (define-key map "Y" 'act) | 2525 | (define-key map "Y" 'act) |
| 2525 | (define-key map "N" 'skip) | 2526 | (define-key map "N" 'skip) |
| 2526 | (define-key map "e" 'edit-replacement) | 2527 | (define-key map "e" 'edit-replacement) |
| 2527 | (define-key map "E" 'edit-replacement) | 2528 | (define-key map "E" 'edit-replacement-exact-case) |
| 2528 | (define-key map "," 'act-and-show) | 2529 | (define-key map "," 'act-and-show) |
| 2529 | (define-key map "q" 'exit) | 2530 | (define-key map "q" 'exit) |
| 2530 | (define-key map "\r" 'exit) | 2531 | (define-key map "\r" 'exit) |
| @@ -2561,8 +2562,9 @@ The \"bindings\" in this map are not commands; they are answers. | |||
| 2561 | The valid answers include `act', `skip', `act-and-show', | 2562 | The valid answers include `act', `skip', `act-and-show', |
| 2562 | `act-and-exit', `exit', `exit-prefix', `recenter', `scroll-up', | 2563 | `act-and-exit', `exit', `exit-prefix', `recenter', `scroll-up', |
| 2563 | `scroll-down', `scroll-other-window', `scroll-other-window-down', | 2564 | `scroll-down', `scroll-other-window', `scroll-other-window-down', |
| 2564 | `edit', `edit-replacement', `delete-and-edit', `automatic', | 2565 | `edit', `edit-replacement', `edit-replacement-exact-case', |
| 2565 | `backup', `undo', `undo-all', `quit', and `help'. | 2566 | `delete-and-edit', `automatic', `backup', `undo', `undo-all', |
| 2567 | `quit', and `help'. | ||
| 2566 | 2568 | ||
| 2567 | This keymap is used by `y-or-n-p' as well as `query-replace'.") | 2569 | This keymap is used by `y-or-n-p' as well as `query-replace'.") |
| 2568 | 2570 | ||
| @@ -3336,19 +3338,29 @@ characters." | |||
| 3336 | (setq match-again (and (looking-at search-string) | 3338 | (setq match-again (and (looking-at search-string) |
| 3337 | (match-data))))) | 3339 | (match-data))))) |
| 3338 | ;; Edit replacement. | 3340 | ;; Edit replacement. |
| 3339 | ((eq def 'edit-replacement) | 3341 | ((or (eq def 'edit-replacement) |
| 3342 | (eq def 'edit-replacement-exact-case)) | ||
| 3340 | (setq real-match-data (replace-match-data | 3343 | (setq real-match-data (replace-match-data |
| 3341 | nil real-match-data | 3344 | nil real-match-data |
| 3342 | real-match-data) | 3345 | real-match-data) |
| 3343 | next-replacement | 3346 | next-replacement |
| 3344 | (read-string "Edit replacement string: " | 3347 | (read-string |
| 3345 | next-replacement) | 3348 | (format "Edit replacement string%s: " |
| 3349 | (if (eq def | ||
| 3350 | 'edit-replacement-exact-case) | ||
| 3351 | " (exact case)" | ||
| 3352 | "")) | ||
| 3353 | next-replacement) | ||
| 3346 | noedit nil) | 3354 | noedit nil) |
| 3347 | (if replaced | 3355 | (if replaced |
| 3348 | (set-match-data real-match-data) | 3356 | (set-match-data real-match-data) |
| 3349 | (setq noedit | 3357 | (setq noedit |
| 3350 | (replace-match-maybe-edit | 3358 | (replace-match-maybe-edit |
| 3351 | next-replacement nocasify literal noedit | 3359 | next-replacement |
| 3360 | (if (eq def 'edit-replacement-exact-case) | ||
| 3361 | t | ||
| 3362 | nocasify) | ||
| 3363 | literal noedit | ||
| 3352 | real-match-data backward) | 3364 | real-match-data backward) |
| 3353 | replaced t) | 3365 | replaced t) |
| 3354 | (setq next-replacement-replaced next-replacement)) | 3366 | (setq next-replacement-replaced next-replacement)) |