aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2018-12-04 02:24:29 +0200
committerJuri Linkov2018-12-04 02:24:29 +0200
commitbeafe2bf50992b60cb4e8c9628a7000317279c8c (patch)
treeee3c7d3cfb1088981d93a6d57937b9d90a2bfe17
parentdf5614297b6d4ca8a3c9cd18fea5088401b25146 (diff)
downloademacs-beafe2bf50992b60cb4e8c9628a7000317279c8c.tar.gz
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)
-rw-r--r--etc/NEWS3
-rw-r--r--lisp/isearch.el61
2 files changed, 37 insertions, 27 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 6297d078798..042a4b59d35 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -697,6 +697,9 @@ position after moving point in the current buffer. 'shift-move'
697extends the search string by motion commands while holding down 697extends the search string by motion commands while holding down
698the shift key. 698the shift key.
699 699
700*** 'isearch-allow-scroll' provides new option 'unlimited' to allow
701scrolling any distance off screen.
702
700--- 703---
701*** Isearch now remembers the regexp-based search mode for words/symbols 704*** Isearch now remembers the regexp-based search mode for words/symbols
702and case-sensitivity together with search strings in the search ring. 705and case-sensitivity together with search strings in the search ring.
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."
2746(defcustom isearch-allow-scroll nil 2746(defcustom isearch-allow-scroll nil
2747 "Whether scrolling is allowed during incremental search. 2747 "Whether scrolling is allowed during incremental search.
2748If non-nil, scrolling commands can be used in Isearch mode. 2748If non-nil, scrolling commands can be used in Isearch mode.
2749However, the current match will never scroll offscreen. 2749However, you cannot scroll far enough that the current match is
2750If nil, scrolling commands will first cancel Isearch mode." 2750no longer visible (is off screen). But if the value is `unlimited'
2751 :type 'boolean 2751that limitation is removed and you can scroll any distance off screen.
2752If nil, scrolling commands exit Isearch mode."
2753 :type '(choice (const :tag "Scrolling exits Isearch" nil)
2754 (const :tag "Scrolling with current match on screen" t)
2755 (const :tag "Scrolling with current match off screen" unlimited))
2752 :group 'isearch) 2756 :group 'isearch)
2753 2757
2754(defcustom isearch-allow-prefix t 2758(defcustom isearch-allow-prefix t
@@ -2846,7 +2850,8 @@ See more for options in `search-exit-option'."
2846 (or (eq (get this-command 'isearch-scroll) t) 2850 (or (eq (get this-command 'isearch-scroll) t)
2847 (eq (get this-command 'scroll-command) t)))) 2851 (eq (get this-command 'scroll-command) t))))
2848 (when isearch-allow-scroll 2852 (when isearch-allow-scroll
2849 (setq isearch-pre-scroll-point (point)))) 2853 (unless (eq isearch-allow-scroll 'unlimited)
2854 (setq isearch-pre-scroll-point (point)))))
2850 ;; A mouse click on the isearch message starts editing the search string. 2855 ;; A mouse click on the isearch message starts editing the search string.
2851 ((and (eq (car-safe main-event) 'down-mouse-1) 2856 ((and (eq (car-safe main-event) 'down-mouse-1)
2852 (window-minibuffer-p (posn-window (event-start main-event)))) 2857 (window-minibuffer-p (posn-window (event-start main-event))))
@@ -2875,29 +2880,31 @@ See more for options in `search-exit-option'."
2875 (isearch-clean-overlays))))) 2880 (isearch-clean-overlays)))))
2876 2881
2877(defun isearch-post-command-hook () 2882(defun isearch-post-command-hook ()
2878 (cond 2883 (when isearch-pre-scroll-point
2879 (isearch-pre-scroll-point 2884 (let ((ab-bel (isearch-string-out-of-window isearch-pre-scroll-point)))
2880 (let ((ab-bel (isearch-string-out-of-window isearch-pre-scroll-point))) 2885 (if ab-bel
2881 (if ab-bel 2886 (isearch-back-into-window (eq ab-bel 'above) isearch-pre-scroll-point)
2882 (isearch-back-into-window (eq ab-bel 'above) isearch-pre-scroll-point) 2887 (goto-char isearch-pre-scroll-point)))
2883 (goto-char isearch-pre-scroll-point))) 2888 (setq isearch-pre-scroll-point nil)
2884 (setq isearch-pre-scroll-point nil) 2889 (isearch-update))
2885 (isearch-update)) 2890 (when (eq isearch-allow-scroll 'unlimited)
2886 ((memq search-exit-option '(move shift-move)) 2891 (when isearch-lazy-highlight
2887 (when (and isearch-pre-move-point 2892 (isearch-lazy-highlight-new-loop)))
2888 (not (eq isearch-pre-move-point (point)))) 2893 (when (memq search-exit-option '(move shift-move))
2889 (let ((string (buffer-substring-no-properties 2894 (when (and isearch-pre-move-point
2890 (or isearch-other-end isearch-opoint) (point)))) 2895 (not (eq isearch-pre-move-point (point))))
2891 (if isearch-regexp (setq string (regexp-quote string))) 2896 (let ((string (buffer-substring-no-properties
2892 (setq isearch-string string) 2897 (or isearch-other-end isearch-opoint) (point))))
2893 (setq isearch-message (mapconcat 'isearch-text-char-description 2898 (if isearch-regexp (setq string (regexp-quote string)))
2894 string "")) 2899 (setq isearch-string string)
2895 (setq isearch-yank-flag t) 2900 (setq isearch-message (mapconcat 'isearch-text-char-description
2896 (setq isearch-forward (<= (or isearch-other-end isearch-opoint) (point))) 2901 string ""))
2897 (when isearch-forward 2902 (setq isearch-yank-flag t)
2898 (goto-char isearch-pre-move-point)) 2903 (setq isearch-forward (<= (or isearch-other-end isearch-opoint) (point)))
2899 (isearch-search-and-update))) 2904 (when isearch-forward
2900 (setq isearch-pre-move-point nil))) 2905 (goto-char isearch-pre-move-point))
2906 (isearch-search-and-update)))
2907 (setq isearch-pre-move-point nil))
2901 (force-mode-line-update)) 2908 (force-mode-line-update))
2902 2909
2903(defun isearch-quote-char (&optional count) 2910(defun isearch-quote-char (&optional count)