Subject: bug#15839: 24.3.50; `isearch-allow-scroll': be able to scroll point off screen temporarily

From: Juri Linkov <[email-masked]>
Date: Wed, 28 Nov 2018 02:35:53 +0200

> I don't want to customize one variable to be able to
> scroll farther, and another variable to have what's
> shown by that scrolling have lazy-highlighting
> (especially if the latter requires lazy-highlighting
> the entire buffer, rather than just what I see when
> scrolling).

Fine.  If you are lazy to customize two variables,
after you customize one variable we could automatically
change the value of the second variable.

> I want to be able to use `isearch-allow-scroll' to
> let me scroll as far as I want, and see search hits
> lazy-highlighted in what parts of the buffer I
> scroll to.

Fine, we could allow the same feature to be enabled
by two different variables.

diff --git a/lisp/isearch.el b/lisp/isearch.el
index eb0b25f9b1..ac809e4980 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -2747,8 +2747,15 @@ isearch-allow-scroll
   "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 `unlimited', the current match can scroll offscreen.
+This has the same effect as the value `nil' of `search-exit-option'.
 If nil, scrolling commands will first cancel Isearch mode."
-  :type 'boolean
+  :type '(choice boolean
+                 (const :tag "Can scroll offscreen" unlimited))
+  :set (lambda (sym val)
+	 (set sym val)
+         (when (eq val 'unlimited)
+           (setq lazy-highlight-buffer t)))
   :group 'isearch)
 
 (defcustom isearch-allow-prefix t
@@ -2841,11 +2848,11 @@ isearch-pre-command-hook
      ((or (and isearch-allow-prefix
                (memq this-command '(universal-argument universal-argument-more
 				    digit-argument negative-argument)))
-	  (and isearch-allow-scroll
+	  (and isearch-allow-scroll (not (eq isearch-allow-scroll 'unlimited))
 	       (symbolp this-command)
 	       (or (eq (get this-command 'isearch-scroll) t)
 		   (eq (get this-command 'scroll-command) t))))
-      (when isearch-allow-scroll
+      (when (and isearch-allow-scroll (not (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)
@@ -2853,6 +2860,7 @@ isearch-pre-command-hook
       ;; Swallow the up-event.
       (read-event)
       (setq this-command 'isearch-edit-string))
+     ((eq isearch-allow-scroll 'unlimited))
      ;; Don't terminate the search for motion commands.
      ((or (and (eq search-exit-option 'move)
                (symbolp this-command)