aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1993-10-25 20:01:29 +0000
committerRichard M. Stallman1993-10-25 20:01:29 +0000
commitc1da5c031fbc3399105c806b2cd7a1bed99da3a3 (patch)
tree577bcca32dbfec40e955872e7336504975839670
parent6351296c27dd984d59c777509b021b1cb376354e (diff)
downloademacs-c1da5c031fbc3399105c806b2cd7a1bed99da3a3.tar.gz
emacs-c1da5c031fbc3399105c806b2cd7a1bed99da3a3.zip
(comint-scroll-to-bottom-on-input): Default to nil.
(comint-mode): Use pre-command-hook, not before-change-function. (comint-preinput-scroll-to-bottom): Take no arguments. (comint-output-filter-functions): Renamed from comint-output-filter-hook. (comint-output-filter): Pass STRING as arg to output hook functions. (comint-preinput-scroll-to-bottom): Take an arg. Move point to new process mark if it was at the old one. Scroll so only if point is at or after the process mark. When scrolling, put end of text on bottom line, regardless of point.
-rw-r--r--lisp/comint.el54
1 files changed, 34 insertions, 20 deletions
diff --git a/lisp/comint.el b/lisp/comint.el
index d2f1db93f2a..2370e1395da 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -183,12 +183,12 @@ See also `comint-read-input-ring' and `comint-write-input-ring'.
183This variable is buffer-local, and is a good thing to set in mode hooks.") 183This variable is buffer-local, and is a good thing to set in mode hooks.")
184 184
185(defvar comint-scroll-to-bottom-on-input 185(defvar comint-scroll-to-bottom-on-input
186 (if (> baud-rate 9600) 'this) 186 nil
187 "*Controls whether input to interpreter causes window to scroll. 187 "*Controls whether input to interpreter causes window to scroll.
188If nil, then do not scroll. If t or `all', scroll all windows showing buffer. 188If nil, then do not scroll. If t or `all', scroll all windows showing buffer.
189If `this', scroll only the selected window. 189If `this', scroll only the selected window.
190 190
191The default is `this' for fast terminals, nil for slower ones. 191The default nil.
192 192
193See `comint-preinput-scroll-to-bottom'. This variable is buffer-local.") 193See `comint-preinput-scroll-to-bottom'. This variable is buffer-local.")
194 194
@@ -266,9 +266,10 @@ Thus it can, for instance, track cd/pushd/popd commands issued to a shell.")
266Takes one argument, the input. If non-nil, the input may be saved on the input 266Takes one argument, the input. If non-nil, the input may be saved on the input
267history list. Default is to save anything that isn't all whitespace.") 267history list. Default is to save anything that isn't all whitespace.")
268 268
269(defvar comint-output-filter-hook '(comint-postoutput-scroll-to-bottom) 269(defvar comint-output-filter-functions '(comint-postoutput-scroll-to-bottom)
270 "Functions to call after output is inserted into the buffer. 270 "Functions to call after output is inserted into the buffer.
271Possible function is `comint-postoutput-scroll-to-bottom'. 271One possible function is `comint-postoutput-scroll-to-bottom'.
272These functions get one argument, a string containing the text just inserted.
272 273
273This variable is buffer-local.") 274This variable is buffer-local.")
274 275
@@ -310,7 +311,7 @@ This is to work around a bug in Emacs process signalling.")
310(put 'comint-input-ring 'permanent-local t) 311(put 'comint-input-ring 'permanent-local t)
311(put 'comint-input-ring-index 'permanent-local t) 312(put 'comint-input-ring-index 'permanent-local t)
312(put 'comint-input-autoexpand 'permanent-local t) 313(put 'comint-input-autoexpand 'permanent-local t)
313(put 'comint-output-filter-hook 'permanent-local t) 314(put 'comint-output-filter-functions 'permanent-local t)
314(put 'comint-scroll-to-bottom-on-input 'permanent-local t) 315(put 'comint-scroll-to-bottom-on-input 'permanent-local t)
315(put 'comint-scroll-to-bottom-on-output 'permanent-local t) 316(put 'comint-scroll-to-bottom-on-output 'permanent-local t)
316(put 'comint-scroll-show-maximum-output 'permanent-local t) 317(put 'comint-scroll-show-maximum-output 'permanent-local t)
@@ -342,7 +343,7 @@ Commands with no default key bindings include `send-invisible',
342`comint-magic-space'. 343`comint-magic-space'.
343 344
344Input to, and output from, the subprocess can cause the window to scroll to 345Input to, and output from, the subprocess can cause the window to scroll to
345the end of the buffer. See variables `comint-output-filter-hook', 346the end of the buffer. See variables `comint-output-filter-functions',
346`comint-scroll-to-bottom-on-input', and `comint-scroll-to-bottom-on-output'. 347`comint-scroll-to-bottom-on-input', and `comint-scroll-to-bottom-on-output'.
347 348
348If you accidentally suspend your process, use \\[comint-continue-subjob] 349If you accidentally suspend your process, use \\[comint-continue-subjob]
@@ -389,9 +390,9 @@ Entry to this mode runs the hooks on `comint-mode-hook'."
389 (make-local-variable 'comint-scroll-to-bottom-on-input) 390 (make-local-variable 'comint-scroll-to-bottom-on-input)
390 (make-local-variable 'comint-scroll-to-bottom-on-output) 391 (make-local-variable 'comint-scroll-to-bottom-on-output)
391 (make-local-variable 'comint-scroll-show-maximum-output) 392 (make-local-variable 'comint-scroll-show-maximum-output)
392 (make-local-variable 'before-change-function) 393 (make-local-variable 'pre-command-hook)
393 (setq before-change-function 'comint-preinput-scroll-to-bottom) 394 (add-hook 'pre-command-hook 'comint-preinput-scroll-to-bottom)
394 (make-local-variable 'comint-output-filter-hook) 395 (make-local-variable 'comint-output-filter-functions)
395 (make-local-variable 'comint-ptyp) 396 (make-local-variable 'comint-ptyp)
396 (make-local-variable 'comint-exec-hook) 397 (make-local-variable 'comint-exec-hook)
397 (make-local-variable 'comint-process-echoes) 398 (make-local-variable 'comint-process-echoes)
@@ -1104,7 +1105,10 @@ Similarly for Soar, Scheme, etc."
1104 (set-marker (process-mark proc) (point)) 1105 (set-marker (process-mark proc) (point))
1105 ;; A kludge to prevent the delay between insert and process output 1106 ;; A kludge to prevent the delay between insert and process output
1106 ;; affecting the display. A case for a comint-send-input-hook? 1107 ;; affecting the display. A case for a comint-send-input-hook?
1107 (run-hooks 'comint-output-filter-hook))))) 1108 (let ((functions comint-output-filter-functions))
1109 (while functions
1110 (funcall (car functions) (concat input "\n"))
1111 (setq functions (cdr functions))))))))
1108 1112
1109;; The purpose of using this filter for comint processes 1113;; The purpose of using this filter for comint processes
1110;; is to keep comint-last-input-end from moving forward 1114;; is to keep comint-last-input-end from moving forward
@@ -1148,18 +1152,20 @@ Similarly for Soar, Scheme, etc."
1148 1152
1149 (narrow-to-region obeg oend) 1153 (narrow-to-region obeg oend)
1150 (goto-char opoint) 1154 (goto-char opoint)
1151 (run-hooks 'comint-output-filter-hook) 1155 (let ((functions comint-output-filter-functions))
1152 1156 (while functions
1157 (funcall (car functions) string)
1158 (setq functions (cdr functions))))
1153 (set-buffer obuf)))) 1159 (set-buffer obuf))))
1154 1160
1155(defun comint-preinput-scroll-to-bottom (beg end) 1161(defun comint-preinput-scroll-to-bottom ()
1156 "Go to the end of buffer in all windows showing it. 1162 "Go to the end of buffer in all windows showing it.
1157Movement occurs if point in the selected window is not after the process mark, 1163Movement occurs if point in the selected window is not after the process mark,
1158and `this-command' is an insertion command. Insertion commands recognised 1164and `this-command' is an insertion command. Insertion commands recognised
1159are `self-insert-command', `yank', `mouse-yank-at-click', and `hilit-yank'. 1165are `self-insert-command', `yank', `mouse-yank-at-click', and `hilit-yank'.
1160Depends on the value of `comint-scroll-to-bottom-on-input'. 1166Depends on the value of `comint-scroll-to-bottom-on-input'.
1161 1167
1162This function should be bound to `before-change-function'." 1168This function should be a pre-command hook."
1163 (if (and comint-scroll-to-bottom-on-input 1169 (if (and comint-scroll-to-bottom-on-input
1164 (memq this-command '(self-insert-command yank mouse-yank-at-click 1170 (memq this-command '(self-insert-command yank mouse-yank-at-click
1165 hilit-yank))) 1171 hilit-yank)))
@@ -1180,13 +1186,13 @@ This function should be bound to `before-change-function'."
1180 (select-window selected))))) 1186 (select-window selected)))))
1181 'not-minibuf t))))) 1187 'not-minibuf t)))))
1182 1188
1183(defun comint-postoutput-scroll-to-bottom () 1189(defun comint-postoutput-scroll-to-bottom (string)
1184 "Go to the end of buffer in all windows showing it. 1190 "Go to the end of buffer in all windows showing it.
1185Does not scroll if the current line is the last line in the buffer. 1191Does not scroll if the current line is the last line in the buffer.
1186Depends on the value of `comint-scroll-to-bottom-on-output' and 1192Depends on the value of `comint-scroll-to-bottom-on-output' and
1187`comint-scroll-show-maximum-output'. 1193`comint-scroll-show-maximum-output'.
1188 1194
1189This function should be bound to `comint-output-filter-hook'." 1195This function should be in the list `comint-output-filter-functions'."
1190 (let* ((selected (selected-window)) 1196 (let* ((selected (selected-window))
1191 (current (current-buffer)) 1197 (current (current-buffer))
1192 (process (get-buffer-process current)) 1198 (process (get-buffer-process current))
@@ -1200,10 +1206,18 @@ This function should be bound to `comint-output-filter-hook'."
1200 (and (eq scroll 'others) (not (eq selected window))))) 1206 (and (eq scroll 'others) (not (eq selected window)))))
1201 (progn 1207 (progn
1202 (select-window window) 1208 (select-window window)
1203 (if (not (save-excursion (end-of-line nil) (eobp))) 1209 ;; If point WAS at process mark in this window,
1204 (goto-char (process-mark process))) 1210 ;; keep it at process mark.
1205 (if comint-scroll-show-maximum-output 1211 (and (>= (point) (- (process-mark process) (length string)))
1206 (recenter -1)) 1212 (< (point) (process-mark process))
1213 (goto-char (process-mark process)))
1214 ;; Optionally scroll so that the text
1215 ;; ends at the bottom of the window.
1216 (if (and comint-scroll-show-maximum-output
1217 (>= (point) (process-mark process)))
1218 (save-excursion
1219 (goto-char (point-max))
1220 (recenter -1)))
1207 (select-window selected))))) 1221 (select-window selected)))))
1208 'not-minibuf t)))) 1222 'not-minibuf t))))
1209 1223