annotate lisp/rsz-mini.el @ 16806:9694822642a7

Use $EMACS to say where to run Emacs. Add --no-update option. (copying src): Check thoroughly for symlinks and copy them in all cases. Regularize the linking of *.in and *.opt and ChangeLog files. (copying lib-src): Likewise. Don't rm getdate.c or y.tab.*--they don't exist any more.
author Richard M. Stallman <rms@gnu.org>
date Thu, 02 Jan 1997 00:53:34 +0000
parents e4e15030dad3
children 43e483167dd3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1 ;;; rsz-mini.el --- dynamically resize minibuffer to display entire contents
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10 ;; This file is part of GNU Emacs.
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 ;; the Free Software Foundation; either version 2, or (at your option)
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 ;; any later version.
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 ;; GNU General Public License for more details.
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14123
diff changeset
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14123
diff changeset
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14123
diff changeset
25 ;; Boston, MA 02111-1307, USA.
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 ;;; Commentary:
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
e4e15030dad3 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 16616
diff changeset
35 ;; minibuffer is the only window, the frame itself can be resized. In
e4e15030dad3 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 16616
diff changeset
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
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52
14123
e2d46e16a1ce Comment fixes.
Karl Heuer <kwzh@gnu.org>
parents: 12762
diff changeset
53 ;; To enable or disable this mode, use M-x resize-minibuffer-mode.
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55 ;;; Code:
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 ;;;###autoload
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59 (defvar resize-minibuffer-mode nil
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 "*If non-`nil', resize the minibuffer so its entire contents are visible.")
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62 ;;;###autoload
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 (defvar resize-minibuffer-window-max-height nil
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 "*Maximum size the minibuffer window is allowed to become.
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 If less than 1 or not a number, the limit is the height of the frame in
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 which the active minibuffer window resides.")
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 ;;;###autoload
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 (defvar resize-minibuffer-window-exactly t
8012
df03bfa5b694 (resize-minibuffer-window-exactly, resize-minibuffer-frame,
Noah Friedman <friedman@splode.com>
parents: 7590
diff changeset
70 "*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
71 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
72 never get smaller while it is active. Any other value allows exact
df03bfa5b694 (resize-minibuffer-window-exactly, resize-minibuffer-frame,
Noah Friedman <friedman@splode.com>
parents: 7590
diff changeset
73 resizing.")
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 ;;;###autoload
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 (defvar resize-minibuffer-frame nil
8012
df03bfa5b694 (resize-minibuffer-window-exactly, resize-minibuffer-frame,
Noah Friedman <friedman@splode.com>
parents: 7590
diff changeset
77 "*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
78 If non-`nil' and the active minibuffer is the sole window in its frame,
df03bfa5b694 (resize-minibuffer-window-exactly, resize-minibuffer-frame,
Noah Friedman <friedman@splode.com>
parents: 7590
diff changeset
79 allow changing the frame height.")
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 ;;;###autoload
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 (defvar resize-minibuffer-frame-max-height nil
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83 "*Maximum size the minibuffer frame is allowed to become.
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 If less than 1 or not a number, there is no limit.")
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86 ;;;###autoload
8012
df03bfa5b694 (resize-minibuffer-window-exactly, resize-minibuffer-frame,
Noah Friedman <friedman@splode.com>
parents: 7590
diff changeset
87 (defvar resize-minibuffer-frame-exactly t
df03bfa5b694 (resize-minibuffer-window-exactly, resize-minibuffer-frame,
Noah Friedman <friedman@splode.com>
parents: 7590
diff changeset
88 "*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
89 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
90 never get smaller while it is active. Any other value allows exact
df03bfa5b694 (resize-minibuffer-window-exactly, resize-minibuffer-frame,
Noah Friedman <friedman@splode.com>
parents: 7590
diff changeset
91 resizing.")
df03bfa5b694 (resize-minibuffer-window-exactly, resize-minibuffer-frame,
Noah Friedman <friedman@splode.com>
parents: 7590
diff changeset
92
df03bfa5b694 (resize-minibuffer-window-exactly, resize-minibuffer-frame,
Noah Friedman <friedman@splode.com>
parents: 7590
diff changeset
93 ;; 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
94 ;; 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
95 ;; modified. Do not use it yourself.
df03bfa5b694 (resize-minibuffer-window-exactly, resize-minibuffer-frame,
Noah Friedman <friedman@splode.com>
parents: 7590
diff changeset
96 (defvar resize-minibuffer-frame-original-height nil)
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99 ;;;###autoload
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100 (defun resize-minibuffer-mode (&optional prefix)
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101 "Enable or disable resize-minibuffer mode.
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 A negative prefix argument disables this mode. A positive argument or
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 argument of 0 enables it.
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105 When this minor mode is enabled, the minibuffer is dynamically resized to
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 contain the entire region of text put in it as you type.
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 The variable `resize-minibuffer-mode' is set to t or nil depending on
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 whether this mode is active or not.
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111 The maximum height to which the minibuffer can grow is controlled by the
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112 variable `resize-minibuffer-window-max-height'.
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 The variable `resize-minibuffer-window-exactly' determines whether the
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115 minibuffer window should ever be shrunk to make it no larger than needed to
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116 display its contents.
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117
7512
d72443e51f84 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 7267
diff changeset
118 When using a window system, it is possible for a minibuffer to be the sole
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 window in a frame. Since that window is already its maximum size, the only
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 way to make more text visible at once is to increase the size of the frame.
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 The variable `resize-minibuffer-frame' controls whether this should be
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 done. The variables `resize-minibuffer-frame-max-height' and
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 `resize-minibuffer-frame-exactly' are analogous to their window
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124 counterparts."
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 (interactive "p")
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 (or prefix (setq prefix 0))
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 (cond
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 ((>= prefix 0)
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129 (setq resize-minibuffer-mode t))
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 (t
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131 (setq resize-minibuffer-mode nil))))
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133 (defun resize-minibuffer-setup ()
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134 (cond
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135 (resize-minibuffer-mode
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136 (cond
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 ((and window-system
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 (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
139 ;; 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
140 ;; 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
141 ;; frame; it just shouldn't do anything if this flag is nil.
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142 (and resize-minibuffer-frame
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143 (progn
8240
363f719d47a5 (resize-minibuffer-setup): Copy post-command-hook when handling minibuffer
Noah Friedman <friedman@splode.com>
parents: 8226
diff changeset
144 ;; 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
145 ;; 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
146 ;; that variable isn't updated.
8012
df03bfa5b694 (resize-minibuffer-window-exactly, resize-minibuffer-frame,
Noah Friedman <friedman@splode.com>
parents: 7590
diff changeset
147 (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
148 (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
149
12762
b616982e679b (resize-minibuffer-setup): Use make-local-hook.
Richard M. Stallman <rms@gnu.org>
parents: 11297
diff changeset
150 (make-local-hook 'post-command-hook)
b616982e679b (resize-minibuffer-setup): Use make-local-hook.
Richard M. Stallman <rms@gnu.org>
parents: 11297
diff changeset
151 (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
152
12762
b616982e679b (resize-minibuffer-setup): Use make-local-hook.
Richard M. Stallman <rms@gnu.org>
parents: 11297
diff changeset
153 (make-local-hook 'minibuffer-exit-hook)
b616982e679b (resize-minibuffer-setup): Use make-local-hook.
Richard M. Stallman <rms@gnu.org>
parents: 11297
diff changeset
154 (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
155 nil t)
8240
363f719d47a5 (resize-minibuffer-setup): Copy post-command-hook when handling minibuffer
Noah Friedman <friedman@splode.com>
parents: 8226
diff changeset
156
363f719d47a5 (resize-minibuffer-setup): Copy post-command-hook when handling minibuffer
Noah Friedman <friedman@splode.com>
parents: 8226
diff changeset
157 (resize-minibuffer-frame))))
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
158 (t
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159 (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
160 ;; 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
161 (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
162 (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
163
8012
df03bfa5b694 (resize-minibuffer-window-exactly, resize-minibuffer-frame,
Noah Friedman <friedman@splode.com>
parents: 7590
diff changeset
164 (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
165 (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
166
363f719d47a5 (resize-minibuffer-setup): Copy post-command-hook when handling minibuffer
Noah Friedman <friedman@splode.com>
parents: 8226
diff changeset
167 (resize-minibuffer-window))))))
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
168
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
169 (defun resize-minibuffer-count-window-lines (&optional start end)
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
170 "Return number of window lines occupied by text in region.
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
171 The number of window lines may be greater than the number of actual lines
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
172 in the buffer if any wrap on the display due to their length.
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
173
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
174 Optional arguments START and END default to point-min and point-max,
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175 respectively."
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176 (or start (setq start (point-min)))
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177 (or end (setq end (point-max)))
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178 (if (= start end)
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179 0
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
180 (save-excursion
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181 (save-restriction
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182 (widen)
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183 (narrow-to-region start end)
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184 (goto-char start)
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 (vertical-motion (buffer-size))))))
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188 ;; Resize the minibuffer window to contain the minibuffer's contents.
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189 (defun resize-minibuffer-window ()
11297
056c7266a614 (resize-minibuffer-window): Make sure minibuffer window is selected.
Noah Friedman <friedman@splode.com>
parents: 8240
diff changeset
190 (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
191 (let ((height (window-height))
056c7266a614 (resize-minibuffer-window): Make sure minibuffer window is selected.
Noah Friedman <friedman@splode.com>
parents: 8240
diff changeset
192 (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
193 (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
194 (> 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
195 (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
196 (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
197 (= lines height)
056c7266a614 (resize-minibuffer-window): Make sure minibuffer window is selected.
Noah Friedman <friedman@splode.com>
parents: 8240
diff changeset
198 (<= lines height))
056c7266a614 (resize-minibuffer-window): Make sure minibuffer window is selected.
Noah Friedman <friedman@splode.com>
parents: 8240
diff changeset
199 (enlarge-window (- lines height))))))
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200
8012
df03bfa5b694 (resize-minibuffer-window-exactly, resize-minibuffer-frame,
Noah Friedman <friedman@splode.com>
parents: 7590
diff changeset
201 ;; 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
202 ;; (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
203 ;; 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
204 ;; 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
205 ;;
df03bfa5b694 (resize-minibuffer-window-exactly, resize-minibuffer-frame,
Noah Friedman <friedman@splode.com>
parents: 7590
diff changeset
206 ;; 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
207 ;; 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
208 ;; completions by complete.el showing their completion.
df03bfa5b694 (resize-minibuffer-window-exactly, resize-minibuffer-frame,
Noah Friedman <friedman@splode.com>
parents: 7590
diff changeset
209 ;; 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
210 ;; 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
211 ;; 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
212 ;; (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
213 ;; 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
214 ;; 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
215 (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
216 (cond
11297
056c7266a614 (resize-minibuffer-window): Make sure minibuffer window is selected.
Noah Friedman <friedman@splode.com>
parents: 8240
diff changeset
217 ((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
218 ((> (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
219 (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
220 (sit-for 0))))
8012
df03bfa5b694 (resize-minibuffer-window-exactly, resize-minibuffer-frame,
Noah Friedman <friedman@splode.com>
parents: 7590
diff changeset
221
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
222
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
223 ;; Resize the minibuffer frame to contain the minibuffer's contents.
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
224 ;; The minibuffer frame must be the current frame.
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
225 (defun resize-minibuffer-frame ()
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
226 (let ((height (frame-height))
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
227 (lines (1+ (resize-minibuffer-count-window-lines))))
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
228 (and (numberp resize-minibuffer-frame-max-height)
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
229 (> resize-minibuffer-frame-max-height 0)
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
230 (setq lines (min lines resize-minibuffer-frame-max-height)))
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
231 (cond
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
232 ((> lines height)
16597
ebdcc5509856 (resize-minibuffer-frame): Don't assume minibuffer frame is selected.
Karl Heuer <kwzh@gnu.org>
parents: 16577
diff changeset
233 (set-frame-size (window-frame (minibuffer-window)) (frame-width) lines))
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
234 ((and resize-minibuffer-frame-exactly
8012
df03bfa5b694 (resize-minibuffer-window-exactly, resize-minibuffer-frame,
Noah Friedman <friedman@splode.com>
parents: 7590
diff changeset
235 (> height resize-minibuffer-frame-original-height)
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
236 (< lines height))
16597
ebdcc5509856 (resize-minibuffer-frame): Don't assume minibuffer frame is selected.
Karl Heuer <kwzh@gnu.org>
parents: 16577
diff changeset
237 (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
238 (frame-width) lines)))))
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
239
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
240 ;; 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
241 ;; 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
242 ;; resize-minibuffer-setup.
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
243 (defun resize-minibuffer-frame-restore ()
16577
15cf729665be (resize-minibuffer-frame-restore): Don't assume
Karl Heuer <kwzh@gnu.org>
parents: 14169
diff changeset
244 (set-frame-size (window-frame (minibuffer-window))
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
245 (frame-width)
8012
df03bfa5b694 (resize-minibuffer-window-exactly, resize-minibuffer-frame,
Noah Friedman <friedman@splode.com>
parents: 7590
diff changeset
246 resize-minibuffer-frame-original-height))
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
247
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
248
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
249 (provide 'rsz-mini)
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
250
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
251 (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
252 (resize-minibuffer-mode)
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
253
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
254 ;; rsz-mini.el ends here