]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/isearch.el (isearch-allow-scroll): New option `unlimited'.
authorJuri Linkov <juri@linkov.net>
Tue, 4 Dec 2018 00:24:29 +0000 (02:24 +0200)
committerJuri Linkov <juri@linkov.net>
Tue, 4 Dec 2018 00:24:29 +0000 (02:24 +0200)
(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)

etc/NEWS
lisp/isearch.el

index 6297d0787982595fdbee7876b74cc8b747fd839d..042a4b59d35c49c07548879e1e14a59eec046c36 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -697,6 +697,9 @@ position after moving point in the current buffer.  'shift-move'
 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.
+
 ---
 *** Isearch now remembers the regexp-based search mode for words/symbols
 and case-sensitivity together with search strings in the search ring.
index eb0b25f9b1713d01bfd1081e38eb2fa3ab3dc3ae..cc199b16d81365a7b25d320cd623a591a9e5da07 100644 (file)
@@ -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)