annotate lisp/electric.el @ 15794:c741a26258ce

Fix previous change.
author Richard M. Stallman <rms@gnu.org>
date Sun, 28 Jul 1996 00:42:14 +0000
parents 7e8ee35d0fb9
children 253f761ad37b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
662
8a533acedb77 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 584
diff changeset
1 ;;; electric.el --- window maker and Command loop for `electric' modes.
8a533acedb77 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 584
diff changeset
2
13260
a10616f0ad17 (Electric-command-loop): Don't display a prompt
Richard M. Stallman <rms@gnu.org>
parents: 3439
diff changeset
3 ;; Copyright (C) 1985, 1986, 1995 Free Software Foundation, Inc.
845
213978acbc1e entered into RCS
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 811
diff changeset
4
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 778
diff changeset
5 ;; Author: K. Shane Hartman
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 778
diff changeset
6 ;; Maintainer: FSF
811
e694e0879463 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 807
diff changeset
7 ;; Keywords: extensions
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 778
diff changeset
8
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 778
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
14 ;; any later version.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
15
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
19 ;; GNU General Public License for more details.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
20
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13260
diff changeset
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13260
diff changeset
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13260
diff changeset
24 ;; Boston, MA 02111-1307, USA.
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
25
2229
bd3c525fa6fc Added standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1821
diff changeset
26 ;;; Commentary:
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
27
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 35
diff changeset
28 ; zaaaaaaap
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
29
2229
bd3c525fa6fc Added standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1821
diff changeset
30 ;;; Code:
bd3c525fa6fc Added standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1821
diff changeset
31
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
32 ;; This loop is the guts for non-standard modes which retain control
13260
a10616f0ad17 (Electric-command-loop): Don't display a prompt
Richard M. Stallman <rms@gnu.org>
parents: 3439
diff changeset
33 ;; until some event occurs. It is a `do-forever', the only way out is
a10616f0ad17 (Electric-command-loop): Don't display a prompt
Richard M. Stallman <rms@gnu.org>
parents: 3439
diff changeset
34 ;; to throw. It assumes that you have set up the keymap, window, and
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
35 ;; everything else: all it does is read commands and execute them -
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
36 ;; providing error messages should one occur (if there is no loop
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
37 ;; function - which see). The required argument is a tag which should
13260
a10616f0ad17 (Electric-command-loop): Don't display a prompt
Richard M. Stallman <rms@gnu.org>
parents: 3439
diff changeset
38 ;; expect a value of nil if the user decides to punt. The second
a10616f0ad17 (Electric-command-loop): Don't display a prompt
Richard M. Stallman <rms@gnu.org>
parents: 3439
diff changeset
39 ;; argument is the prompt to be used: if nil, use "->", if 'noprompt,
a10616f0ad17 (Electric-command-loop): Don't display a prompt
Richard M. Stallman <rms@gnu.org>
parents: 3439
diff changeset
40 ;; don't use a prompt, if a string, use that string as prompt, and if
a10616f0ad17 (Electric-command-loop): Don't display a prompt
Richard M. Stallman <rms@gnu.org>
parents: 3439
diff changeset
41 ;; a function of no variable, it will be evaluated in every iteration
a10616f0ad17 (Electric-command-loop): Don't display a prompt
Richard M. Stallman <rms@gnu.org>
parents: 3439
diff changeset
42 ;; of the loop and its return value, which can be nil, 'noprompt or a
a10616f0ad17 (Electric-command-loop): Don't display a prompt
Richard M. Stallman <rms@gnu.org>
parents: 3439
diff changeset
43 ;; string, will be used as prompt. Given third argument non-nil, it
a10616f0ad17 (Electric-command-loop): Don't display a prompt
Richard M. Stallman <rms@gnu.org>
parents: 3439
diff changeset
44 ;; INHIBITS quitting unless the user types C-g at toplevel. This is
a10616f0ad17 (Electric-command-loop): Don't display a prompt
Richard M. Stallman <rms@gnu.org>
parents: 3439
diff changeset
45 ;; so user can do things like C-u C-g and not get thrown out. Fourth
a10616f0ad17 (Electric-command-loop): Don't display a prompt
Richard M. Stallman <rms@gnu.org>
parents: 3439
diff changeset
46 ;; argument, if non-nil, should be a function of two arguments which
a10616f0ad17 (Electric-command-loop): Don't display a prompt
Richard M. Stallman <rms@gnu.org>
parents: 3439
diff changeset
47 ;; is called after every command is executed. The fifth argument, if
a10616f0ad17 (Electric-command-loop): Don't display a prompt
Richard M. Stallman <rms@gnu.org>
parents: 3439
diff changeset
48 ;; provided, is the state variable for the function. If the
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
49 ;; loop-function gets an error, the loop will abort WITHOUT throwing
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
50 ;; (moral: use unwind-protect around call to this function for any
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
51 ;; critical stuff). The second argument for the loop function is the
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
52 ;; conditions for any error that occurred or nil if none.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
53
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
54 (defun Electric-command-loop (return-tag
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
55 &optional prompt inhibit-quit
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
56 loop-function loop-state)
13260
a10616f0ad17 (Electric-command-loop): Don't display a prompt
Richard M. Stallman <rms@gnu.org>
parents: 3439
diff changeset
57
a10616f0ad17 (Electric-command-loop): Don't display a prompt
Richard M. Stallman <rms@gnu.org>
parents: 3439
diff changeset
58 (let (cmd
a10616f0ad17 (Electric-command-loop): Don't display a prompt
Richard M. Stallman <rms@gnu.org>
parents: 3439
diff changeset
59 (err nil)
a10616f0ad17 (Electric-command-loop): Don't display a prompt
Richard M. Stallman <rms@gnu.org>
parents: 3439
diff changeset
60 (prompt-string prompt))
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
61 (while t
13260
a10616f0ad17 (Electric-command-loop): Don't display a prompt
Richard M. Stallman <rms@gnu.org>
parents: 3439
diff changeset
62 (if (not (or (stringp prompt) (eq prompt nil) (eq prompt 'noprompt)))
a10616f0ad17 (Electric-command-loop): Don't display a prompt
Richard M. Stallman <rms@gnu.org>
parents: 3439
diff changeset
63 (setq prompt-string (funcall prompt)))
a10616f0ad17 (Electric-command-loop): Don't display a prompt
Richard M. Stallman <rms@gnu.org>
parents: 3439
diff changeset
64 (if (not (stringp prompt-string))
a10616f0ad17 (Electric-command-loop): Don't display a prompt
Richard M. Stallman <rms@gnu.org>
parents: 3439
diff changeset
65 (if (eq prompt-string 'noprompt)
a10616f0ad17 (Electric-command-loop): Don't display a prompt
Richard M. Stallman <rms@gnu.org>
parents: 3439
diff changeset
66 (setq prompt-string nil)
a10616f0ad17 (Electric-command-loop): Don't display a prompt
Richard M. Stallman <rms@gnu.org>
parents: 3439
diff changeset
67 (setq prompt-string "->")))
a10616f0ad17 (Electric-command-loop): Don't display a prompt
Richard M. Stallman <rms@gnu.org>
parents: 3439
diff changeset
68 (setq cmd (read-key-sequence prompt-string))
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
69 (setq last-command-char (aref cmd (1- (length cmd)))
14941
7e8ee35d0fb9 (Electric-command-loop): Set universal-argument-other-key to 0.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
70 this-command (key-binding cmd t)
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
71 cmd this-command)
14941
7e8ee35d0fb9 (Electric-command-loop): Set universal-argument-other-key to 0.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
72 ;; This makes universal-argument-other-key work.
7e8ee35d0fb9 (Electric-command-loop): Set universal-argument-other-key to 0.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
73 (setq universal-argument-num-events 0)
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
74 (if (or (prog1 quit-flag (setq quit-flag nil))
3439
13660e63d8f0 (Electric-command-loop): Use eq to compare events.
Richard M. Stallman <rms@gnu.org>
parents: 2540
diff changeset
75 (eq last-input-char ?\C-g))
1821
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1609
diff changeset
76 (progn (setq unread-command-events nil
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
77 prefix-arg nil)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
78 ;; If it wasn't cancelling a prefix character, then quit.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
79 (if (or (= (length (this-command-keys)) 1)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
80 (not inhibit-quit)) ; safety
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
81 (progn (ding)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
82 (message "Quit")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
83 (throw return-tag nil))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
84 (setq cmd nil))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
85 (setq current-prefix-arg prefix-arg)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
86 (if cmd
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
87 (condition-case conditions
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
88 (progn (command-execute cmd)
703
e2780d9a814c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 662
diff changeset
89 (setq last-command this-command)
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
90 (if (or (prog1 quit-flag (setq quit-flag nil))
3439
13660e63d8f0 (Electric-command-loop): Use eq to compare events.
Richard M. Stallman <rms@gnu.org>
parents: 2540
diff changeset
91 (eq last-input-char ?\C-g))
1821
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1609
diff changeset
92 (progn (setq unread-command-events nil)
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
93 (if (not inhibit-quit)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
94 (progn (ding)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
95 (message "Quit")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
96 (throw return-tag nil))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
97 (ding)))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
98 (buffer-read-only (if loop-function
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
99 (setq err conditions)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
100 (ding)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
101 (message "Buffer is read-only")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
102 (sit-for 2)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
103 (beginning-of-buffer (if loop-function
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
104 (setq err conditions)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
105 (ding)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
106 (message "Beginning of Buffer")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
107 (sit-for 2)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
108 (end-of-buffer (if loop-function
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
109 (setq err conditions)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
110 (ding)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
111 (message "End of Buffer")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
112 (sit-for 2)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
113 (error (if loop-function
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
114 (setq err conditions)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
115 (ding)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
116 (message "Error: %s"
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
117 (if (eq (car conditions) 'error)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
118 (car (cdr conditions))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
119 (prin1-to-string conditions)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
120 (sit-for 2))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
121 (ding))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
122 (if loop-function (funcall loop-function loop-state err))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
123 (ding)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
124 (throw return-tag nil))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
125
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
126 ;; This function is like pop-to-buffer, sort of.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
127 ;; The algorithm is
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
128 ;; If there is a window displaying buffer
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
129 ;; Select it
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
130 ;; Else if there is only one window
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
131 ;; Split it, selecting the window on the bottom with height being
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
132 ;; the lesser of max-height (if non-nil) and the number of lines in
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
133 ;; the buffer to be displayed subject to window-min-height constraint.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
134 ;; Else
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
135 ;; Switch to buffer in the current window.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
136 ;;
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
137 ;; Then if max-height is nil, and not all of the lines in the buffer
778
cd00bdacc17b *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 703
diff changeset
138 ;; are displayed, grab the whole frame.
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
139 ;;
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
140 ;; Returns selected window on buffer positioned at point-min.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
141
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
142 (defun Electric-pop-up-window (buffer &optional max-height)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
143 (let* ((win (or (get-buffer-window buffer) (selected-window)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
144 (buf (get-buffer buffer))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
145 (one-window (one-window-p t))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
146 (pop-up-windows t)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
147 (target-height)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
148 (lines))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
149 (if (not buf)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
150 (error "Buffer %s does not exist" buffer)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
151 (save-excursion
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
152 (set-buffer buf)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
153 (setq lines (count-lines (point-min) (point-max)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
154 (setq target-height
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
155 (min (max (if max-height (min max-height (1+ lines)) (1+ lines))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
156 window-min-height)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
157 (save-window-excursion
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
158 (delete-other-windows)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
159 (1- (window-height (selected-window)))))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
160 (cond ((and (eq (window-buffer win) buf))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
161 (select-window win))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
162 (one-window
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
163 (goto-char (window-start win))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
164 (pop-to-buffer buffer)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
165 (setq win (selected-window))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
166 (enlarge-window (- target-height (window-height win))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
167 (t
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
168 (switch-to-buffer buf)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
169 (if (and (not max-height)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
170 (> target-height (window-height (selected-window))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
171 (progn (goto-char (window-start win))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
172 (enlarge-window (- target-height (window-height win)))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
173 (goto-char (point-min))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
174 win)))
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 35
diff changeset
175
662
8a533acedb77 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 584
diff changeset
176 (provide 'electric)
8a533acedb77 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 584
diff changeset
177
2229
bd3c525fa6fc Added standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1821
diff changeset
178 ;;; electric.el ends here