X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/07bec0fc67ee0b26685f0ec7f28d9b73f67bf3de..9dfa949c0d24b8b74104e5cd1ac2fc0bdaa37341:/lisp/window.el diff --git a/lisp/window.el b/lisp/window.el index 5ac04c7e99..b1acd93926 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -108,7 +108,7 @@ Return the buffer." ;; Return the buffer. buffer))) -(defun temp-buffer-window-show (&optional buffer action) +(defun temp-buffer-window-show (buffer &optional action) "Show temporary buffer BUFFER in a window. Return the window showing BUFFER. Pass ACTION as action argument to `display-buffer'." @@ -185,19 +185,19 @@ argument replaces this)." (let ((buffer (make-symbol "buffer")) (window (make-symbol "window")) (value (make-symbol "value"))) - (macroexp-let2 nil vbuffer-or-name buffer-or-name - (macroexp-let2 nil vaction action - (macroexp-let2 nil vquit-function quit-function - `(let* ((,buffer (temp-buffer-window-setup ,vbuffer-or-name)) - (standard-output ,buffer) - ,window ,value) - (setq ,value (progn ,@body)) - (with-current-buffer ,buffer - (setq ,window (temp-buffer-window-show ,buffer ,vaction))) - - (if (functionp ,vquit-function) - (funcall ,vquit-function ,window ,value) - ,value))))))) + (macroexp-let2* nil ((vbuffer-or-name buffer-or-name) + (vaction action) + (vquit-function quit-function)) + `(let* ((,buffer (temp-buffer-window-setup ,vbuffer-or-name)) + (standard-output ,buffer) + ,window ,value) + (setq ,value (progn ,@body)) + (with-current-buffer ,buffer + (setq ,window (temp-buffer-window-show ,buffer ,vaction))) + + (if (functionp ,vquit-function) + (funcall ,vquit-function ,window ,value) + ,value))))) (defmacro with-current-buffer-window (buffer-or-name action quit-function &rest body) "Evaluate BODY with a buffer BUFFER-OR-NAME current and show that buffer. @@ -208,19 +208,19 @@ BODY." (let ((buffer (make-symbol "buffer")) (window (make-symbol "window")) (value (make-symbol "value"))) - (macroexp-let2 nil vbuffer-or-name buffer-or-name - (macroexp-let2 nil vaction action - (macroexp-let2 nil vquit-function quit-function - `(let* ((,buffer (temp-buffer-window-setup ,vbuffer-or-name)) - (standard-output ,buffer) - ,window ,value) - (with-current-buffer ,buffer - (setq ,value (progn ,@body)) - (setq ,window (temp-buffer-window-show ,buffer ,vaction))) - - (if (functionp ,vquit-function) - (funcall ,vquit-function ,window ,value) - ,value))))))) + (macroexp-let2* nil ((vbuffer-or-name buffer-or-name) + (vaction action) + (vquit-function quit-function)) + `(let* ((,buffer (temp-buffer-window-setup ,vbuffer-or-name)) + (standard-output ,buffer) + ,window ,value) + (with-current-buffer ,buffer + (setq ,value (progn ,@body)) + (setq ,window (temp-buffer-window-show ,buffer ,vaction))) + + (if (functionp ,vquit-function) + (funcall ,vquit-function ,window ,value) + ,value))))) (defmacro with-displayed-buffer-window (buffer-or-name action quit-function &rest body) "Show a buffer BUFFER-OR-NAME and evaluate BODY in that buffer. @@ -230,28 +230,28 @@ displays the buffer specified by BUFFER-OR-NAME before running BODY." (let ((buffer (make-symbol "buffer")) (window (make-symbol "window")) (value (make-symbol "value"))) - (macroexp-let2 nil vbuffer-or-name buffer-or-name - (macroexp-let2 nil vaction action - (macroexp-let2 nil vquit-function quit-function - `(let* ((,buffer (temp-buffer-window-setup ,vbuffer-or-name)) - (standard-output ,buffer) - ,window ,value) - (with-current-buffer ,buffer - (setq ,window (temp-buffer-window-show ,buffer ,vaction))) - - (let ((inhibit-read-only t) - (inhibit-modification-hooks t)) - (setq ,value (progn ,@body))) - - (set-window-point ,window (point-min)) - - (when (functionp (cdr (assq 'window-height (cdr ,vaction)))) - (ignore-errors - (funcall (cdr (assq 'window-height (cdr ,vaction))) ,window))) + (macroexp-let2* nil ((vbuffer-or-name buffer-or-name) + (vaction action) + (vquit-function quit-function)) + `(let* ((,buffer (temp-buffer-window-setup ,vbuffer-or-name)) + (standard-output ,buffer) + ,window ,value) + (with-current-buffer ,buffer + (setq ,window (temp-buffer-window-show ,buffer ,vaction))) + + (let ((inhibit-read-only t) + (inhibit-modification-hooks t)) + (setq ,value (progn ,@body))) + + (set-window-point ,window (point-min)) + + (when (functionp (cdr (assq 'window-height (cdr ,vaction)))) + (ignore-errors + (funcall (cdr (assq 'window-height (cdr ,vaction))) ,window))) - (if (functionp ,vquit-function) - (funcall ,vquit-function ,window ,value) - ,value))))))) + (if (functionp ,vquit-function) + (funcall ,vquit-function ,window ,value) + ,value))))) ;; The following two functions are like `window-next-sibling' and ;; `window-prev-sibling' but the WINDOW argument is _not_ optional (so @@ -1745,9 +1745,6 @@ doc-string of `window-resizable'." (defalias 'window-height 'window-total-height) (defalias 'window-width 'window-body-width) -;; Eventually the following two should work pixelwise. - -;; See discussion in bug#4543. (defun window-full-height-p (&optional window) "Return t if WINDOW is as high as its containing frame. More precisely, return t if and only if the total height of @@ -1755,8 +1752,10 @@ WINDOW equals the total height of the root window of WINDOW's frame. WINDOW must be a valid window and defaults to the selected one." (setq window (window-normalize-window window)) - (= (window-pixel-height window) - (window-pixel-height (frame-root-window window)))) + (if (window-minibuffer-p window) + (eq window (frame-root-window (window-frame window))) + (= (window-pixel-height window) + (window-pixel-height (frame-root-window window))))) (defun window-full-width-p (&optional window) "Return t if WINDOW is as wide as its containing frame. @@ -1780,28 +1779,26 @@ optional argument PIXELWISE is passed to the functions." (window-body-height window pixelwise))) (defun window-current-scroll-bars (&optional window) - "Return the current scroll bar settings for WINDOW. + "Return the current scroll bar types for WINDOW. WINDOW must be a live window and defaults to the selected one. The return value is a cons cell (VERTICAL . HORIZONTAL) where VERTICAL specifies the current location of the vertical scroll -bars (`left', `right', or nil), and HORIZONTAL specifies the -current location of the horizontal scroll bars (`top', `bottom', -or nil). +bar (`left', `right' or nil), and HORIZONTAL specifies the +current location of the horizontal scroll bar (`bottom' or nil). Unlike `window-scroll-bars', this function reports the scroll bar type actually used, once frame defaults and `scroll-bar-mode' are taken into account." (setq window (window-normalize-window window t)) - (let ((vert (nth 2 (window-scroll-bars window))) - (hor nil)) - (when (or (eq vert t) (eq hor t)) - (let ((fcsb (frame-current-scroll-bars (window-frame window)))) - (if (eq vert t) - (setq vert (car fcsb))) - (if (eq hor t) - (setq hor (cdr fcsb))))) - (cons vert hor))) + (let ((vertical (nth 2 (window-scroll-bars window))) + (horizontal (nth 5 (window-scroll-bars window))) + (inherited (frame-current-scroll-bars (window-frame window)))) + (when (eq vertical t) + (setq vertical (car inherited))) + (when (eq horizontal t) + (setq horizontal (cdr inherited))) + (cons vertical (and horizontal 'bottom)))) (defun walk-windows (fun &optional minibuf all-frames) "Cycle through all live windows, calling FUN for each one. @@ -7176,7 +7173,7 @@ FRAME." (height (+ (cdr value) (window-bottom-divider-width) - (nth 3 (window-scroll-bars))))) + (window-scroll-bar-height)))) ;; Don't change height or width when the window's size is fixed ;; in either direction or ONLY forbids it. (cond @@ -7335,7 +7332,7 @@ accessible position." ;; height. Its width remains fixed. (setq height (+ (cdr (window-text-pixel-size nil nil t nil (frame-pixel-height) t)) - (nth 3 (window-scroll-bars window)) + (window-scroll-bar-height window) (window-bottom-divider-width))) ;; Round height. (unless pixelwise @@ -7803,7 +7800,7 @@ is active. This function is run by `mouse-autoselect-window-timer'." (defun handle-select-window (event) "Handle select-window events." - (interactive "e") + (interactive "^e") (let ((window (posn-window (event-start event)))) (unless (or (not (window-live-p window)) ;; Don't switch if we're currently in the minibuffer.