diff options
Diffstat (limited to 'lisp/window.el')
-rw-r--r-- | lisp/window.el | 105 |
1 files changed, 53 insertions, 52 deletions
diff --git a/lisp/window.el b/lisp/window.el index 2c0ea8e4d56..76de4207e74 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -3084,11 +3084,12 @@ already set by this routine." (while (and best-window (not (zerop delta))) (setq sub last) (setq best-window nil) - (setq best-value most-negative-fixnum) + (setq best-value nil) (while sub (when (and (consp (window-new-normal sub)) (not (<= (car (window-new-normal sub)) 0)) - (> (cdr (window-new-normal sub)) best-value)) + (or (not best-value) + (> (cdr (window-new-normal sub)) best-value))) (setq best-window sub) (setq best-value (cdr (window-new-normal sub)))) @@ -3113,10 +3114,11 @@ already set by this routine." (while (and best-window (not (zerop delta))) (setq sub last) (setq best-window nil) - (setq best-value most-positive-fixnum) + (setq best-value nil) (while sub (when (and (numberp (window-new-normal sub)) - (< (window-new-normal sub) best-value)) + (or (not best-value) + (< (window-new-normal sub) best-value))) (setq best-window sub) (setq best-value (window-new-normal sub))) @@ -6642,6 +6644,7 @@ represents a live window, nil otherwise." )) frame)))) +(defvaralias 'even-window-heights 'even-window-sizes) (defcustom even-window-sizes t "If non-nil `display-buffer' will try to even window sizes. Otherwise `display-buffer' will leave the window configuration @@ -6655,7 +6658,6 @@ any of them." (const :tag "Always" t)) :version "25.1" :group 'windows) -(defvaralias 'even-window-heights 'even-window-sizes) (defun window--even-window-sizes (window) "Even sizes of WINDOW and selected window. @@ -7290,12 +7292,23 @@ text-only terminal), try with `display-buffer-pop-up-frame'. If that cannot be done, and `pop-up-windows' is non-nil, try again with `display-buffer-pop-up-window'." - (or (and (if (eq pop-up-frames 'graphic-only) - (display-graphic-p) - pop-up-frames) - (display-buffer-pop-up-frame buffer alist)) - (and pop-up-windows - (display-buffer-pop-up-window buffer alist)))) + (or (display-buffer--maybe-pop-up-frame buffer alist) + (display-buffer--maybe-pop-up-window buffer alist))) + +(defun display-buffer--maybe-pop-up-frame (buffer alist) + "Try displaying BUFFER based on `pop-up-frames'. +If `pop-up-frames' is non-nil (and not `graphic-only' on a +text-only terminal), try with `display-buffer-pop-up-frame'." + (and (if (eq pop-up-frames 'graphic-only) + (display-graphic-p) + pop-up-frames) + (display-buffer-pop-up-frame buffer alist))) + +(defun display-buffer--maybe-pop-up-window (buffer alist) + "Try displaying BUFFER based on `pop-up-windows'. +If `pop-up-windows' is non-nil, try with `display-buffer-pop-up-window'." + (and pop-up-windows + (display-buffer-pop-up-window buffer alist))) (defun display-buffer-in-child-frame (buffer alist) "Display BUFFER in a child frame. @@ -7361,6 +7374,17 @@ below the selected one, use that window." (window--display-buffer buffer window 'reuse alist display-buffer-mark-dedicated))))) +(defun display-buffer--maybe-at-bottom (buffer alist) + (let ((alist (append alist `(,(if temp-buffer-resize-mode + '(window-height . resize-temp-buffer-window) + '(window-height . fit-window-to-buffer)) + ,(when temp-buffer-resize-mode + '(preserve-size . (nil . t))))))) + (or (display-buffer--maybe-same-window buffer alist) + (display-buffer-reuse-window buffer alist) + (display-buffer--maybe-pop-up-frame buffer alist) + (display-buffer-at-bottom buffer alist)))) + (defun display-buffer-at-bottom (buffer alist) "Try displaying BUFFER in a window at the bottom of the selected frame. This either reuses such a window provided it shows BUFFER @@ -7377,8 +7401,8 @@ selected frame." (setq bottom-window-shows-buffer t) (setq bottom-window window)) ((not bottom-window) - (setq bottom-window window))) - nil nil 'nomini)) + (setq bottom-window window)))) + nil nil 'nomini) (or (and bottom-window-shows-buffer (window--display-buffer buffer bottom-window 'reuse alist display-buffer-mark-dedicated)) @@ -8745,7 +8769,7 @@ A prefix argument is handled like `recenter': With plain `C-u', move current line to window center." (interactive "P") (cond - (arg (recenter arg)) ; Always respect ARG. + (arg (recenter arg t)) ; Always respect ARG. (t (setq recenter-last-op (if (eq this-command last-command) @@ -8756,15 +8780,15 @@ A prefix argument is handled like `recenter': (min (max 0 scroll-margin) (truncate (/ (window-body-height) 4.0))))) (cond ((eq recenter-last-op 'middle) - (recenter)) + (recenter nil t)) ((eq recenter-last-op 'top) - (recenter this-scroll-margin)) + (recenter this-scroll-margin t)) ((eq recenter-last-op 'bottom) - (recenter (- -1 this-scroll-margin))) + (recenter (- -1 this-scroll-margin) t)) ((integerp recenter-last-op) - (recenter recenter-last-op)) + (recenter recenter-last-op t)) ((floatp recenter-last-op) - (recenter (round (* recenter-last-op (window-height)))))))))) + (recenter (round (* recenter-last-op (window-height))) t))))))) (define-key global-map [?\C-l] 'recenter-top-bottom) @@ -8902,35 +8926,17 @@ This is different from `scroll-down-command' that scrolls a full screen." (put 'scroll-down-line 'scroll-command t) -(defun scroll-other-window-down (&optional lines) - "Scroll the \"other window\" down. -For more details, see the documentation for `scroll-other-window'." - (interactive "P") - (scroll-other-window - ;; Just invert the argument's meaning. - ;; We can do that without knowing which window it will be. - (if (eq lines '-) nil - (if (null lines) '- - (- (prefix-numeric-value lines)))))) - (defun beginning-of-buffer-other-window (arg) "Move point to the beginning of the buffer in the other window. Leave mark at previous position. With arg N, put point N/10 of the way from the true beginning." (interactive "P") - (let ((orig-window (selected-window)) - (window (other-window-for-scrolling))) - ;; We use unwind-protect rather than save-window-excursion - ;; because the latter would preserve the things we want to change. - (unwind-protect - (progn - (select-window window) - ;; Set point and mark in that window's buffer. - (with-no-warnings - (beginning-of-buffer arg)) - ;; Set point accordingly. - (recenter '(t))) - (select-window orig-window)))) + (with-selected-window (other-window-for-scrolling) + ;; Set point and mark in that window's buffer. + (with-no-warnings + (beginning-of-buffer arg)) + ;; Set point accordingly. + (recenter '(t)))) (defun end-of-buffer-other-window (arg) "Move point to the end of the buffer in the other window. @@ -8938,15 +8944,10 @@ Leave mark at previous position. With arg N, put point N/10 of the way from the true end." (interactive "P") ;; See beginning-of-buffer-other-window for comments. - (let ((orig-window (selected-window)) - (window (other-window-for-scrolling))) - (unwind-protect - (progn - (select-window window) - (with-no-warnings - (end-of-buffer arg)) - (recenter '(t))) - (select-window orig-window)))) + (with-selected-window (other-window-for-scrolling) + (with-no-warnings + (end-of-buffer arg)) + (recenter '(t)))) (defvar mouse-autoselect-window-timer nil "Timer used by delayed window autoselection.") |