annotate lisp/window.el @ 1870:d90e9fecad48

* frame.c (Fframe_parameters): Report the `minibuffer' parameter of minibufferless frames as nil, not `none'. (Qnone): Remove declaration and initialization for this. It's not needed anymore. * xfns.c (Qnone): Add them here; we still accept "none" as a valid value for the `minibuffer' parameter.
author Jim Blandy <jimb@redhat.com>
date Sun, 14 Feb 1993 14:38:19 +0000
parents 2cdce064065f
children bb127c1081af
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
656
d74e65773062 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 419
diff changeset
1 ;;; windows.el --- GNU Emacs window commands aside from those written in C.
773
9c89fd7ddd41 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 707
diff changeset
2
841
2cdce064065f entered into RCS
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 820
diff changeset
3 ;;; Copyright (C) 1985, 1989, 1992 Free Software Foundation, Inc.
2cdce064065f entered into RCS
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 820
diff changeset
4
773
9c89fd7ddd41 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 707
diff changeset
5 ;; Maintainer: FSF
36
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
6
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
7 ;; This file is part of GNU Emacs.
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
8
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
10 ;; it under the terms of the GNU General Public License as published by
707
e4253da532fb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 698
diff changeset
11 ;; the Free Software Foundation; either version 2, or (at your option)
36
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
12 ;; any later version.
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
13
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
14 ;; GNU Emacs is distributed in the hope that it will be useful,
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
17 ;; GNU General Public License for more details.
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
18
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
19 ;; You should have received a copy of the GNU General Public License
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
20 ;; along with GNU Emacs; see the file COPYING. If not, write to
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
21 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
22
773
9c89fd7ddd41 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 707
diff changeset
23 ;;; Code:
36
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
24
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
25 (defun count-windows (&optional minibuf)
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
26 "Returns the number of visible windows.
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
27 Optional arg NO-MINI non-nil means don't count the minibuffer
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
28 even if it is active."
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
29 (let ((count 0))
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
30 (walk-windows (function (lambda ()
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
31 (setq count (+ count 1))))
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
32 minibuf)
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
33 count))
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
34
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
35 (defun balance-windows ()
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
36 "Makes all visible windows the same size (approximately)."
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
37 (interactive)
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
38 (let ((count 0))
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
39 (walk-windows (function (lambda (w)
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
40 (setq count (+ count 1))))
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
41 'nomini)
779
c2dbf1fe0506 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 773
diff changeset
42 (let ((size (/ (frame-height) count)))
36
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
43 (walk-windows (function (lambda (w)
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
44 (select-window w)
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
45 (enlarge-window (- size (window-height)))))
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
46 'nomini))))
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
47
698
793483bd29fe *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 656
diff changeset
48 ;;; I think this should be the default; I think people will prefer it--rms.
382
b6465a2ae3e5 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 108
diff changeset
49
698
793483bd29fe *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 656
diff changeset
50 (defvar split-window-keep-point t
382
b6465a2ae3e5 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 108
diff changeset
51 "*If non-nil, split windows so that both windows keep the original
b6465a2ae3e5 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 108
diff changeset
52 value of point. This is often more convenient for editing.
b6465a2ae3e5 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 108
diff changeset
53 If nil, split windows to minimize redisplay. This is convenient on
b6465a2ae3e5 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 108
diff changeset
54 slow terminals, but point may be moved strangely to accommodate the
b6465a2ae3e5 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 108
diff changeset
55 redisplay.")
b6465a2ae3e5 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 108
diff changeset
56
36
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
57 (defun split-window-vertically (&optional arg)
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
58 "Split current window into two windows, one above the other.
108
8644955999f0 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 36
diff changeset
59 The uppermost window gets ARG lines and the other gets the rest.
8644955999f0 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 36
diff changeset
60 With no argument, split equally or close to it.
8644955999f0 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 36
diff changeset
61 Both windows display the same buffer now current.
382
b6465a2ae3e5 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 108
diff changeset
62
b6465a2ae3e5 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 108
diff changeset
63 If the variable split-window-keep-point is non-nil, both new windows
b6465a2ae3e5 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 108
diff changeset
64 will get the same value of point as the current window. This is often
b6465a2ae3e5 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 108
diff changeset
65 more convenient for editing.
108
8644955999f0 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 36
diff changeset
66
382
b6465a2ae3e5 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 108
diff changeset
67 Otherwise, we chose window starts so as to minimize the amount of
b6465a2ae3e5 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 108
diff changeset
68 redisplay; this is convenient on slow terminals. The new selected
b6465a2ae3e5 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 108
diff changeset
69 window is the one that the current value of point appears in. The
b6465a2ae3e5 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 108
diff changeset
70 value of point can change if the text around point is hidden by the
b6465a2ae3e5 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 108
diff changeset
71 new mode line."
36
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
72 (interactive "P")
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
73 (let ((old-w (selected-window))
108
8644955999f0 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 36
diff changeset
74 (old-point (point))
8644955999f0 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 36
diff changeset
75 new-w bottom switch)
36
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
76 (setq new-w (split-window nil (and arg (prefix-numeric-value arg))))
419
4fa4f423f981 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 382
diff changeset
77 (or split-window-keep-point
108
8644955999f0 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 36
diff changeset
78 (progn
382
b6465a2ae3e5 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 108
diff changeset
79 (save-excursion
b6465a2ae3e5 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 108
diff changeset
80 (set-buffer (window-buffer))
b6465a2ae3e5 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 108
diff changeset
81 (goto-char (window-start))
b6465a2ae3e5 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 108
diff changeset
82 (vertical-motion (window-height))
b6465a2ae3e5 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 108
diff changeset
83 (set-window-start new-w (point))
b6465a2ae3e5 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 108
diff changeset
84 (if (> (point) (window-point new-w))
b6465a2ae3e5 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 108
diff changeset
85 (set-window-point new-w (point)))
b6465a2ae3e5 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 108
diff changeset
86 (vertical-motion -1)
b6465a2ae3e5 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 108
diff changeset
87 (setq bottom (point)))
b6465a2ae3e5 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 108
diff changeset
88 (if (<= bottom (point))
b6465a2ae3e5 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 108
diff changeset
89 (set-window-point old-w (1- bottom)))
b6465a2ae3e5 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 108
diff changeset
90 (if (< (window-start new-w) old-point)
b6465a2ae3e5 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 108
diff changeset
91 (progn
b6465a2ae3e5 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 108
diff changeset
92 (set-window-point new-w old-point)
b6465a2ae3e5 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 108
diff changeset
93 (select-window new-w)))))))
36
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
94
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
95 (defun split-window-horizontally (&optional arg)
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
96 "Split current window into two windows side by side.
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
97 This window becomes the leftmost of the two, and gets
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
98 ARG columns. No arg means split equally."
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
99 (interactive "P")
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
100 (split-window nil (and arg (prefix-numeric-value arg)) t))
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
101
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
102 (defun enlarge-window-horizontally (arg)
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
103 "Make current window ARG columns wider."
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
104 (interactive "p")
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
105 (enlarge-window arg t))
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
106
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
107 (defun shrink-window-horizontally (arg)
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
108 "Make current window ARG columns narrower."
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
109 (interactive "p")
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
110 (shrink-window arg t))
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
111
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
112 (define-key ctl-x-map "2" 'split-window-vertically)
707
e4253da532fb *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 698
diff changeset
113 (define-key ctl-x-map "3" 'split-window-horizontally)
36
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
114 (define-key ctl-x-map "}" 'enlarge-window-horizontally)
9697c13298e5 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
115 (define-key ctl-x-map "{" 'shrink-window-horizontally)
656
d74e65773062 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 419
diff changeset
116
d74e65773062 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 419
diff changeset
117 ;;; windows.el ends here