* lisp/isearch.el: Improve 'isearch-allow-motion' feature (bug#50466)
* lisp/isearch.el: Add recenter to 'isearch-motion' property of 'end-of-buffer' to maximize the number of search hits on the screen. In 'isearch-motion' property of 'scroll-up-command' use 'recenter 0' for the first line of the screen. (isearch-beginning-of-buffer) (isearch-end-of-buffer): Sync logic from 'isearch-allow-motion' part of isearch-pre-command-hook. Direct users to isearch-allow-motion in the docstrings. (isearch-pre-command-hook): Don't override shifted 'isearch-yank-on-move' in 'isearch-allow-motion'.
This commit is contained in:
parent
4cf6d03d04
commit
a17bea6d63
1 changed files with 20 additions and 9 deletions
|
@ -2003,7 +2003,8 @@ Move point to the beginning of the buffer and search forwards from the top.
|
|||
\\<isearch-mode-map>
|
||||
With a numeric argument, go to the ARGth absolute occurrence counting from
|
||||
the beginning of the buffer. To find the next relative occurrence forwards,
|
||||
type \\[isearch-repeat-forward] with a numeric argument."
|
||||
type \\[isearch-repeat-forward] with a numeric argument.
|
||||
You might want to use `isearch-allow-motion' instead of this command."
|
||||
(interactive "p")
|
||||
(if (and arg (< arg 0))
|
||||
(isearch-end-of-buffer (abs arg))
|
||||
|
@ -2011,8 +2012,11 @@ type \\[isearch-repeat-forward] with a numeric argument."
|
|||
;; don't forward char in isearch-repeat
|
||||
(setq isearch-just-started t)
|
||||
(goto-char (point-min))
|
||||
(let ((isearch-repeat-on-direction-change nil))
|
||||
(isearch-repeat 'forward arg))))
|
||||
(let ((current-direction (if isearch-forward 'forward 'backward))
|
||||
(isearch-repeat-on-direction-change nil))
|
||||
(isearch-repeat 'forward arg)
|
||||
(unless (eq current-direction (if isearch-forward 'forward 'backward))
|
||||
(isearch-repeat current-direction)))))
|
||||
|
||||
(defun isearch-end-of-buffer (&optional arg)
|
||||
"Go to the last occurrence of the current search string.
|
||||
|
@ -2020,14 +2024,18 @@ Move point to the end of the buffer and search backwards from the bottom.
|
|||
\\<isearch-mode-map>
|
||||
With a numeric argument, go to the ARGth absolute occurrence counting from
|
||||
the end of the buffer. To find the next relative occurrence backwards,
|
||||
type \\[isearch-repeat-backward] with a numeric argument."
|
||||
type \\[isearch-repeat-backward] with a numeric argument.
|
||||
You might want to use `isearch-allow-motion' instead of this command."
|
||||
(interactive "p")
|
||||
(if (and arg (< arg 0))
|
||||
(isearch-beginning-of-buffer (abs arg))
|
||||
(setq isearch-just-started t)
|
||||
(goto-char (point-max))
|
||||
(let ((isearch-repeat-on-direction-change nil))
|
||||
(isearch-repeat 'backward arg))))
|
||||
(let ((current-direction (if isearch-forward 'forward 'backward))
|
||||
(isearch-repeat-on-direction-change nil))
|
||||
(isearch-repeat 'backward arg)
|
||||
(unless (eq current-direction (if isearch-forward 'forward 'backward))
|
||||
(isearch-repeat current-direction)))))
|
||||
|
||||
|
||||
;;; Toggles for `isearch-regexp-function' and `search-default-mode'.
|
||||
|
@ -2939,9 +2947,9 @@ See also the related option `isearch-allow-motion'."
|
|||
(put 'beginning-of-buffer 'isearch-motion
|
||||
'((lambda () (goto-char (point-min))) . forward))
|
||||
(put 'end-of-buffer 'isearch-motion
|
||||
'((lambda () (goto-char (point-max))) . backward))
|
||||
'((lambda () (goto-char (point-max)) (recenter -1 t)) . backward))
|
||||
(put 'scroll-up-command 'isearch-motion
|
||||
'((lambda () (goto-char (window-end)) (recenter 1 t)) . forward))
|
||||
'((lambda () (goto-char (window-end)) (recenter 0 t)) . forward))
|
||||
(put 'scroll-down-command 'isearch-motion
|
||||
'((lambda () (goto-char (window-start)) (recenter -1 t)) . backward))
|
||||
|
||||
|
@ -3076,7 +3084,10 @@ See more for options in `search-exit-option'."
|
|||
;; Handle motion command functions.
|
||||
((and isearch-allow-motion
|
||||
(symbolp this-command)
|
||||
(get this-command 'isearch-motion))
|
||||
(get this-command 'isearch-motion)
|
||||
;; Don't override `isearch-yank-on-move' used below.
|
||||
(not (and (eq isearch-yank-on-move 'shift)
|
||||
this-command-keys-shift-translated)))
|
||||
(let* ((property (get this-command 'isearch-motion))
|
||||
(function (car property))
|
||||
(current-direction (if isearch-forward 'forward 'backward))
|
||||
|
|
Loading…
Add table
Reference in a new issue