aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2016-08-02 15:17:01 -0400
committerStefan Monnier2016-08-02 15:17:01 -0400
commit9d5cd450564a841c9146e3453f92b2fe0b001067 (patch)
treee5a2b1ea966b0ebd240cb4d101bb00ea927e504c
parentc441f5649871e7ba13bf0d4edb785105ce845efd (diff)
downloademacs-9d5cd450564a841c9146e3453f92b2fe0b001067.tar.gz
emacs-9d5cd450564a841c9146e3453f92b2fe0b001067.zip
* lisp/window.el: Use lexical-binding
(window--min-size-ignore-p): Remove unused arg `horizontal'. (window--sanitize-window-sizes): Remove unused arg `frame'. (window-edges): Remove unused vars left-off and right-off. (display-buffer-reuse-mode-window): Remove unused var `frame?'. Avoid extraneous setq and do a bit of CSE. (fit-frame-to-buffer): Remove unused vars `window', `fit-width', and `toolbar-extra-height'. (window-adjust-process-window-size): Remove unused arg `process'.
-rw-r--r--lisp/window.el88
1 files changed, 32 insertions, 56 deletions
diff --git a/lisp/window.el b/lisp/window.el
index a0bdfeb672a..faefbd38e82 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -1,4 +1,4 @@
1;;; window.el --- GNU Emacs window commands aside from those written in C 1;;; window.el --- GNU Emacs window commands aside from those written in C -*- lexical-binding:t -*-
2 2
3;; Copyright (C) 1985, 1989, 1992-1994, 2000-2016 Free Software 3;; Copyright (C) 1985, 1989, 1992-1994, 2000-2016 Free Software
4;; Foundation, Inc. 4;; Foundation, Inc.
@@ -1333,10 +1333,8 @@ return the minimum pixel-size of WINDOW."
1333 (window--min-size-1 1333 (window--min-size-1
1334 (window-normalize-window window) horizontal ignore pixelwise)) 1334 (window-normalize-window window) horizontal ignore pixelwise))
1335 1335
1336(defun window--min-size-ignore-p (window horizontal ignore) 1336(defun window--min-size-ignore-p (window ignore)
1337 "Return non-nil if IGNORE says to ignore height restrictions for WINDOW. 1337 "Return non-nil if IGNORE says to ignore height restrictions for WINDOW."
1338HORIZONTAL non-nil means to return non-nil if IGNORE says to
1339ignore width restrictions for WINDOW."
1340 (if (window-valid-p ignore) 1338 (if (window-valid-p ignore)
1341 (eq window ignore) 1339 (eq window ignore)
1342 (not (memq ignore '(nil preserved))))) 1340 (not (memq ignore '(nil preserved)))))
@@ -1396,12 +1394,12 @@ ignore width restrictions for WINDOW."
1396 pixel-width 1394 pixel-width
1397 ;; Round up to next integral of columns. 1395 ;; Round up to next integral of columns.
1398 (* (ceiling pixel-width char-size) char-size)) 1396 (* (ceiling pixel-width char-size) char-size))
1399 (if (window--min-size-ignore-p window horizontal ignore) 1397 (if (window--min-size-ignore-p window ignore)
1400 0 1398 0
1401 (window-min-pixel-width window))) 1399 (window-min-pixel-width window)))
1402 (max 1400 (max
1403 (ceiling pixel-width char-size) 1401 (ceiling pixel-width char-size)
1404 (if (window--min-size-ignore-p window horizontal ignore) 1402 (if (window--min-size-ignore-p window ignore)
1405 0 1403 0
1406 window-min-width))))) 1404 window-min-width)))))
1407 ((let ((char-size (frame-char-size window)) 1405 ((let ((char-size (frame-char-size window))
@@ -1417,11 +1415,11 @@ ignore width restrictions for WINDOW."
1417 pixel-height 1415 pixel-height
1418 ;; Round up to next integral of lines. 1416 ;; Round up to next integral of lines.
1419 (* (ceiling pixel-height char-size) char-size)) 1417 (* (ceiling pixel-height char-size) char-size))
1420 (if (window--min-size-ignore-p window horizontal ignore) 1418 (if (window--min-size-ignore-p window ignore)
1421 0 1419 0
1422 (window-min-pixel-height window))) 1420 (window-min-pixel-height window)))
1423 (max (ceiling pixel-height char-size) 1421 (max (ceiling pixel-height char-size)
1424 (if (window--min-size-ignore-p window horizontal ignore) 1422 (if (window--min-size-ignore-p window ignore)
1425 0 1423 0
1426 window-min-height)))))))))) 1424 window-min-height))))))))))
1427 1425
@@ -3129,8 +3127,8 @@ routines."
3129 pixel-delta 3127 pixel-delta
3130 (/ pixel-delta (frame-char-height frame))))) 3128 (/ pixel-delta (frame-char-height frame)))))
3131 3129
3132(defun window--sanitize-window-sizes (frame horizontal) 3130(defun window--sanitize-window-sizes (horizontal)
3133 "Assert that all windows on FRAME are large enough. 3131 "Assert that all windows on selected frame are large enough.
3134If necessary and possible, make sure that every window on frame 3132If necessary and possible, make sure that every window on frame
3135FRAME has its minimum height. Optional argument HORIZONTAL 3133FRAME has its minimum height. Optional argument HORIZONTAL
3136non-nil means to make sure that every window on frame FRAME has 3134non-nil means to make sure that every window on frame FRAME has
@@ -3508,8 +3506,7 @@ ABSOLUTE is non-nil, PIXELWISE is implicitly non-nil too."
3508 (bottom (+ top (if pixelwise 3506 (bottom (+ top (if pixelwise
3509 (window-pixel-height window) 3507 (window-pixel-height window)
3510 (window-total-height window)))) 3508 (window-total-height window))))
3511 (bottom-body (and body (+ top-body (window-body-height window t)))) 3509 (bottom-body (and body (+ top-body (window-body-height window t)))))
3512 left-off right-off)
3513 (if absolute 3510 (if absolute
3514 (let* ((native-edges (frame-edges frame 'native-edges)) 3511 (let* ((native-edges (frame-edges frame 'native-edges))
3515 (left-off (nth 0 native-edges)) 3512 (left-off (nth 0 native-edges))
@@ -4878,7 +4875,7 @@ frame. The selected window is not changed by this function."
4878 4875
4879 ;; Sanitize sizes unless SIZE was specified. 4876 ;; Sanitize sizes unless SIZE was specified.
4880 (unless size 4877 (unless size
4881 (window--sanitize-window-sizes frame horizontal)) 4878 (window--sanitize-window-sizes horizontal))
4882 4879
4883 (run-window-configuration-change-hook frame) 4880 (run-window-configuration-change-hook frame)
4884 (run-window-scroll-functions new) 4881 (run-window-scroll-functions new)
@@ -6785,23 +6782,22 @@ The behaviour is also controlled by entries for
6785 derived-mode-same-frame 6782 derived-mode-same-frame
6786 derived-mode-other-frame) 6783 derived-mode-other-frame)
6787 (dolist (window windows) 6784 (dolist (window windows)
6788 (let (mode? frame?) 6785 (let ((mode?
6789 (with-current-buffer (window-buffer window) 6786 (with-current-buffer (window-buffer window)
6790 (setq mode? 6787 (cond ((memq major-mode allowed-modes)
6791 (cond ((memq major-mode allowed-modes) 6788 'same)
6792 'same) 6789 ((derived-mode-p allowed-modes)
6793 ((derived-mode-p allowed-modes) 6790 'derived)))))
6794 'derived))))
6795 (when (and mode? 6791 (when (and mode?
6796 (not (and inhibit-same-window-p 6792 (not (and inhibit-same-window-p
6797 (eq window curwin)))) 6793 (eq window curwin))))
6798 (if (eq curframe (window-frame window)) 6794 (push window (if (eq curframe (window-frame window))
6799 (if (eq mode? 'same) 6795 (if (eq mode? 'same)
6800 (push window same-mode-same-frame) 6796 same-mode-same-frame
6801 (push window derived-mode-same-frame)) 6797 derived-mode-same-frame)
6802 (if (eq mode? 'same) 6798 (if (eq mode? 'same)
6803 (push window same-mode-other-frame) 6799 same-mode-other-frame
6804 (push window derived-mode-other-frame)))))) 6800 derived-mode-other-frame))))))
6805 (let ((window (car (nconc same-mode-same-frame 6801 (let ((window (car (nconc same-mode-same-frame
6806 same-mode-other-frame 6802 same-mode-other-frame
6807 derived-mode-same-frame 6803 derived-mode-same-frame
@@ -7548,8 +7544,7 @@ FRAME."
7548 (setq frame (window-normalize-frame frame)) 7544 (setq frame (window-normalize-frame frame))
7549 (when (window-live-p (frame-root-window frame)) 7545 (when (window-live-p (frame-root-window frame))
7550 (with-selected-window (frame-root-window frame) 7546 (with-selected-window (frame-root-window frame)
7551 (let* ((window (frame-root-window frame)) 7547 (let* ((char-width (frame-char-width))
7552 (char-width (frame-char-width))
7553 (char-height (frame-char-height)) 7548 (char-height (frame-char-height))
7554 (monitor-attributes (car (display-monitor-attributes-list 7549 (monitor-attributes (car (display-monitor-attributes-list
7555 (frame-parameter frame 'display)))) 7550 (frame-parameter frame 'display))))
@@ -7596,8 +7591,6 @@ FRAME."
7596 ;; and the window's body width. This is the space we can't 7591 ;; and the window's body width. This is the space we can't
7597 ;; use for fitting. 7592 ;; use for fitting.
7598 (extra-width (- frame-width window-body-width)) 7593 (extra-width (- frame-width window-body-width))
7599 ;; The maximum width we can use for fitting.
7600 (fit-width (- workarea-width extra-width))
7601 ;; The pixel position of FRAME's left border. We usually 7594 ;; The pixel position of FRAME's left border. We usually
7602 ;; try to leave this alone. 7595 ;; try to leave this alone.
7603 (left 7596 (left
@@ -7616,23 +7609,6 @@ FRAME."
7616 ;; The difference in pixels between the frame's pixel 7609 ;; The difference in pixels between the frame's pixel
7617 ;; height and the window's height. 7610 ;; height and the window's height.
7618 (extra-height (- frame-height window-height)) 7611 (extra-height (- frame-height window-height))
7619 ;; When tool-bar-mode is enabled and we just created a new
7620 ;; frame, reserve lines for toolbar resizing. Needed
7621 ;; because for reasons unknown to me Emacs (1) reserves one
7622 ;; line for the toolbar when making the initial frame and
7623 ;; toolbars are enabled, and (2) later adds the remaining
7624 ;; lines needed. Our code runs IN BETWEEN (1) and (2).
7625 ;; YMMV when you're on a system that behaves differently.
7626 (toolbar-extra-height
7627 (let ((quit-restore (window-parameter window 'quit-restore))
7628 ;; This may have to change when we allow arbitrary
7629 ;; pixel height toolbars.
7630 (lines (tool-bar-height)))
7631 (* char-height
7632 (if (and quit-restore (eq (car quit-restore) 'frame)
7633 (not (zerop lines)))
7634 (1- lines)
7635 0))))
7636 ;; The pixel position of FRAME's top border. 7612 ;; The pixel position of FRAME's top border.
7637 (top 7613 (top
7638 (let ((top (frame-parameter nil 'top))) 7614 (let ((top (frame-parameter nil 'top)))
@@ -8554,9 +8530,9 @@ overrides the global or buffer-local value of
8554 :group 'windows 8530 :group 'windows
8555 :version "25.1") 8531 :version "25.1")
8556 8532
8557(defun window-adjust-process-window-size (reducer process windows) 8533(defun window-adjust-process-window-size (reducer windows)
8558 "Adjust the process window size of PROCESS. 8534 "Adjust the window sizes of a process.
8559WINDOWS is a list of windows associated with PROCESS. REDUCER is 8535WINDOWS is a list of windows associated with that process. REDUCER is
8560a two-argument function used to combine the widths and heights of 8536a two-argument function used to combine the widths and heights of
8561the given windows." 8537the given windows."
8562 (when windows 8538 (when windows
@@ -8567,17 +8543,17 @@ the given windows."
8567 (setf height (funcall reducer height (window-body-height window)))) 8543 (setf height (funcall reducer height (window-body-height window))))
8568 (cons width height)))) 8544 (cons width height))))
8569 8545
8570(defun window-adjust-process-window-size-smallest (process windows) 8546(defun window-adjust-process-window-size-smallest (_process windows)
8571 "Adjust the process window size of PROCESS. 8547 "Adjust the process window size of PROCESS.
8572WINDOWS is a list of windows associated with PROCESS. Choose the 8548WINDOWS is a list of windows associated with PROCESS. Choose the
8573smallest area available for displaying PROCESS's output." 8549smallest area available for displaying PROCESS's output."
8574 (window-adjust-process-window-size #'min process windows)) 8550 (window-adjust-process-window-size #'min windows))
8575 8551
8576(defun window-adjust-process-window-size-largest (process windows) 8552(defun window-adjust-process-window-size-largest (_process windows)
8577 "Adjust the process window size of PROCESS. 8553 "Adjust the process window size of PROCESS.
8578WINDOWS is a list of windows associated with PROCESS. Choose the 8554WINDOWS is a list of windows associated with PROCESS. Choose the
8579largest area available for displaying PROCESS's output." 8555largest area available for displaying PROCESS's output."
8580 (window-adjust-process-window-size #'max process windows)) 8556 (window-adjust-process-window-size #'max windows))
8581 8557
8582(defun window--process-window-list () 8558(defun window--process-window-list ()
8583 "Return an alist mapping processes to associated windows. 8559 "Return an alist mapping processes to associated windows.