Mercurial > emacs
annotate lisp/rsz-mini.el @ 18398:3c18aa006200
(LD_SWITCH_SYSTEM) [__mips__]: Alternate definition.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 23 Jun 1997 01:54:03 +0000 |
parents | 43e483167dd3 |
children | da941474d947 |
rev | line source |
---|---|
7267 | 1 ;;; rsz-mini.el --- dynamically resize minibuffer to display entire contents |
2 | |
11297
056c7266a614
(resize-minibuffer-window): Make sure minibuffer window is selected.
Noah Friedman <friedman@splode.com>
parents:
8240
diff
changeset
|
3 ;; Copyright (C) 1990, 1993, 1994, 1995 Free Software Foundation, Inc. |
7267 | 4 |
11297
056c7266a614
(resize-minibuffer-window): Make sure minibuffer window is selected.
Noah Friedman <friedman@splode.com>
parents:
8240
diff
changeset
|
5 ;; Author: Noah Friedman <friedman@prep.ai.mit.edu> |
056c7266a614
(resize-minibuffer-window): Make sure minibuffer window is selected.
Noah Friedman <friedman@splode.com>
parents:
8240
diff
changeset
|
6 ;; Roland McGrath <roland@prep.ai.mit.edu> |
056c7266a614
(resize-minibuffer-window): Make sure minibuffer window is selected.
Noah Friedman <friedman@splode.com>
parents:
8240
diff
changeset
|
7 ;; Maintainer: friedman@prep.ai.mit.edu |
056c7266a614
(resize-minibuffer-window): Make sure minibuffer window is selected.
Noah Friedman <friedman@splode.com>
parents:
8240
diff
changeset
|
8 ;; Keywords: minibuffer, window, frame, display |
7267 | 9 |
10 ;; This file is part of GNU Emacs. | |
11 | |
12 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
13 ;; it under the terms of the GNU General Public License as published by | |
14 ;; the Free Software Foundation; either version 2, or (at your option) | |
15 ;; any later version. | |
16 | |
17 ;; GNU Emacs is distributed in the hope that it will be useful, | |
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 ;; GNU General Public License for more details. | |
21 | |
22 ;; You should have received a copy of the GNU General Public License | |
14169 | 23 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
25 ;; Boston, MA 02111-1307, USA. | |
7267 | 26 |
27 ;;; Commentary: | |
28 | |
11297
056c7266a614
(resize-minibuffer-window): Make sure minibuffer window is selected.
Noah Friedman <friedman@splode.com>
parents:
8240
diff
changeset
|
29 ;; This package allows the entire contents (or as much as possible) of the |
056c7266a614
(resize-minibuffer-window): Make sure minibuffer window is selected.
Noah Friedman <friedman@splode.com>
parents:
8240
diff
changeset
|
30 ;; minibuffer to be visible at once when typing. As the end of a line is |
056c7266a614
(resize-minibuffer-window): Make sure minibuffer window is selected.
Noah Friedman <friedman@splode.com>
parents:
8240
diff
changeset
|
31 ;; reached, the minibuffer will resize itself. When the user is done |
056c7266a614
(resize-minibuffer-window): Make sure minibuffer window is selected.
Noah Friedman <friedman@splode.com>
parents:
8240
diff
changeset
|
32 ;; typing, the minibuffer will return to its original size. |
7267 | 33 |
11297
056c7266a614
(resize-minibuffer-window): Make sure minibuffer window is selected.
Noah Friedman <friedman@splode.com>
parents:
8240
diff
changeset
|
34 ;; In window systems where it is possible to have a frame in which the |
16741 | 35 ;; minibuffer is the only window, the frame itself can be resized. In |
36 ;; Emacs 19.22 and earlier, the frame may not be properly returned to | |
11297
056c7266a614
(resize-minibuffer-window): Make sure minibuffer window is selected.
Noah Friedman <friedman@splode.com>
parents:
8240
diff
changeset
|
37 ;; its original size after it ceases to be active because |
056c7266a614
(resize-minibuffer-window): Make sure minibuffer window is selected.
Noah Friedman <friedman@splode.com>
parents:
8240
diff
changeset
|
38 ;; `minibuffer-exit-hook' didn't exist until version 19.23. |
056c7266a614
(resize-minibuffer-window): Make sure minibuffer window is selected.
Noah Friedman <friedman@splode.com>
parents:
8240
diff
changeset
|
39 ;; |
056c7266a614
(resize-minibuffer-window): Make sure minibuffer window is selected.
Noah Friedman <friedman@splode.com>
parents:
8240
diff
changeset
|
40 ;; Prior to Emacs 19.26, minibuffer-exit-hook wasn't called after exiting |
056c7266a614
(resize-minibuffer-window): Make sure minibuffer window is selected.
Noah Friedman <friedman@splode.com>
parents:
8240
diff
changeset
|
41 ;; from the minibuffer by hitting the quit char. That meant that the |
056c7266a614
(resize-minibuffer-window): Make sure minibuffer window is selected.
Noah Friedman <friedman@splode.com>
parents:
8240
diff
changeset
|
42 ;; frame size restoration function wasn't being called in that case. In |
056c7266a614
(resize-minibuffer-window): Make sure minibuffer window is selected.
Noah Friedman <friedman@splode.com>
parents:
8240
diff
changeset
|
43 ;; 19.26 or later, minibuffer-exit-hook should be called anyway. |
7267 | 44 |
11297
056c7266a614
(resize-minibuffer-window): Make sure minibuffer window is selected.
Noah Friedman <friedman@splode.com>
parents:
8240
diff
changeset
|
45 ;; Note that the minibuffer and echo area are not the same! They simply |
056c7266a614
(resize-minibuffer-window): Make sure minibuffer window is selected.
Noah Friedman <friedman@splode.com>
parents:
8240
diff
changeset
|
46 ;; happen to occupy roughly the same place on the frame. Messages put in |
056c7266a614
(resize-minibuffer-window): Make sure minibuffer window is selected.
Noah Friedman <friedman@splode.com>
parents:
8240
diff
changeset
|
47 ;; the echo area will not cause any resizing by this package. |
7267 | 48 |
11297
056c7266a614
(resize-minibuffer-window): Make sure minibuffer window is selected.
Noah Friedman <friedman@splode.com>
parents:
8240
diff
changeset
|
49 ;; This package is considered a minor mode but it doesn't put anything in |
056c7266a614
(resize-minibuffer-window): Make sure minibuffer window is selected.
Noah Friedman <friedman@splode.com>
parents:
8240
diff
changeset
|
50 ;; minor-mode-alist because this mode is specific to the minibuffer, which |
056c7266a614
(resize-minibuffer-window): Make sure minibuffer window is selected.
Noah Friedman <friedman@splode.com>
parents:
8240
diff
changeset
|
51 ;; has no mode line. |
7267 | 52 |
14123 | 53 ;; To enable or disable this mode, use M-x resize-minibuffer-mode. |
7267 | 54 |
55 ;;; Code: | |
56 | |
57 | |
17423
43e483167dd3
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16741
diff
changeset
|
58 (defgroup resize-minibuffer nil |
43e483167dd3
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16741
diff
changeset
|
59 "Dynamically resize minibuffer to display entire contents" |
43e483167dd3
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16741
diff
changeset
|
60 :group 'frames) |
43e483167dd3
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16741
diff
changeset
|
61 |
7267 | 62 |
63 ;;;###autoload | |
17423
43e483167dd3
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16741
diff
changeset
|
64 (defcustom resize-minibuffer-mode nil |
43e483167dd3
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16741
diff
changeset
|
65 "*If non-`nil', resize the minibuffer so its entire contents are visible." |
43e483167dd3
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16741
diff
changeset
|
66 :type 'boolean |
43e483167dd3
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16741
diff
changeset
|
67 :group 'resize-minibuffer) |
43e483167dd3
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16741
diff
changeset
|
68 |
43e483167dd3
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16741
diff
changeset
|
69 ;;;###autoload |
43e483167dd3
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16741
diff
changeset
|
70 (defcustom resize-minibuffer-window-max-height nil |
7267 | 71 "*Maximum size the minibuffer window is allowed to become. |
72 If less than 1 or not a number, the limit is the height of the frame in | |
17423
43e483167dd3
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16741
diff
changeset
|
73 which the active minibuffer window resides." |
43e483167dd3
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16741
diff
changeset
|
74 :type '(choice (const nil) integer) |
43e483167dd3
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16741
diff
changeset
|
75 :group 'resize-minibuffer) |
7267 | 76 |
77 ;;;###autoload | |
17423
43e483167dd3
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16741
diff
changeset
|
78 (defcustom resize-minibuffer-window-exactly t |
8012
df03bfa5b694
(resize-minibuffer-window-exactly, resize-minibuffer-frame,
Noah Friedman <friedman@splode.com>
parents:
7590
diff
changeset
|
79 "*Allow making minibuffer exactly the size to display all its contents. |
df03bfa5b694
(resize-minibuffer-window-exactly, resize-minibuffer-frame,
Noah Friedman <friedman@splode.com>
parents:
7590
diff
changeset
|
80 If `nil', the minibuffer window can temporarily increase in size but |
df03bfa5b694
(resize-minibuffer-window-exactly, resize-minibuffer-frame,
Noah Friedman <friedman@splode.com>
parents:
7590
diff
changeset
|
81 never get smaller while it is active. Any other value allows exact |
17423
43e483167dd3
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16741
diff
changeset
|
82 resizing." |
43e483167dd3
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16741
diff
changeset
|
83 :type 'boolean |
43e483167dd3
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16741
diff
changeset
|
84 :group 'resize-minibuffer) |
7267 | 85 |
86 ;;;###autoload | |
17423
43e483167dd3
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16741
diff
changeset
|
87 (defcustom resize-minibuffer-frame nil |
8012
df03bfa5b694
(resize-minibuffer-window-exactly, resize-minibuffer-frame,
Noah Friedman <friedman@splode.com>
parents:
7590
diff
changeset
|
88 "*Allow changing the frame height of minibuffer frames. |
df03bfa5b694
(resize-minibuffer-window-exactly, resize-minibuffer-frame,
Noah Friedman <friedman@splode.com>
parents:
7590
diff
changeset
|
89 If non-`nil' and the active minibuffer is the sole window in its frame, |
17423
43e483167dd3
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16741
diff
changeset
|
90 allow changing the frame height." |
43e483167dd3
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16741
diff
changeset
|
91 :type 'boolean |
43e483167dd3
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16741
diff
changeset
|
92 :group 'resize-minibuffer) |
7267 | 93 |
94 ;;;###autoload | |
17423
43e483167dd3
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16741
diff
changeset
|
95 (defcustom resize-minibuffer-frame-max-height nil |
7267 | 96 "*Maximum size the minibuffer frame is allowed to become. |
97 If less than 1 or not a number, there is no limit.") | |
98 | |
99 ;;;###autoload | |
17423
43e483167dd3
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16741
diff
changeset
|
100 (defcustom resize-minibuffer-frame-exactly t |
8012
df03bfa5b694
(resize-minibuffer-window-exactly, resize-minibuffer-frame,
Noah Friedman <friedman@splode.com>
parents:
7590
diff
changeset
|
101 "*Allow making minibuffer frame exactly the size to display all its contents. |
df03bfa5b694
(resize-minibuffer-window-exactly, resize-minibuffer-frame,
Noah Friedman <friedman@splode.com>
parents:
7590
diff
changeset
|
102 If `nil', the minibuffer frame can temporarily increase in size but |
df03bfa5b694
(resize-minibuffer-window-exactly, resize-minibuffer-frame,
Noah Friedman <friedman@splode.com>
parents:
7590
diff
changeset
|
103 never get smaller while it is active. Any other value allows exact |
17423
43e483167dd3
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16741
diff
changeset
|
104 resizing." |
43e483167dd3
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16741
diff
changeset
|
105 :type 'boolean |
43e483167dd3
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16741
diff
changeset
|
106 :group 'resize-minibuffer) |
8012
df03bfa5b694
(resize-minibuffer-window-exactly, resize-minibuffer-frame,
Noah Friedman <friedman@splode.com>
parents:
7590
diff
changeset
|
107 |
df03bfa5b694
(resize-minibuffer-window-exactly, resize-minibuffer-frame,
Noah Friedman <friedman@splode.com>
parents:
7590
diff
changeset
|
108 ;; Variable used to store the height of the minibuffer frame |
df03bfa5b694
(resize-minibuffer-window-exactly, resize-minibuffer-frame,
Noah Friedman <friedman@splode.com>
parents:
7590
diff
changeset
|
109 ;; on entry, so it can be restored on exit. It is made local before it is |
df03bfa5b694
(resize-minibuffer-window-exactly, resize-minibuffer-frame,
Noah Friedman <friedman@splode.com>
parents:
7590
diff
changeset
|
110 ;; modified. Do not use it yourself. |
df03bfa5b694
(resize-minibuffer-window-exactly, resize-minibuffer-frame,
Noah Friedman <friedman@splode.com>
parents:
7590
diff
changeset
|
111 (defvar resize-minibuffer-frame-original-height nil) |
7267 | 112 |
113 | |
114 ;;;###autoload | |
115 (defun resize-minibuffer-mode (&optional prefix) | |
116 "Enable or disable resize-minibuffer mode. | |
117 A negative prefix argument disables this mode. A positive argument or | |
118 argument of 0 enables it. | |
119 | |
120 When this minor mode is enabled, the minibuffer is dynamically resized to | |
121 contain the entire region of text put in it as you type. | |
122 | |
123 The variable `resize-minibuffer-mode' is set to t or nil depending on | |
124 whether this mode is active or not. | |
125 | |
126 The maximum height to which the minibuffer can grow is controlled by the | |
127 variable `resize-minibuffer-window-max-height'. | |
128 | |
129 The variable `resize-minibuffer-window-exactly' determines whether the | |
130 minibuffer window should ever be shrunk to make it no larger than needed to | |
131 display its contents. | |
132 | |
7512 | 133 When using a window system, it is possible for a minibuffer to be the sole |
7267 | 134 window in a frame. Since that window is already its maximum size, the only |
135 way to make more text visible at once is to increase the size of the frame. | |
136 The variable `resize-minibuffer-frame' controls whether this should be | |
137 done. The variables `resize-minibuffer-frame-max-height' and | |
138 `resize-minibuffer-frame-exactly' are analogous to their window | |
139 counterparts." | |
140 (interactive "p") | |
141 (or prefix (setq prefix 0)) | |
142 (cond | |
143 ((>= prefix 0) | |
144 (setq resize-minibuffer-mode t)) | |
145 (t | |
146 (setq resize-minibuffer-mode nil)))) | |
147 | |
148 (defun resize-minibuffer-setup () | |
149 (cond | |
150 (resize-minibuffer-mode | |
151 (cond | |
152 ((and window-system | |
153 (eq 'only (cdr (assq 'minibuffer (frame-parameters))))) | |
8240
363f719d47a5
(resize-minibuffer-setup): Copy post-command-hook when handling minibuffer
Noah Friedman <friedman@splode.com>
parents:
8226
diff
changeset
|
154 ;; Checking for resize-minibuffer-frame is done outside the cond |
363f719d47a5
(resize-minibuffer-setup): Copy post-command-hook when handling minibuffer
Noah Friedman <friedman@splode.com>
parents:
8226
diff
changeset
|
155 ;; predicate because that should always be t if this is a minibuffer |
363f719d47a5
(resize-minibuffer-setup): Copy post-command-hook when handling minibuffer
Noah Friedman <friedman@splode.com>
parents:
8226
diff
changeset
|
156 ;; frame; it just shouldn't do anything if this flag is nil. |
7267 | 157 (and resize-minibuffer-frame |
158 (progn | |
8240
363f719d47a5
(resize-minibuffer-setup): Copy post-command-hook when handling minibuffer
Noah Friedman <friedman@splode.com>
parents:
8226
diff
changeset
|
159 ;; Can't trust the height stored in minibuffer-frame-alist |
363f719d47a5
(resize-minibuffer-setup): Copy post-command-hook when handling minibuffer
Noah Friedman <friedman@splode.com>
parents:
8226
diff
changeset
|
160 ;; since the frame can be resized by the window manager and |
363f719d47a5
(resize-minibuffer-setup): Copy post-command-hook when handling minibuffer
Noah Friedman <friedman@splode.com>
parents:
8226
diff
changeset
|
161 ;; that variable isn't updated. |
8012
df03bfa5b694
(resize-minibuffer-window-exactly, resize-minibuffer-frame,
Noah Friedman <friedman@splode.com>
parents:
7590
diff
changeset
|
162 (make-local-variable 'resize-minibuffer-frame-original-height) |
df03bfa5b694
(resize-minibuffer-window-exactly, resize-minibuffer-frame,
Noah Friedman <friedman@splode.com>
parents:
7590
diff
changeset
|
163 (setq resize-minibuffer-frame-original-height (frame-height)) |
8240
363f719d47a5
(resize-minibuffer-setup): Copy post-command-hook when handling minibuffer
Noah Friedman <friedman@splode.com>
parents:
8226
diff
changeset
|
164 |
12762
b616982e679b
(resize-minibuffer-setup): Use make-local-hook.
Richard M. Stallman <rms@gnu.org>
parents:
11297
diff
changeset
|
165 (make-local-hook 'post-command-hook) |
b616982e679b
(resize-minibuffer-setup): Use make-local-hook.
Richard M. Stallman <rms@gnu.org>
parents:
11297
diff
changeset
|
166 (add-hook 'post-command-hook 'resize-minibuffer-frame 'append t) |
8240
363f719d47a5
(resize-minibuffer-setup): Copy post-command-hook when handling minibuffer
Noah Friedman <friedman@splode.com>
parents:
8226
diff
changeset
|
167 |
12762
b616982e679b
(resize-minibuffer-setup): Use make-local-hook.
Richard M. Stallman <rms@gnu.org>
parents:
11297
diff
changeset
|
168 (make-local-hook 'minibuffer-exit-hook) |
b616982e679b
(resize-minibuffer-setup): Use make-local-hook.
Richard M. Stallman <rms@gnu.org>
parents:
11297
diff
changeset
|
169 (add-hook 'minibuffer-exit-hook 'resize-minibuffer-frame-restore |
b616982e679b
(resize-minibuffer-setup): Use make-local-hook.
Richard M. Stallman <rms@gnu.org>
parents:
11297
diff
changeset
|
170 nil t) |
8240
363f719d47a5
(resize-minibuffer-setup): Copy post-command-hook when handling minibuffer
Noah Friedman <friedman@splode.com>
parents:
8226
diff
changeset
|
171 |
363f719d47a5
(resize-minibuffer-setup): Copy post-command-hook when handling minibuffer
Noah Friedman <friedman@splode.com>
parents:
8226
diff
changeset
|
172 (resize-minibuffer-frame)))) |
7267 | 173 (t |
174 (make-local-variable 'post-command-hook) | |
8240
363f719d47a5
(resize-minibuffer-setup): Copy post-command-hook when handling minibuffer
Noah Friedman <friedman@splode.com>
parents:
8226
diff
changeset
|
175 ;; Copy this because add-hook modifies the list structure. |
363f719d47a5
(resize-minibuffer-setup): Copy post-command-hook when handling minibuffer
Noah Friedman <friedman@splode.com>
parents:
8226
diff
changeset
|
176 (setq post-command-hook (copy-sequence post-command-hook)) |
8012
df03bfa5b694
(resize-minibuffer-window-exactly, resize-minibuffer-frame,
Noah Friedman <friedman@splode.com>
parents:
7590
diff
changeset
|
177 (add-hook 'post-command-hook 'resize-minibuffer-window 'append) |
8240
363f719d47a5
(resize-minibuffer-setup): Copy post-command-hook when handling minibuffer
Noah Friedman <friedman@splode.com>
parents:
8226
diff
changeset
|
178 |
8012
df03bfa5b694
(resize-minibuffer-window-exactly, resize-minibuffer-frame,
Noah Friedman <friedman@splode.com>
parents:
7590
diff
changeset
|
179 (make-local-variable 'minibuffer-exit-hook) |
8240
363f719d47a5
(resize-minibuffer-setup): Copy post-command-hook when handling minibuffer
Noah Friedman <friedman@splode.com>
parents:
8226
diff
changeset
|
180 (add-hook 'minibuffer-exit-hook 'resize-minibuffer-window-restore) |
363f719d47a5
(resize-minibuffer-setup): Copy post-command-hook when handling minibuffer
Noah Friedman <friedman@splode.com>
parents:
8226
diff
changeset
|
181 |
363f719d47a5
(resize-minibuffer-setup): Copy post-command-hook when handling minibuffer
Noah Friedman <friedman@splode.com>
parents:
8226
diff
changeset
|
182 (resize-minibuffer-window)))))) |
7267 | 183 |
184 (defun resize-minibuffer-count-window-lines (&optional start end) | |
185 "Return number of window lines occupied by text in region. | |
186 The number of window lines may be greater than the number of actual lines | |
187 in the buffer if any wrap on the display due to their length. | |
188 | |
189 Optional arguments START and END default to point-min and point-max, | |
190 respectively." | |
191 (or start (setq start (point-min))) | |
192 (or end (setq end (point-max))) | |
193 (if (= start end) | |
194 0 | |
195 (save-excursion | |
196 (save-restriction | |
197 (widen) | |
198 (narrow-to-region start end) | |
199 (goto-char start) | |
200 (vertical-motion (buffer-size)))))) | |
201 | |
202 | |
203 ;; Resize the minibuffer window to contain the minibuffer's contents. | |
204 (defun resize-minibuffer-window () | |
11297
056c7266a614
(resize-minibuffer-window): Make sure minibuffer window is selected.
Noah Friedman <friedman@splode.com>
parents:
8240
diff
changeset
|
205 (and (eq (selected-window) (minibuffer-window)) |
056c7266a614
(resize-minibuffer-window): Make sure minibuffer window is selected.
Noah Friedman <friedman@splode.com>
parents:
8240
diff
changeset
|
206 (let ((height (window-height)) |
056c7266a614
(resize-minibuffer-window): Make sure minibuffer window is selected.
Noah Friedman <friedman@splode.com>
parents:
8240
diff
changeset
|
207 (lines (1+ (resize-minibuffer-count-window-lines)))) |
056c7266a614
(resize-minibuffer-window): Make sure minibuffer window is selected.
Noah Friedman <friedman@splode.com>
parents:
8240
diff
changeset
|
208 (and (numberp resize-minibuffer-window-max-height) |
056c7266a614
(resize-minibuffer-window): Make sure minibuffer window is selected.
Noah Friedman <friedman@splode.com>
parents:
8240
diff
changeset
|
209 (> resize-minibuffer-window-max-height 0) |
056c7266a614
(resize-minibuffer-window): Make sure minibuffer window is selected.
Noah Friedman <friedman@splode.com>
parents:
8240
diff
changeset
|
210 (setq lines (min lines resize-minibuffer-window-max-height))) |
056c7266a614
(resize-minibuffer-window): Make sure minibuffer window is selected.
Noah Friedman <friedman@splode.com>
parents:
8240
diff
changeset
|
211 (or (if resize-minibuffer-window-exactly |
056c7266a614
(resize-minibuffer-window): Make sure minibuffer window is selected.
Noah Friedman <friedman@splode.com>
parents:
8240
diff
changeset
|
212 (= lines height) |
056c7266a614
(resize-minibuffer-window): Make sure minibuffer window is selected.
Noah Friedman <friedman@splode.com>
parents:
8240
diff
changeset
|
213 (<= lines height)) |
056c7266a614
(resize-minibuffer-window): Make sure minibuffer window is selected.
Noah Friedman <friedman@splode.com>
parents:
8240
diff
changeset
|
214 (enlarge-window (- lines height)))))) |
7267 | 215 |
8012
df03bfa5b694
(resize-minibuffer-window-exactly, resize-minibuffer-frame,
Noah Friedman <friedman@splode.com>
parents:
7590
diff
changeset
|
216 ;; This resizes the minibuffer back to one line as soon as it is exited |
df03bfa5b694
(resize-minibuffer-window-exactly, resize-minibuffer-frame,
Noah Friedman <friedman@splode.com>
parents:
7590
diff
changeset
|
217 ;; (e.g. when the user hits RET). This way, subsequent messages put in the |
df03bfa5b694
(resize-minibuffer-window-exactly, resize-minibuffer-frame,
Noah Friedman <friedman@splode.com>
parents:
7590
diff
changeset
|
218 ;; echo area aren't cluttered with leftover minibuffer text. |
df03bfa5b694
(resize-minibuffer-window-exactly, resize-minibuffer-frame,
Noah Friedman <friedman@splode.com>
parents:
7590
diff
changeset
|
219 ;; It should be called by minibuffer-exit-hook. |
df03bfa5b694
(resize-minibuffer-window-exactly, resize-minibuffer-frame,
Noah Friedman <friedman@splode.com>
parents:
7590
diff
changeset
|
220 ;; |
df03bfa5b694
(resize-minibuffer-window-exactly, resize-minibuffer-frame,
Noah Friedman <friedman@splode.com>
parents:
7590
diff
changeset
|
221 ;; Note that because it calls sit-for to force a screen update, strange |
df03bfa5b694
(resize-minibuffer-window-exactly, resize-minibuffer-frame,
Noah Friedman <friedman@splode.com>
parents:
7590
diff
changeset
|
222 ;; things may happen in the minibuffer, such as unexpanded partial |
df03bfa5b694
(resize-minibuffer-window-exactly, resize-minibuffer-frame,
Noah Friedman <friedman@splode.com>
parents:
7590
diff
changeset
|
223 ;; completions by complete.el showing their completion. |
df03bfa5b694
(resize-minibuffer-window-exactly, resize-minibuffer-frame,
Noah Friedman <friedman@splode.com>
parents:
7590
diff
changeset
|
224 ;; If this bothers you, just redefine this function to do nothing, in, say, |
df03bfa5b694
(resize-minibuffer-window-exactly, resize-minibuffer-frame,
Noah Friedman <friedman@splode.com>
parents:
7590
diff
changeset
|
225 ;; your after-load-alist. Perhaps there should be an option variable, |
df03bfa5b694
(resize-minibuffer-window-exactly, resize-minibuffer-frame,
Noah Friedman <friedman@splode.com>
parents:
7590
diff
changeset
|
226 ;; but I don't know if there's really any demand for it. |
df03bfa5b694
(resize-minibuffer-window-exactly, resize-minibuffer-frame,
Noah Friedman <friedman@splode.com>
parents:
7590
diff
changeset
|
227 ;; (Clobbering this definition is harmless because eventually emacs restores |
df03bfa5b694
(resize-minibuffer-window-exactly, resize-minibuffer-frame,
Noah Friedman <friedman@splode.com>
parents:
7590
diff
changeset
|
228 ;; its idea of the minibuffer window size when the minibuffer isn't in use |
df03bfa5b694
(resize-minibuffer-window-exactly, resize-minibuffer-frame,
Noah Friedman <friedman@splode.com>
parents:
7590
diff
changeset
|
229 ;; anyway; this is just a kludge because of the timing for that update). |
df03bfa5b694
(resize-minibuffer-window-exactly, resize-minibuffer-frame,
Noah Friedman <friedman@splode.com>
parents:
7590
diff
changeset
|
230 (defun resize-minibuffer-window-restore () |
8093
1978838b7b6f
(resize-minibuffer-window-restore): Don't do anything if the window height
Noah Friedman <friedman@splode.com>
parents:
8012
diff
changeset
|
231 (cond |
11297
056c7266a614
(resize-minibuffer-window): Make sure minibuffer window is selected.
Noah Friedman <friedman@splode.com>
parents:
8240
diff
changeset
|
232 ((not (eq (minibuffer-window) (selected-window)))) |
8093
1978838b7b6f
(resize-minibuffer-window-restore): Don't do anything if the window height
Noah Friedman <friedman@splode.com>
parents:
8012
diff
changeset
|
233 ((> (window-height) 1) |
1978838b7b6f
(resize-minibuffer-window-restore): Don't do anything if the window height
Noah Friedman <friedman@splode.com>
parents:
8012
diff
changeset
|
234 (enlarge-window (- 1 (window-height))) |
1978838b7b6f
(resize-minibuffer-window-restore): Don't do anything if the window height
Noah Friedman <friedman@splode.com>
parents:
8012
diff
changeset
|
235 (sit-for 0)))) |
8012
df03bfa5b694
(resize-minibuffer-window-exactly, resize-minibuffer-frame,
Noah Friedman <friedman@splode.com>
parents:
7590
diff
changeset
|
236 |
7267 | 237 |
238 ;; Resize the minibuffer frame to contain the minibuffer's contents. | |
239 ;; The minibuffer frame must be the current frame. | |
240 (defun resize-minibuffer-frame () | |
241 (let ((height (frame-height)) | |
242 (lines (1+ (resize-minibuffer-count-window-lines)))) | |
243 (and (numberp resize-minibuffer-frame-max-height) | |
244 (> resize-minibuffer-frame-max-height 0) | |
245 (setq lines (min lines resize-minibuffer-frame-max-height))) | |
246 (cond | |
247 ((> lines height) | |
16597
ebdcc5509856
(resize-minibuffer-frame): Don't assume minibuffer frame is selected.
Karl Heuer <kwzh@gnu.org>
parents:
16577
diff
changeset
|
248 (set-frame-size (window-frame (minibuffer-window)) (frame-width) lines)) |
7267 | 249 ((and resize-minibuffer-frame-exactly |
8012
df03bfa5b694
(resize-minibuffer-window-exactly, resize-minibuffer-frame,
Noah Friedman <friedman@splode.com>
parents:
7590
diff
changeset
|
250 (> height resize-minibuffer-frame-original-height) |
7267 | 251 (< lines height)) |
16597
ebdcc5509856
(resize-minibuffer-frame): Don't assume minibuffer frame is selected.
Karl Heuer <kwzh@gnu.org>
parents:
16577
diff
changeset
|
252 (set-frame-size (window-frame (minibuffer-window)) |
ebdcc5509856
(resize-minibuffer-frame): Don't assume minibuffer frame is selected.
Karl Heuer <kwzh@gnu.org>
parents:
16577
diff
changeset
|
253 (frame-width) lines))))) |
7267 | 254 |
255 ;; Restore the original height of the frame. | |
8012
df03bfa5b694
(resize-minibuffer-window-exactly, resize-minibuffer-frame,
Noah Friedman <friedman@splode.com>
parents:
7590
diff
changeset
|
256 ;; resize-minibuffer-frame-original-height is set in |
df03bfa5b694
(resize-minibuffer-window-exactly, resize-minibuffer-frame,
Noah Friedman <friedman@splode.com>
parents:
7590
diff
changeset
|
257 ;; resize-minibuffer-setup. |
7267 | 258 (defun resize-minibuffer-frame-restore () |
16577
15cf729665be
(resize-minibuffer-frame-restore): Don't assume
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
259 (set-frame-size (window-frame (minibuffer-window)) |
7267 | 260 (frame-width) |
8012
df03bfa5b694
(resize-minibuffer-window-exactly, resize-minibuffer-frame,
Noah Friedman <friedman@splode.com>
parents:
7590
diff
changeset
|
261 resize-minibuffer-frame-original-height)) |
7267 | 262 |
263 | |
264 (provide 'rsz-mini) | |
265 | |
266 (add-hook 'minibuffer-setup-hook 'resize-minibuffer-setup) | |
7590
e70581cde056
Enable resize-minibuffer-mode when this file is loaded.
Noah Friedman <friedman@splode.com>
parents:
7512
diff
changeset
|
267 (resize-minibuffer-mode) |
7267 | 268 |
269 ;; rsz-mini.el ends here |