;;; window.el --- GNU Emacs window commands aside from those written in C
-;; Copyright (C) 1985, 1989, 1992-1994, 2000-2015 Free Software
+;; Copyright (C) 1985, 1989, 1992-1994, 2000-2016 Free Software
;; Foundation, Inc.
;; Maintainer: emacs-devel@gnu.org
(ncols (/ window-width font-width)))
(if (and (display-graphic-p)
overflow-newline-into-fringe
- (/= (frame-parameter nil 'left-fringe) 0)
- (/= (frame-parameter nil 'right-fringe) 0))
+ (not
+ (or (eq left-fringe-width 0)
+ (and (null left-fringe-width)
+ (= (frame-parameter nil 'left-fringe) 0))))
+ (not
+ (or (eq right-fringe-width 0)
+ (and (null right-fringe-width)
+ (= (frame-parameter nil 'right-fringe) 0)))))
ncols
+ ;; FIXME: This should remove 1 more column when there are no
+ ;; fringes, lines are truncated, and the window is hscrolled,
+ ;; but EOL is not in the view, because then there are 2
+ ;; truncation glyphs, not one.
(1- ncols)))))
(defun window-current-scroll-bars (&optional window)
;; Predecessors to the below have been devised by Julian Assange in
;; change-windows-intuitively.el and Hovav Shacham in windmove.el.
-;; Neither of these allow to selectively ignore specific windows
+;; Neither of these allow one to selectively ignore specific windows
;; (windows whose `no-other-window' parameter is non-nil) as targets of
;; the movement.
(defun window-in-direction (direction &optional window ignore sign wrap mini)
Optional argument MINI nil means to return the minibuffer window
if and only if it is currently active. MINI non-nil means to
return the minibuffer window even when it's not active. However,
-if WRAP non-nil, always act as if MINI were nil.
+if WRAP is non-nil, always act as if MINI were nil.
Return nil if no suitable window can be found."
(setq window (window-normalize-window window t))
(when (window-right window)
(window--resize-reset-1 (window-right window) horizontal)))
-;; The following routine is used to manually resize the minibuffer
-;; window and is currently used, for example, by ispell.el.
(defun window--resize-mini-window (window delta)
"Resize minibuffer window WINDOW by DELTA pixels.
If WINDOW cannot be resized by DELTA pixels make it as large (or
(setq ignore 'preserved)
(setq right first-right)
(while (and right
- (or (window-size-fixed-p right horizontal 'preserved))
- (<= (window-size right horizontal t)
- (window-min-size right horizontal 'preserved t)))
+ (or (window-size-fixed-p right horizontal 'preserved)
+ (<= (window-size right horizontal t)
+ (window-min-size right horizontal 'preserved t))))
(setq right
(or (window-right right)
(progn
(cond
((zerop delta))
((window-size-fixed-p nil horizontal)
- (error "Selected window has fixed size"))
+ (user-error "Selected window has fixed size"))
((window-minibuffer-p)
(if horizontal
- (error "Cannot resize minibuffer window horizontally")
- (window--resize-mini-window (selected-window) delta)))
+ (user-error "Cannot resize minibuffer window horizontally")
+ (window--resize-mini-window
+ (selected-window) (* delta (frame-char-height)))))
((and (not horizontal)
(window-full-height-p)
(eq (window-frame minibuffer-window) (selected-frame))
(not resize-mini-windows))
;; If the selected window is full height and `resize-mini-windows'
;; is nil, resize the minibuffer window.
- (window--resize-mini-window minibuffer-window (- delta)))
+ (window--resize-mini-window
+ minibuffer-window (* (- delta) (frame-char-height))))
((window--resizable-p nil delta horizontal)
(window-resize nil delta horizontal))
+ ((window--resizable-p nil delta horizontal 'preserved)
+ (window-resize nil delta horizontal 'preserved))
+ ((eq this-command
+ (if horizontal 'enlarge-window-horizontally 'enlarge-window))
+ ;; For backward compatibility don't signal an error unless this
+ ;; command is `enlarge-window(-horizontally)'.
+ (user-error "Cannot enlarge selected window"))
(t
(window-resize
nil (if (> delta 0)
Interactively, if no argument is given, make the selected window
one line smaller. If optional argument HORIZONTAL is non-nil,
make selected window narrower by DELTA columns. If DELTA is
-negative, enlarge selected window by -DELTA lines or columns.
-Also see the `window-min-height' variable."
+negative, enlarge selected window by -DELTA lines or columns."
(interactive "p")
(let ((minibuffer-window (minibuffer-window)))
(when (window-preserved-size nil horizontal)
(cond
((zerop delta))
((window-size-fixed-p nil horizontal)
- (error "Selected window has fixed size"))
+ (user-error "Selected window has fixed size"))
((window-minibuffer-p)
(if horizontal
- (error "Cannot resize minibuffer window horizontally")
- (window--resize-mini-window (selected-window) (- delta))))
+ (user-error "Cannot resize minibuffer window horizontally")
+ (window--resize-mini-window
+ (selected-window) (* (- delta) (frame-char-height)))))
((and (not horizontal)
(window-full-height-p)
(eq (window-frame minibuffer-window) (selected-frame))
(not resize-mini-windows))
;; If the selected window is full height and `resize-mini-windows'
;; is nil, resize the minibuffer window.
- (window--resize-mini-window minibuffer-window delta))
+ (window--resize-mini-window
+ minibuffer-window (* delta (frame-char-height))))
((window--resizable-p nil (- delta) horizontal)
(window-resize nil (- delta) horizontal))
+ ((window--resizable-p nil (- delta) horizontal 'preserved)
+ (window-resize nil (- delta) horizontal 'preserved))
+ ((eq this-command
+ (if horizontal 'shrink-window-horizontally 'shrink-window))
+ ;; For backward compatibility don't signal an error unless this
+ ;; command is `shrink-window(-horizontally)'.
+ (user-error "Cannot shrink selected window"))
(t
(window-resize
nil (if (> delta 0)
a two-argument function used to combine the widths and heights of
the given windows."
(when windows
- (let ((width (window-body-width (car windows)))
+ (let ((width (window-max-chars-per-line (car windows)))
(height (window-body-height (car windows))))
(dolist (window (cdr windows))
- (setf width (funcall reducer width (window-body-width window)))
+ (setf width (funcall reducer width (window-max-chars-per-line window)))
(setf height (funcall reducer height (window-body-height window))))
(cons width height))))
displaying that processes's buffer."
(let ((processes (process-list))
(process-windows nil))
- (walk-windows
- (lambda (window)
- (let ((buffer (window-buffer window))
- (iter processes))
- (while (let ((process (car iter)))
- (if (and (process-live-p process)
- (eq buffer (process-buffer process)))
- (let ((procwin (assq process process-windows)))
- ;; Add this window to the list of windows
- ;; displaying process.
- (if procwin
- (push window (cdr procwin))
- (push (list process window) process-windows))
- ;; We found our process for this window, so
- ;; stop iterating over the process list.
- nil)
- (setf iter (cdr iter)))))))
- 1 t)
+ (if processes
+ (walk-windows
+ (lambda (window)
+ (let ((buffer (window-buffer window))
+ (iter processes))
+ (while (let ((process (car iter)))
+ (if (and (process-live-p process)
+ (eq buffer (process-buffer process)))
+ (let ((procwin (assq process process-windows)))
+ ;; Add this window to the list of windows
+ ;; displaying process.
+ (if procwin
+ (push window (cdr procwin))
+ (push (list process window) process-windows))
+ ;; We found our process for this window, so
+ ;; stop iterating over the process list.
+ nil)
+ (setf iter (cdr iter)))))))
+ 1 t))
process-windows))
(defun window--adjust-process-windows ()
"Update process window sizes to match the current window configuration."
- (dolist (procwin (window--process-window-list))
- (let ((process (car procwin)))
- (with-demoted-errors "Error adjusting window size: %S"
- (with-current-buffer (process-buffer process)
- (let ((size (funcall
- (or (process-get process 'adjust-window-size-function)
- window-adjust-process-window-size-function)
- process (cdr procwin))))
- (when size
- (set-process-window-size process (cdr size) (car size)))))))))
+ (when (fboundp 'process-list)
+ (dolist (procwin (window--process-window-list))
+ (let ((process (car procwin)))
+ (with-demoted-errors "Error adjusting window size: %S"
+ (with-current-buffer (process-buffer process)
+ (let ((size (funcall
+ (or (process-get process 'adjust-window-size-function)
+ window-adjust-process-window-size-function)
+ process (cdr procwin))))
+ (when size
+ (set-process-window-size process (cdr size) (car size))))))))))
(add-hook 'window-configuration-change-hook 'window--adjust-process-windows)