diff options
author | Juri Linkov <juri@linkov.net> | 2018-12-04 02:24:29 +0200 |
---|---|---|
committer | Juri Linkov <juri@linkov.net> | 2018-12-04 02:24:29 +0200 |
commit | beafe2bf50992b60cb4e8c9628a7000317279c8c (patch) | |
tree | ee3c7d3cfb1088981d93a6d57937b9d90a2bfe17 /lisp | |
parent | df5614297b6d4ca8a3c9cd18fea5088401b25146 (diff) | |
download | emacs-beafe2bf50992b60cb4e8c9628a7000317279c8c.tar.gz emacs-beafe2bf50992b60cb4e8c9628a7000317279c8c.tar.bz2 emacs-beafe2bf50992b60cb4e8c9628a7000317279c8c.zip |
* lisp/isearch.el (isearch-allow-scroll): New option `unlimited'.
(isearch-pre-command-hook): Call isearch-pre-scroll-point unless
isearch-allow-scroll is 'unlimited'.
(isearch-post-command-hook): Use `when' instead of `cond'.
Call isearch-lazy-highlight-new-loop when isearch-allow-scroll is
'unlimited'. (Bug#15839)
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/isearch.el | 61 |
1 files changed, 34 insertions, 27 deletions
diff --git a/lisp/isearch.el b/lisp/isearch.el index eb0b25f9b17..cc199b16d81 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el @@ -2746,9 +2746,13 @@ to the barrier." (defcustom isearch-allow-scroll nil "Whether scrolling is allowed during incremental search. If non-nil, scrolling commands can be used in Isearch mode. -However, the current match will never scroll offscreen. -If nil, scrolling commands will first cancel Isearch mode." - :type 'boolean +However, you cannot scroll far enough that the current match is +no longer visible (is off screen). But if the value is `unlimited' +that limitation is removed and you can scroll any distance off screen. +If nil, scrolling commands exit Isearch mode." + :type '(choice (const :tag "Scrolling exits Isearch" nil) + (const :tag "Scrolling with current match on screen" t) + (const :tag "Scrolling with current match off screen" unlimited)) :group 'isearch) (defcustom isearch-allow-prefix t @@ -2846,7 +2850,8 @@ See more for options in `search-exit-option'." (or (eq (get this-command 'isearch-scroll) t) (eq (get this-command 'scroll-command) t)))) (when isearch-allow-scroll - (setq isearch-pre-scroll-point (point)))) + (unless (eq isearch-allow-scroll 'unlimited) + (setq isearch-pre-scroll-point (point))))) ;; A mouse click on the isearch message starts editing the search string. ((and (eq (car-safe main-event) 'down-mouse-1) (window-minibuffer-p (posn-window (event-start main-event)))) @@ -2875,29 +2880,31 @@ See more for options in `search-exit-option'." (isearch-clean-overlays))))) (defun isearch-post-command-hook () - (cond - (isearch-pre-scroll-point - (let ((ab-bel (isearch-string-out-of-window isearch-pre-scroll-point))) - (if ab-bel - (isearch-back-into-window (eq ab-bel 'above) isearch-pre-scroll-point) - (goto-char isearch-pre-scroll-point))) - (setq isearch-pre-scroll-point nil) - (isearch-update)) - ((memq search-exit-option '(move shift-move)) - (when (and isearch-pre-move-point - (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))) - (setq isearch-string string) - (setq isearch-message (mapconcat 'isearch-text-char-description - string "")) - (setq isearch-yank-flag t) - (setq isearch-forward (<= (or isearch-other-end isearch-opoint) (point))) - (when isearch-forward - (goto-char isearch-pre-move-point)) - (isearch-search-and-update))) - (setq isearch-pre-move-point nil))) + (when isearch-pre-scroll-point + (let ((ab-bel (isearch-string-out-of-window isearch-pre-scroll-point))) + (if ab-bel + (isearch-back-into-window (eq ab-bel 'above) isearch-pre-scroll-point) + (goto-char isearch-pre-scroll-point))) + (setq isearch-pre-scroll-point nil) + (isearch-update)) + (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)))) + (let ((string (buffer-substring-no-properties + (or isearch-other-end isearch-opoint) (point)))) + (if isearch-regexp (setq string (regexp-quote string))) + (setq isearch-string string) + (setq isearch-message (mapconcat 'isearch-text-char-description + string "")) + (setq isearch-yank-flag t) + (setq isearch-forward (<= (or isearch-other-end isearch-opoint) (point))) + (when isearch-forward + (goto-char isearch-pre-move-point)) + (isearch-search-and-update))) + (setq isearch-pre-move-point nil)) (force-mode-line-update)) (defun isearch-quote-char (&optional count) |