[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master a17bea6: * lisp/isearch.el: Improve 'isearch-allow-motion' featur
From: |
Juri Linkov |
Subject: |
master a17bea6: * lisp/isearch.el: Improve 'isearch-allow-motion' feature (bug#50466) |
Date: |
Mon, 13 Sep 2021 14:18:49 -0400 (EDT) |
branch: master
commit a17bea6d63c23a943a6bae28e699398c4002c2a8
Author: Juri Linkov <juri@linkov.net>
Commit: Juri Linkov <juri@linkov.net>
* 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'.
---
lisp/isearch.el | 29 ++++++++++++++++++++---------
1 file changed, 20 insertions(+), 9 deletions(-)
diff --git a/lisp/isearch.el b/lisp/isearch.el
index bebc80a..3f5e642 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -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))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master a17bea6: * lisp/isearch.el: Improve 'isearch-allow-motion' feature (bug#50466),
Juri Linkov <=