From: Juri Linkov Date: Sat, 17 Nov 2018 21:31:52 +0000 (+0200) Subject: Don't exit Isearch while resizing windows with mouse (bug#32990) X-Git-Tag: emacs-27.0.90~4148 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=8a481d29706eaf023ca786e3b905d397fbcfd685;p=emacs.git Don't exit Isearch while resizing windows with mouse (bug#32990) * lisp/isearch.el (isearch-mouse-leave-buffer): New function. (isearch-mode): Use isearch-mouse-leave-buffer instead of isearch-done for mouse-leave-buffer-hook. (isearch-done): Remove isearch-mouse-leave-buffer from mouse-leave-buffer-hook. (enlarge-window-horizontally, shrink-window-horizontally) (shrink-window, mouse-drag-mode-line, mouse-drag-vertical-line): Put property isearch-scroll with t. (isearch-mode): Reset isearch-pre-scroll-point and isearch-pre-move-point to nil for the case when Isearch exits between isearch-pre-command-hook (that sets these values) and isearch-post-command-hook (that used to reset them). --- diff --git a/lisp/isearch.el b/lisp/isearch.el index 035ff693275..87f4d495f4e 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el @@ -973,6 +973,9 @@ used to set the value of `isearch-regexp-function'." isearch-input-method-local-p (local-variable-p 'input-method-function) regexp-search-ring-yank-pointer nil + isearch-pre-scroll-point nil + isearch-pre-move-point nil + ;; Save the original value of `minibuffer-message-timeout', and ;; set it to nil so that isearch's messages don't get timed out. isearch-original-minibuffer-message-timeout minibuffer-message-timeout @@ -1015,7 +1018,7 @@ used to set the value of `isearch-regexp-function'." (add-hook 'pre-command-hook 'isearch-pre-command-hook) (add-hook 'post-command-hook 'isearch-post-command-hook) - (add-hook 'mouse-leave-buffer-hook 'isearch-done) + (add-hook 'mouse-leave-buffer-hook 'isearch-mouse-leave-buffer) (add-hook 'kbd-macro-termination-hook 'isearch-done) ;; isearch-mode can be made modal (in the sense of not returning to @@ -1112,7 +1115,7 @@ NOPUSH is t and EDIT is t." (remove-hook 'pre-command-hook 'isearch-pre-command-hook) (remove-hook 'post-command-hook 'isearch-post-command-hook) - (remove-hook 'mouse-leave-buffer-hook 'isearch-done) + (remove-hook 'mouse-leave-buffer-hook 'isearch-mouse-leave-buffer) (remove-hook 'kbd-macro-termination-hook 'isearch-done) (setq isearch-lazy-highlight-start nil) (when (buffer-live-p isearch--current-buffer) @@ -1176,6 +1179,11 @@ NOPUSH is t and EDIT is t." (and (not edit) isearch-recursive-edit (exit-recursive-edit))) +(defun isearch-mouse-leave-buffer () + "Exit Isearch unless the mouse command is allowed in Isearch." + (unless (eq (get this-command 'isearch-scroll) t) + (isearch-done))) + (defun isearch-update-ring (string &optional regexp) "Add STRING to the beginning of the search ring. REGEXP if non-nil says use the regexp search ring." @@ -2390,6 +2398,12 @@ to the barrier." (put 'split-window-right 'isearch-scroll t) (put 'split-window-below 'isearch-scroll t) (put 'enlarge-window 'isearch-scroll t) +(put 'enlarge-window-horizontally 'isearch-scroll t) +(put 'shrink-window-horizontally 'isearch-scroll t) +(put 'shrink-window 'isearch-scroll t) +;; The next two commands don't exit Isearch in isearch-mouse-leave-buffer +(put 'mouse-drag-mode-line 'isearch-scroll t) +(put 'mouse-drag-vertical-line 'isearch-scroll t) ;; Aliases for split-window-* (put 'split-window-vertically 'isearch-scroll t)