Commit f745cf8c authored by Juri Linkov's avatar Juri Linkov

* lisp/isearch.el (isearch-yank-on-move): New defcustom

with shift-move related options extracted from `search-exit-option'.
(isearch-pre-command-hook): Rename search-exit-option to
isearch-yank-on-move in shift-move related places.
(isearch-post-command-hook): Check for isearch-pre-move-point
instead of search-exit-option.  (Bug#15839)

* doc/emacs/search.texi (Not Exiting Isearch): Rename
search-exit-option to isearch-yank-on-move.

* lisp/menu-bar.el (menu-bar-i-search-menu): Add more isearch commands.
parent beafe2bf
Pipeline #199 failed with stage
in 23 minutes and 10 seconds
......@@ -548,12 +548,12 @@ an incremental search. This feature is disabled if
@item Motion Commands
@cindex motion commands, during incremental search
When @code{search-exit-option} is customized to @code{shift-move},
When @code{isearch-yank-on-move} is customized to @code{shift},
you can extend the search string by holding down the shift key while
typing cursor motion commands. It will yank text that ends at the new
position after moving point in the current buffer.
When @code{search-exit-option} is @code{move}, you can extend the
When @code{isearch-yank-on-move} is @code{t}, you can extend the
search string without using the shift key for cursor motion commands,
but it applies only for certain motion command that have the
@code{isearch-move} property on their symbols.
......
......@@ -691,11 +691,10 @@ highlight in one iteration while processing the full buffer.
'C-M-d'.
+++
*** 'search-exit-option' provides new options 'move' and 'shift-move'
*** New variable 'isearch-yank-on-move' provides options 't' and 'shift'
to extend the search string by yanking text that ends at the new
position after moving point in the current buffer. 'shift-move'
extends the search string by motion commands while holding down
the shift key.
position after moving point in the current buffer. 'shift' extends
the search string by motion commands while holding down the shift key.
*** 'isearch-allow-scroll' provides new option 'unlimited' to allow
scrolling any distance off screen.
......
......@@ -72,21 +72,11 @@
If t, random control and meta characters terminate the search
and are then executed normally.
If `edit', edit the search string instead of exiting.
If `move', extend the search string by motion commands
that have the `isearch-move' property on their symbols
equal to `enabled', or the shift-translated command is
not disabled by the value `disabled' of the same property.
If `shift-move', extend the search string by motion commands
while holding down the shift key.
Both `move' and `shift-move' extend the search string by yanking text
that ends at the new position after moving point in the current buffer.
If `append', the characters which you type that are not interpreted by
the incremental search are simply appended to the search string.
If nil, run the command without exiting Isearch."
:type '(choice (const :tag "Terminate incremental search" t)
(const :tag "Edit the search string" edit)
(const :tag "Extend the search string by motion commands" move)
(const :tag "Extend the search string by shifted motion keys" shift-move)
(const :tag "Append control characters to the search string" append)
(const :tag "Don't terminate incremental search" nil))
:version "27.1")
......@@ -2816,6 +2806,21 @@ the bottom."
(defvar isearch-pre-scroll-point nil)
(defvar isearch-pre-move-point nil)
(defcustom isearch-yank-on-move nil
"Motion keys yank text to the search string while you move the cursor.
If `shift', extend the search string by motion commands while holding down
the shift key. The search string is extended by yanking text that
ends at the new position after moving point in the current buffer.
If t, extend the search string without the shift key pressed
by motion commands that have the `isearch-move' property on their
symbols equal to `enabled', or for which the shift-translated command
is not disabled by the value `disabled' of property `isearch-move'."
:type '(choice (const :tag "Motion keys exit Isearch" nil)
(const :tag "Motion keys extend the search string" t)
(const :tag "Shifted motion keys extend the search string" shift))
:group 'isearch
:version "27.1")
(defun isearch-pre-command-hook ()
"Decide whether to exit Isearch mode before executing the command.
Don't exit Isearch if the key sequence that invoked this command
......@@ -2859,13 +2864,13 @@ See more for options in `search-exit-option'."
(read-event)
(setq this-command 'isearch-edit-string))
;; Don't terminate the search for motion commands.
((or (and (eq search-exit-option 'move)
((or (and (eq isearch-yank-on-move t)
(symbolp this-command)
(or (eq (get this-command 'isearch-move) 'enabled)
(and (not (eq (get this-command 'isearch-move) 'disabled))
(stringp (nth 1 (interactive-form this-command)))
(string-match-p "^^" (nth 1 (interactive-form this-command))))))
(and (eq search-exit-option 'shift-move)
(and (eq isearch-yank-on-move 'shift)
this-command-keys-shift-translated))
(setq this-command-keys-shift-translated nil)
(setq isearch-pre-move-point (point)))
......@@ -2890,9 +2895,8 @@ See more for options in `search-exit-option'."
(when (eq isearch-allow-scroll 'unlimited)
(when isearch-lazy-highlight
(isearch-lazy-highlight-new-loop)))
(when (memq search-exit-option '(move shift-move))
(when (and isearch-pre-move-point
(not (eq isearch-pre-move-point (point))))
(when isearch-pre-move-point
(when (not (eq isearch-pre-move-point (point)))
(let ((string (buffer-substring-no-properties
(or isearch-other-end isearch-opoint) (point))))
(if isearch-regexp (setq string (regexp-quote string)))
......@@ -3188,12 +3192,12 @@ the word mode."
(defun isearch-message-suffix (&optional c-q-hack)
(propertize (concat (if c-q-hack "^Q" "")
(if isearch-error
(concat " [" isearch-error "]")
"")
(isearch-lazy-count-format 'suffix)
(or isearch-message-suffix-add ""))
'face 'minibuffer-prompt))
(isearch-lazy-count-format 'suffix)
(if isearch-error
(concat " [" isearch-error "]")
"")
(or isearch-message-suffix-add ""))
'face 'minibuffer-prompt))
(defun isearch-lazy-count-format (&optional suffix-p)
"Format the current match number and the total number of matches.
......
......@@ -277,6 +277,15 @@
;; The Edit->Search->Incremental Search menu
(defvar menu-bar-i-search-menu
(let ((menu (make-sparse-keymap "Incremental Search")))
(bindings--define-key menu [isearch-forward-symbol-at-point]
'(menu-item "Forward Symbol at Point..." isearch-forward-symbol-at-point
:help "Search forward for a symbol found at point"))
(bindings--define-key menu [isearch-forward-symbol]
'(menu-item "Forward Symbol..." isearch-forward-symbol
:help "Search forward for a symbol as you type it"))
(bindings--define-key menu [isearch-forward-word]
'(menu-item "Forward Word..." isearch-forward-word
:help "Search forward for a word as you type it"))
(bindings--define-key menu [isearch-backward-regexp]
'(menu-item "Backward Regexp..." isearch-backward-regexp
:help "Search backwards for a regular expression as you type it"))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment