diff options
| -rw-r--r-- | doc/emacs/search.texi | 14 | ||||
| -rw-r--r-- | etc/NEWS | 8 | ||||
| -rw-r--r-- | lisp/isearch.el | 52 |
3 files changed, 67 insertions, 7 deletions
diff --git a/doc/emacs/search.texi b/doc/emacs/search.texi index 887fd982d01..0de3aee1b21 100644 --- a/doc/emacs/search.texi +++ b/doc/emacs/search.texi | |||
| @@ -437,7 +437,7 @@ of the keymap @code{isearch-mode-map} (@pxref{Keymaps}). | |||
| 437 | 437 | ||
| 438 | This subsection describes how to control whether typing a command not | 438 | This subsection describes how to control whether typing a command not |
| 439 | specifically meaningful in searches exits the search before executing | 439 | specifically meaningful in searches exits the search before executing |
| 440 | the command. It also describes two categories of commands which you | 440 | the command. It also describes three categories of commands which you |
| 441 | can type without exiting the current incremental search, even though | 441 | can type without exiting the current incremental search, even though |
| 442 | they are not themselves part of incremental search. | 442 | they are not themselves part of incremental search. |
| 443 | 443 | ||
| @@ -507,6 +507,18 @@ change point, the buffer contents, the match data, the current buffer, | |||
| 507 | or the selected window and frame. The command must not itself attempt | 507 | or the selected window and frame. The command must not itself attempt |
| 508 | an incremental search. This feature is disabled if | 508 | an incremental search. This feature is disabled if |
| 509 | @code{isearch-allow-scroll} is @code{nil} (which it is by default). | 509 | @code{isearch-allow-scroll} is @code{nil} (which it is by default). |
| 510 | |||
| 511 | @item Motion Commands | ||
| 512 | @cindex motion commands, during incremental search | ||
| 513 | When @code{search-exit-option} is customized to @code{shift-move}, | ||
| 514 | you can extend the search string by holding down the shift key while | ||
| 515 | typing cursor motion commands. It will yank text that ends at the new | ||
| 516 | position after moving point in the current buffer. | ||
| 517 | |||
| 518 | When @code{search-exit-option} is @code{move}, you can extend the | ||
| 519 | search string without using the shift key for cursor motion commands, | ||
| 520 | but it applies only for certain motion command that have the | ||
| 521 | @code{isearch-move} property on their symbols. | ||
| 510 | @end table | 522 | @end table |
| 511 | 523 | ||
| 512 | @node Isearch Minibuffer | 524 | @node Isearch Minibuffer |
| @@ -180,6 +180,14 @@ created by 'edit-last-kbd-macro', and to save the macro by 'C-c C-c'. | |||
| 180 | --- | 180 | --- |
| 181 | *** New filter ibuffer-filter-by-process; bound to '/E'. | 181 | *** New filter ibuffer-filter-by-process; bound to '/E'. |
| 182 | 182 | ||
| 183 | ** Search and Replace | ||
| 184 | |||
| 185 | *** 'search-exit-option' provides new options 'move' and 'shift-move' | ||
| 186 | to extend the search string by yanking text that ends at the new | ||
| 187 | position after moving point in the current buffer. 'shift-move' | ||
| 188 | extends the search string by motion commands while holding down | ||
| 189 | the shift key. | ||
| 190 | |||
| 183 | ** Edebug | 191 | ** Edebug |
| 184 | 192 | ||
| 185 | +++ | 193 | +++ |
diff --git a/lisp/isearch.el b/lisp/isearch.el index a41adf0c2cd..96faa27c174 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el | |||
| @@ -67,8 +67,23 @@ | |||
| 67 | 67 | ||
| 68 | 68 | ||
| 69 | (defcustom search-exit-option t | 69 | (defcustom search-exit-option t |
| 70 | "Non-nil means random control characters terminate incremental search." | 70 | "Defines what control characters do in incremental search. |
| 71 | :type 'boolean) | 71 | If t, random control and meta characters terminate the search |
| 72 | and are then executed normally. | ||
| 73 | If `edit', edit the search string instead of exiting. | ||
| 74 | If `move', extend the search string by motion commands | ||
| 75 | that have the `isearch-move' property on their symbols. | ||
| 76 | If `shift-move', extend the search string by motion commands | ||
| 77 | while holding down the shift key. | ||
| 78 | Both `move' and `shift-move' extend the search string by yanking text | ||
| 79 | that ends at the new position after moving point in the current buffer. | ||
| 80 | If nil, run the command without exiting Isearch." | ||
| 81 | :type '(choice (const :tag "Terminate incremental search" t) | ||
| 82 | (const :tag "Edit the search string" edit) | ||
| 83 | (const :tag "Extend the search string by motion commands" move) | ||
| 84 | (const :tag "Extend the search string by shifted motion keys" shift-move) | ||
| 85 | (const :tag "Don't terminate incremental search" nil)) | ||
| 86 | :version "27.1") | ||
| 72 | 87 | ||
| 73 | (defcustom search-slow-window-lines 1 | 88 | (defcustom search-slow-window-lines 1 |
| 74 | "Number of lines in slow search display windows. | 89 | "Number of lines in slow search display windows. |
| @@ -2391,6 +2406,7 @@ the bottom." | |||
| 2391 | (goto-char isearch-point)) | 2406 | (goto-char isearch-point)) |
| 2392 | 2407 | ||
| 2393 | (defvar isearch-pre-scroll-point nil) | 2408 | (defvar isearch-pre-scroll-point nil) |
| 2409 | (defvar isearch-pre-move-point nil) | ||
| 2394 | 2410 | ||
| 2395 | (defun isearch-pre-command-hook () | 2411 | (defun isearch-pre-command-hook () |
| 2396 | "Decide whether to exit Isearch mode before executing the command. | 2412 | "Decide whether to exit Isearch mode before executing the command. |
| @@ -2398,8 +2414,9 @@ Don't exit Isearch if the key sequence that invoked this command | |||
| 2398 | is bound in `isearch-mode-map', or if the invoked command is | 2414 | is bound in `isearch-mode-map', or if the invoked command is |
| 2399 | a prefix argument command (when `isearch-allow-prefix' is non-nil), | 2415 | a prefix argument command (when `isearch-allow-prefix' is non-nil), |
| 2400 | or it is a scrolling command (when `isearch-allow-scroll' is non-nil). | 2416 | or it is a scrolling command (when `isearch-allow-scroll' is non-nil). |
| 2401 | Otherwise, exit Isearch (when `search-exit-option' is non-nil) | 2417 | Otherwise, exit Isearch (when `search-exit-option' is t) |
| 2402 | before the command is executed globally with terminated Isearch." | 2418 | before the command is executed globally with terminated Isearch. |
| 2419 | See more for options in `search-exit-option'." | ||
| 2403 | (let* ((key (this-single-command-keys)) | 2420 | (let* ((key (this-single-command-keys)) |
| 2404 | (main-event (aref key 0))) | 2421 | (main-event (aref key 0))) |
| 2405 | (cond | 2422 | (cond |
| @@ -2427,6 +2444,14 @@ before the command is executed globally with terminated Isearch." | |||
| 2427 | ;; Swallow the up-event. | 2444 | ;; Swallow the up-event. |
| 2428 | (read-event) | 2445 | (read-event) |
| 2429 | (setq this-command 'isearch-edit-string)) | 2446 | (setq this-command 'isearch-edit-string)) |
| 2447 | ;; Don't terminate the search for motion commands. | ||
| 2448 | ((or (and (eq search-exit-option 'move) | ||
| 2449 | (symbolp this-command) | ||
| 2450 | (eq (get this-command 'isearch-move) t)) | ||
| 2451 | (and (eq search-exit-option 'shift-move) | ||
| 2452 | this-command-keys-shift-translated)) | ||
| 2453 | (setq this-command-keys-shift-translated nil) | ||
| 2454 | (setq isearch-pre-move-point (point))) | ||
| 2430 | ;; Other characters terminate the search and are then executed normally. | 2455 | ;; Other characters terminate the search and are then executed normally. |
| 2431 | (search-exit-option | 2456 | (search-exit-option |
| 2432 | (isearch-done) | 2457 | (isearch-done) |
| @@ -2436,13 +2461,28 @@ before the command is executed globally with terminated Isearch." | |||
| 2436 | (isearch-process-search-string key key))))) | 2461 | (isearch-process-search-string key key))))) |
| 2437 | 2462 | ||
| 2438 | (defun isearch-post-command-hook () | 2463 | (defun isearch-post-command-hook () |
| 2439 | (when isearch-pre-scroll-point | 2464 | (cond |
| 2465 | (isearch-pre-scroll-point | ||
| 2440 | (let ((ab-bel (isearch-string-out-of-window isearch-pre-scroll-point))) | 2466 | (let ((ab-bel (isearch-string-out-of-window isearch-pre-scroll-point))) |
| 2441 | (if ab-bel | 2467 | (if ab-bel |
| 2442 | (isearch-back-into-window (eq ab-bel 'above) isearch-pre-scroll-point) | 2468 | (isearch-back-into-window (eq ab-bel 'above) isearch-pre-scroll-point) |
| 2443 | (goto-char isearch-pre-scroll-point))) | 2469 | (goto-char isearch-pre-scroll-point))) |
| 2444 | (setq isearch-pre-scroll-point nil) | 2470 | (setq isearch-pre-scroll-point nil) |
| 2445 | (isearch-update))) | 2471 | (isearch-update)) |
| 2472 | ((memq search-exit-option '(move shift-move)) | ||
| 2473 | (when (and isearch-pre-move-point | ||
| 2474 | (not (eq isearch-pre-move-point (point)))) | ||
| 2475 | (let ((string (buffer-substring-no-properties | ||
| 2476 | (or isearch-other-end isearch-opoint) (point)))) | ||
| 2477 | (if isearch-regexp (setq string (regexp-quote string))) | ||
| 2478 | (setq isearch-string string) | ||
| 2479 | (setq isearch-message (mapconcat 'isearch-text-char-description | ||
| 2480 | string "")) | ||
| 2481 | (setq isearch-yank-flag t) | ||
| 2482 | (setq isearch-forward (<= (or isearch-other-end isearch-opoint) (point))) | ||
| 2483 | (goto-char isearch-pre-move-point) | ||
| 2484 | (isearch-search-and-update))) | ||
| 2485 | (setq isearch-pre-move-point nil)))) | ||
| 2446 | 2486 | ||
| 2447 | (defun isearch-quote-char (&optional count) | 2487 | (defun isearch-quote-char (&optional count) |
| 2448 | "Quote special characters for incremental search. | 2488 | "Quote special characters for incremental search. |