annotate lisp/modes/rsz-minibuf.el @ 194:2947057885e5

Added tag r20-3b23 for changeset f53b5ca2e663
author cvs
date Mon, 13 Aug 2007 09:58:32 +0200
parents 489f57a838ef
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; rsz-minibuf.el --- dynamically resize minibuffer to display entire contents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 134
diff changeset
3 ;; Copyright (C) 1990 Roland McGrath
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 134
diff changeset
4 ;; Copyright (C) 1993, 1994 Noah S. Friedman
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 134
diff changeset
6 ;; Author: Noah Friedman <friedman@prep.ai.mit.edu>
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 134
diff changeset
7 ;; Author: Roland McGrath <roland@prep.ai.mit.edu>
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 134
diff changeset
8 ;; Modified for Lucid Emacs By: Peter Stout <pds@cs.cmu.edu>
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 134
diff changeset
9 ;; Maintainer: friedman@prep.ai.mit.edu
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 134
diff changeset
10 ;; Keywords: minibuffer, window, frames, display
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 134
diff changeset
12 ;; This file is part of XEmacs.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 134
diff changeset
14 ;; XEmacs is free software; you can redistribute it and/or modify it
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 134
diff changeset
15 ;; under the terms of the GNU General Public License as published by
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 134
diff changeset
16 ;; the Free Software Foundation; either version 2, or (at your option)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 134
diff changeset
17 ;; any later version.
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 134
diff changeset
18
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 134
diff changeset
19 ;; XEmacs is distributed in the hope that it will be useful, but
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 134
diff changeset
20 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 134
diff changeset
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 134
diff changeset
22 ;; General Public License for more details.
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 134
diff changeset
23
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 134
diff changeset
24 ;; You should have received a copy of the GNU General Public License
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 134
diff changeset
25 ;; along with XEmacs; see the file COPYING. If not, you can either
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 134
diff changeset
26 ;; send email to this program's maintainer or write to: The Free
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 134
diff changeset
27 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 134
diff changeset
28 ;; 02111-1307, USA.
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 134
diff changeset
29
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 134
diff changeset
30 ;;; Synched up with: Not synched.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 134
diff changeset
34 ;; This file has received maintenance by the XEmacs development team.
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 134
diff changeset
35
189
489f57a838ef Import from CVS: tag r20-3b21
cvs
parents: 165
diff changeset
36 ;; $Id: rsz-minibuf.el,v 1.6 1997/09/17 05:19:26 steve Exp $
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 134
diff changeset
38 ;; This package allows the entire contents (or as much as possible) of the
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 134
diff changeset
39 ;; minibuffer to be visible at once when typing. As the end of a line is
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 134
diff changeset
40 ;; reached, the minibuffer will resize itself. When the user is done
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 134
diff changeset
41 ;; typing, the minibuffer will return to its original size.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 134
diff changeset
43 ;; In window systems where it is possible to have a frame in which the
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 134
diff changeset
44 ;; minibuffer is the only window, the frame itself can be resized. In FSF
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 134
diff changeset
45 ;; GNU Emacs 19.22 and earlier, the frame may not be properly returned to
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 134
diff changeset
46 ;; its original size after it ceases to be active because
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 134
diff changeset
47 ;; `minibuffer-exit-hook' didn't exist until version 19.23.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 134
diff changeset
49 ;; NOTE: The code to resize frames has not been tested under Lucid Emacs,
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 134
diff changeset
50 ;; because detached minibuffers are broken.
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 134
diff changeset
51
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 134
diff changeset
52 ;; Note that the minibuffer and echo area are not the same! They simply
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 134
diff changeset
53 ;; happen to occupy roughly the same place on the frame. Messages put in
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 134
diff changeset
54 ;; the echo area will not cause any resizing by this package.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 134
diff changeset
56 ;; This package is considered a minor mode but it doesn't put anything in
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 134
diff changeset
57 ;; minor-mode-alist because this mode is specific to the minibuffer, which
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 134
diff changeset
58 ;; has no modeline.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 134
diff changeset
60 ;; To use this package, put the following in your .emacs:
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 134
diff changeset
61 ;;
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 134
diff changeset
62 ;; (autoload 'resize-minibuffer-mode "rsz-minibuf" nil t)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 134
diff changeset
63 ;;
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 134
diff changeset
64 ;; Invoking the command `resize-minibuffer-mode' will then enable this mode.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 108
diff changeset
69
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 108
diff changeset
70 (defgroup resize-minibuffer nil
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 108
diff changeset
71 "Dynamically resize minibuffer to display entire contents"
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 108
diff changeset
72 :group 'frames)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 108
diff changeset
73
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 108
diff changeset
74
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 108
diff changeset
75 (defcustom resize-minibuffer-mode nil
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 108
diff changeset
76 "*If non-`nil', resize the minibuffer so its entire contents are visible."
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 108
diff changeset
77 :type 'boolean
189
489f57a838ef Import from CVS: tag r20-3b21
cvs
parents: 165
diff changeset
78 :require 'rsz-minibuf
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 108
diff changeset
79 :group 'resize-minibuffer)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 108
diff changeset
81 (defcustom resize-minibuffer-window-max-height nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 "*Maximum size the minibuffer window is allowed to become.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 If less than 1 or not a number, the limit is the height of the frame in
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 108
diff changeset
84 which the active minibuffer window resides."
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 108
diff changeset
85 :type '(choice (const nil) integer)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 108
diff changeset
86 :group 'resize-minibuffer)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 108
diff changeset
88 (defcustom resize-minibuffer-window-exactly t
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 "*If non-`nil', make minibuffer exactly the size needed to display all its contents.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 Otherwise, the minibuffer window can temporarily increase in size but
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 108
diff changeset
91 never get smaller while it is active."
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 108
diff changeset
92 :type 'boolean
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 108
diff changeset
93 :group 'resize-minibuffer)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 108
diff changeset
96 (defcustom resize-minibuffer-frame nil
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 108
diff changeset
97 "*If non-`nil' and the active minibuffer is the sole window in its frame, allow changing the frame height."
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 108
diff changeset
98 :type 'boolean
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 108
diff changeset
99 :group 'resize-minibuffer)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 108
diff changeset
101 (defcustom resize-minibuffer-frame-max-height nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 "*Maximum size the minibuffer frame is allowed to become.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 If less than 1 or not a number, there is no limit.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 108
diff changeset
105 (defcustom resize-minibuffer-frame-exactly nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 "*If non-`nil', make minibuffer frame exactly the size needed to display all its contents.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 Otherwise, the minibuffer frame can temporarily increase in size but
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 108
diff changeset
108 never get smaller while it is active."
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 108
diff changeset
109 :type 'boolean
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 108
diff changeset
110 :group 'resize-minibuffer)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (defun resize-minibuffer-mode (&optional prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 "Enable or disable resize-minibuffer mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 A negative prefix argument disables this mode. A positive argument or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 argument of 0 enables it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 When this minor mode is enabled, the minibuffer is dynamically resized to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 contain the entire region of text put in it as you type.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 The variable `resize-minibuffer-mode' is set to t or nil depending on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 whether this mode is active or not.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 The maximum height to which the minibuffer can grow is controlled by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 variable `resize-minibuffer-window-max-height'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 The variable `resize-minibuffer-window-exactly' determines whether the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 minibuffer window should ever be shrunk to make it no larger than needed to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 display its contents.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 82
diff changeset
132 When using a window system, it is possible for a minibuffer to be the sole
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 window in a frame. Since that window is already its maximum size, the only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 way to make more text visible at once is to increase the size of the frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 The variable `resize-minibuffer-frame' controls whether this should be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 done. The variables `resize-minibuffer-frame-max-height' and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 `resize-minibuffer-frame-exactly' are analogous to their window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 counterparts."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (or prefix (setq prefix 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 ((>= prefix 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (setq resize-minibuffer-mode t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (setq resize-minibuffer-mode nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (defun resize-minibuffer-setup ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (resize-minibuffer-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 ((and (not (eq 'tty (console-type)))
189
489f57a838ef Import from CVS: tag r20-3b21
cvs
parents: 165
diff changeset
152 (eq 'only (plist-get (frame-properties) 'minibuffer)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (and resize-minibuffer-frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (make-local-hook 'minibuffer-exit-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (add-hook 'minibuffer-exit-hook 'resize-minibuffer-frame-restore
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (make-local-hook 'post-command-hook)
82
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 70
diff changeset
159 (add-hook 'post-command-hook 'resize-minibuffer-frame nil t)
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 70
diff changeset
160 (unless (and (boundp 'icomplete-mode)
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 70
diff changeset
161 icomplete-mode)
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 70
diff changeset
162 (resize-minibuffer-frame)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (make-local-hook 'post-command-hook)
82
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 70
diff changeset
165 (add-hook 'post-command-hook 'resize-minibuffer-window nil t)
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 70
diff changeset
166 (unless (and (boundp 'icomplete-mode)
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 70
diff changeset
167 icomplete-mode)
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 70
diff changeset
168 (resize-minibuffer-window)))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (defun resize-minibuffer-count-window-lines (&optional start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 "Return number of window lines occupied by text in region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 The number of window lines may be greater than the number of actual lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 in the buffer if any wrap on the display due to their length.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 Optional arguments START and END default to point-min and point-max,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 respectively."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (or start (setq start (point-min)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (or end (setq end (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (if (= start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (narrow-to-region start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (vertical-motion (buffer-size))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 ;; Resize the minibuffer window to contain the minibuffer's contents.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 ;; The minibuffer must be the current window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (defun resize-minibuffer-window ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (let ((height (window-height))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (lines (1+ (resize-minibuffer-count-window-lines))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (and (numberp resize-minibuffer-window-max-height)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (> resize-minibuffer-window-max-height 0)
189
489f57a838ef Import from CVS: tag r20-3b21
cvs
parents: 165
diff changeset
196 (setq lines (min
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 resize-minibuffer-window-max-height)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (or (if resize-minibuffer-window-exactly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (= lines height)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (<= lines height))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (enlarge-window (- lines height)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 ;; Resize the minibuffer frame to contain the minibuffer's contents.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 ;; The minibuffer frame must be the current frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (defun resize-minibuffer-frame ()
189
489f57a838ef Import from CVS: tag r20-3b21
cvs
parents: 165
diff changeset
208 (let ((height (frame-height))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (lines (1+ (resize-minibuffer-count-window-lines))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (and (numberp resize-minibuffer-frame-max-height)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (> resize-minibuffer-frame-max-height 0)
189
489f57a838ef Import from CVS: tag r20-3b21
cvs
parents: 165
diff changeset
212 (setq lines (min
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 resize-minibuffer-frame-max-height)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 ((> lines height)
189
489f57a838ef Import from CVS: tag r20-3b21
cvs
parents: 165
diff changeset
217 (set-frame-size (selected-frame) (frame-width) lines))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 ((and resize-minibuffer-frame-exactly
189
489f57a838ef Import from CVS: tag r20-3b21
cvs
parents: 165
diff changeset
219 (> height (plist-get minibuffer-frame-plist 'height))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (< lines height))
189
489f57a838ef Import from CVS: tag r20-3b21
cvs
parents: 165
diff changeset
221 (set-frame-size (selected-frame) (frame-width) lines)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 ;; Restore the original height of the frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (defun resize-minibuffer-frame-restore ()
189
489f57a838ef Import from CVS: tag r20-3b21
cvs
parents: 165
diff changeset
225 (set-frame-size (selected-frame) (frame-width)
489f57a838ef Import from CVS: tag r20-3b21
cvs
parents: 165
diff changeset
226 (plist-get minibuffer-frame-plist 'height)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (provide 'rsz-minibuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (add-hook 'minibuffer-setup-hook 'resize-minibuffer-setup)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 134
diff changeset
233 ;;; rsz-minibuf.el ends here