annotate lisp/ilisp/ilisp-out.el @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children b82b59fe008d
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 ;;; -*- Mode: Emacs-Lisp -*-
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;;; ilisp-out.el --
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;;; This file is part of ILISP.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;;; Version: 5.7
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;;; Copyright (C) 1990, 1991, 1992, 1993 Chris McConnell
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;;; 1993, 1994 Ivan Vasquez
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;;; 1994, 1995 Marco Antoniotti and Rick Busdiecker
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;;; Other authors' names for which this Copyright notice also holds
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;; may appear later in this file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;;; Send mail to 'ilisp-request@lehman.com' to be included in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;;; ILISP mailing list. 'ilisp@lehman.com' is the general ILISP
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;;; mailing list were bugs and improvements are discussed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;;; ILISP is freely redistributable under the terms found in the file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;;; COPYING.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;;; ILISP output, including a popper replacement.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 (defvar ilisp-output-buffer " *Output*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 (defvar ilisp-output-buffer-major-mode 'lisp-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 "*The major mode for the ilisp typeout window.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 (defvar ilisp-output-min-height 2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 "*The minimum height of the typeout window used to display ilisp output.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 (defvar ilisp-output-max-height 25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 "*The maximum height of the typeout window used to display ilisp output.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 (defvar ilisp-display-output-function 'ilisp-display-output-default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 "The name of a function to display all ilisp output. The function gets a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 single argument, a string.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;; Minor mode (just to get a pretty mode line).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 (defvar ilisp-output-mode-line nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 (defvar ilisp-output-mode nil "If T, then we are in the ilisp-output minor mode.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 (make-variable-buffer-local 'ilisp-output-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 (or (assq 'ilisp-output-mode minor-mode-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (setq minor-mode-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 (cons '(ilisp-output-mode ilisp-output-mode-line) minor-mode-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (defun ilisp-output-buffer (&optional create-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (let ((buffer (if create-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (get-buffer-create ilisp-output-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 (get-buffer ilisp-output-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (or ilisp-output-mode-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (setq ilisp-output-mode-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (list (format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 " %s bury, %s scroll"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (ilisp-where-is 'ilisp-bury-output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (ilisp-where-is 'ilisp-scroll-output)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (defun ilisp-output-window ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 (let ((buffer (get-buffer ilisp-output-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 (if buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (get-buffer-window buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (defun lisp-display-output (output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 "Display OUTPUT in the appropriate place.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 This calls the function given by the value of ilisp-display-output-function in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 order to do the real work."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (cond ((null output))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 ;; Bugcheck
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (if (not (stringp output))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (error "bug: not a string in lisp-display-output"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (if (ilisp-value 'comint-errorp t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (setq output (funcall (ilisp-value 'ilisp-error-filter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 output)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (funcall ilisp-display-output-function output))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 ;;; Popper replacement
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (defun ilisp-bury-output ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 "Delete the typeout window, if any"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (let* ((buffer (ilisp-output-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (window (and buffer (get-buffer-window buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (if buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (bury-buffer buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (if window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (ilisp-delete-window window))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (defun ilisp-show-output (&optional buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 "Make typeout visible, if it is not already."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (let ((buffer (or buffer (ilisp-output-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (if buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (ilisp-display-buffer-in-typeout-window buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (defun ilisp-delete-window (window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 "Delete a window with minimal redisplay."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (let ((height (window-height window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (lower-window (ilisp-find-lower-window window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (delete-window window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (if (and lower-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (not (eq lower-window window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (let ((old-window (selected-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (select-window lower-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (set-buffer (window-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (goto-char (window-start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (vertical-motion (- height))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (set-window-start lower-window (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (select-window old-window)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (defun ilisp-scroll-output (&optional lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 "Scroll the typeout-window, if any."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (let* ((buffer (ilisp-output-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (window (and buffer (get-buffer-window buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (old-window (selected-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (if window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (select-window window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (scroll-up lines))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (select-window old-window)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (defun ilisp-grow-output (&optional n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 "Grow the typeout window by ARG (default 1) lines."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (let* ((buffer (ilisp-output-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (window (and buffer (get-buffer-window buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (old-window (selected-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (if window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (select-window window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (enlarge-window n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (if (ilisp-window-live-p old-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (select-window old-window))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (defun ilisp-trim-blank-lines ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 ;; Delete leading blank lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (if (looking-at "\n+")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (replace-match ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 ;; Delete trailing blank lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (skip-chars-backward "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (if (< (point) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (delete-region (1+ (point)) (point-max))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (defun ilisp-write-string-to-buffer (buffer string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 ;; Maybe an option to keep the old output?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 ;; New: select mode for the output buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (if (not (eq major-mode ilisp-output-buffer-major-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (funcall ilisp-output-buffer-major-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (setq ilisp-output-mode t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (princ string buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (ilisp-trim-blank-lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (goto-char (point-min))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (defun ilisp-desired-height (buffer-or-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (let ((height
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (cond ((bufferp buffer-or-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (ilisp-needed-buffer-height buffer-or-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 ((windowp buffer-or-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (ilisp-needed-window-height buffer-or-window)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (max window-min-height
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (min ilisp-output-max-height
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (max ilisp-output-min-height
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 height)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 ;; A first guess at the height needed to display this buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (defun ilisp-needed-buffer-height (buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (1+ (count-lines (point-min) (point-max)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 ;; The height this window must be to display its entire buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (defun ilisp-needed-window-height (window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (select-window window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (set-buffer (window-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (+ 2 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 ;; Any upper bound on the height of an emacs window will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 ;; do here. How about 1000.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (vertical-motion 1000))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (defun ilisp-shrink-wrap-window (window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (let ((previously-selected-window (selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (buffer (window-buffer window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (select-window window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (let* ((current-height (window-height window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (desired-height (ilisp-desired-height window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (delta (- desired-height current-height)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (enlarge-window delta)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 ;; Now repair damage to the window below us, if it still exists.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (let ((lower-window (ilisp-find-lower-window window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (if lower-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (select-window lower-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (let ((old-point (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (goto-char (window-start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (vertical-motion delta)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (set-window-start lower-window (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (goto-char old-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (if (not (pos-visible-in-window-p old-point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (recenter 0))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 ;; If there was no lower window, then we ought to preserve
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 ;; the start of the window above us, if any.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (if (ilisp-window-live-p previously-selected-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (select-window previously-selected-window)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (defun ilisp-window-live-p (window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (let* ((initial-window (selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (win initial-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (found nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (while win
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (cond ((eq window win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (setq found t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 win nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (setq win (next-window win 'no))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (if (eq win initial-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (setq win nil)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 found))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 ;; XEmacs change -- window-edges is gone in 19.12+ so use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 ;; next-vertical-window instead.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (defun ilisp-find-lower-window (window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 "Find the window directly below us, if any. This is probably the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 window from which enlarge-window would steal lines."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (if (< emacs-minor-version 12)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (let* ((bottom (nth 3 (window-edges window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (window* nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (win window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (while (not (eq (setq win (next-window win 'no))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (if (and (= (nth 1 (window-edges win))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 bottom)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (null window*))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (setq window* win)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 window*)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (next-vertical-window window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 ;; XEmacs change -- There is now a primitive to do this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (defun ilisp-find-top-left-most-window ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 "Return the leftmost topmost window on the current screen."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (if (< emacs-minor-version 12)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (let* ((window* (selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (edges* (window-edges window*))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (win nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (edges nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (start-window window*))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (while (not (eq (setq win (next-window win 'no))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 start-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (setq edges (window-edges win))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (if (or (< (car (cdr edges)) (car (cdr edges*))) ; top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (and (= (car (cdr edges)) (car (cdr edges*)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (< (car edges) (car edges*)))) ; left
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (setq window* win
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 edges* edges)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 window*)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (frame-highest-window (selected-frame) 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 ;; This causes the typeout window to be created by splitting or using the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 ;; top-left-most window on the current screen. That is different behavior
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 ;; from the popper, which always split the current window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (defun ilisp-window-to-use-for-typeout ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (ilisp-find-top-left-most-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (defun ilisp-display-buffer-in-typeout-window (buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 "Display buffer in a window at the top of the screen."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (let ((window (get-buffer-window buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 ;; If buffer already has a window, keep it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (if (null window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 ;; Otherwise, find a window to split.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (let* ((top-window (ilisp-window-to-use-for-typeout))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (new-window nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (previously-selected-window (selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (desired-height (ilisp-desired-height buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 ;; The new window is always the lower one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (select-window top-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 ;; Always minimize redisplay (except in emacs 18).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (let ((split-window-keep-point nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 ;; If the top window is not big enough to split, commandeer it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 ;; entirely.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (cond ((> desired-height (- (window-height) window-min-height))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (setq new-window top-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (setq new-window (split-window-vertically desired-height)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (set-window-buffer top-window buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 ;; The height is already correct, unless there was line wrapping.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 ;; Account for that here.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (ilisp-shrink-wrap-window top-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 ;; Restore selected window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (if (eq previously-selected-window top-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (select-window new-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (select-window previously-selected-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 ;; Simply shrink-wrap an existing window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (ilisp-shrink-wrap-window window))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 ;;; Various functions to which to bind ilisp-display-output-function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 ;; This function does what ilisp used to do, except that we use the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 ;; new "popper".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (defun ilisp-display-output-default (output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 "Dispatch on the value of lisp-no-popper:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 lisp-no-popper = nil: display output in a typeout window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 lisp-no-popper = t: display output in the ilisp buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 otherwise: display one-line output in the echo area, multiline output in the ilisp buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (cond ((null lisp-no-popper)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (ilisp-display-output-in-typeout-window output))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 ((eq lisp-no-popper t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (ilisp-display-output-in-lisp-listener output))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (ilisp-display-output-adaptively output))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 ;; This is the display function I like to use.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 ;; Another trick which might be useful is to dispatch on the value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 ;; this-command here, to make output from different ilisp commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 ;; go to different places.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (defun ilisp-display-output-adaptively (output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 "Display one-liners in the echo area, others in the typeout window"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (cond ((or (string-match "\n" output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (> (length output) (window-width (minibuffer-window))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (message "See above.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (ilisp-display-output-in-typeout-window output))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (ilisp-display-output-in-echo-area output))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (defun ilisp-display-output-in-typeout-window (output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 "Display output in a shrink-wrapped window at the top of the screen."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (let ((buffer (ilisp-output-buffer t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (ilisp-write-string-to-buffer buffer output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (ilisp-display-buffer-in-typeout-window buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 (defun ilisp-display-output-in-echo-area (output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 "Display output as a message in the echo area."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 ;; First clear any existing typeout so as to not confuse the user.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (or (eq (selected-window) (ilisp-output-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (ilisp-bury-output))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 ;; Patch suggested by hunter@work.nlm.nih.gov (Larry Hunter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 ;; If output contains '%', 'message' loses.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 ;; (message (ilisp-quote-%s output))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 ;; An alternative here could be '(princ output)', as suggested by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 ;; Christopher Hoover <ch@lks.csi.com>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (princ output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 ;;; ilisp-quote-%s --
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 ;;; Patch suggested by hunter@work.nlm.nih.gov (Larry Hunter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 (defun ilisp-quote-%s (string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 "Quote all the occurences of ?% in STRING in an ELisp fashion."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (mapconcat '(lambda (char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (if (char-equal char ?%)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 "%%"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (char-to-string char)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 string ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (defun ilisp-display-output-in-temp-buffer (output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (with-output-to-temp-buffer ilisp-output-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (princ output)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (defun ilisp-display-output-in-lisp-listener (output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 "Display output in the ilisp buffer"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (let ((buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (window (selected-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 (lisp-pop-to-buffer (ilisp-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 (if (not (eq (current-buffer) buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 (setq ilisp-last-buffer buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (comint-insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 (if ilisp-last-message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (concat ";;; " ilisp-last-message "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (comint-remove-whitespace output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 "\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 ilisp-last-prompt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (setq ilisp-last-message nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (if (window-point window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (progn (select-window window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (set-buffer buffer))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 ;;; Changed according to suggestions by Robert P. Goldman
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (defun lisp-pop-to-buffer (buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 "Like pop-to-buffer, but select a screen that buffer was shown in."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 (let ((ilisp-window (if ilisp-epoch-running
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 (epoch::get-buffer-window buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 (get-buffer-window buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (if ilisp-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 (select-window ilisp-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 ;; It is not currently displayed, so find some place to display
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 ;; it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (cond (ilisp-epoch-running
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 ;; Select a screen that the buffer has been displayed in before
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 ;; or the current screen otherwise.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 (epoch::select-screen
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 ;; allowed-screens in epoch 3.2, was called screens before that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (or (car (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (symbol-value 'allowed-screens)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (epoch::current-screen))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 ;; Next clauses patterned after a suggestion by R. P. Goldman.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 ((eq +ilisp-emacs-version-id+ 'fsf-19)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 (let* ((window (get-buffer-window buffer t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (frame (if window (window-frame window))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 (if (eq 'x (framep frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (raise-frame frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (select-frame frame)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (t nil)) ; fsf-18, but also lucid and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 ; xemacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 ; I do not know how to make
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 ; them work
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 ; Marco Antoniotti, Jan 4th 1995
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (ilisp-bury-output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (pop-to-buffer buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (set-buffer buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 ;(defun lisp-pop-to-buffer (buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 ; "Like pop-to-buffer, but select a screen that buffer was shown in.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 ; Also, first bury any typeout-window."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 ; (let ((ilisp-window (if ilisp-epoch-running
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 ; (epoch::get-buffer-window buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 ; (get-buffer-window buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 ; (if ilisp-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 ; (select-window ilisp-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 ; ;; It is not currently displayed, so find some place to display it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 ; (if ilisp-epoch-running
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 ; ;; Select a screen that the buffer has been displayed in before
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 ; ;; or the current screen otherwise.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 ; (epoch::select-screen
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 ; ;; allowed-screens in epoch 3.2, was called screens before that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 ; (or (car (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 ; (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 ; (symbol-value 'allowed-screens)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 ; (epoch::current-screen))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 ; ;; Do not pop to the output buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 ; (ilisp-bury-output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 ; (pop-to-buffer buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 ; (set-buffer buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 (defun switch-to-lisp (eob-p &optional ilisp-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 "If in an ILISP buffer, switch to the buffer that last switched to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 an ILISP otherwise, switch to the current ILISP buffer. With
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 argument, positions cursor at end of buffer. If you don't want to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 split windows, set pop-up-windows to NIL."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 (if (and (not ilisp-only) ilisp-last-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 (memq major-mode ilisp-modes))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 (lisp-pop-to-buffer ilisp-last-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 (if (not (memq major-mode ilisp-modes))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 (setq ilisp-last-buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (lisp-pop-to-buffer (ilisp-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 (cond (eob-p (goto-char (point-max))))))