diff options
| -rw-r--r-- | lisp/comint.el | 54 |
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'. | |||
| 183 | This variable is buffer-local, and is a good thing to set in mode hooks.") | 183 | This 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. |
| 188 | If nil, then do not scroll. If t or `all', scroll all windows showing buffer. | 188 | If nil, then do not scroll. If t or `all', scroll all windows showing buffer. |
| 189 | If `this', scroll only the selected window. | 189 | If `this', scroll only the selected window. |
| 190 | 190 | ||
| 191 | The default is `this' for fast terminals, nil for slower ones. | 191 | The default nil. |
| 192 | 192 | ||
| 193 | See `comint-preinput-scroll-to-bottom'. This variable is buffer-local.") | 193 | See `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.") | |||
| 266 | Takes one argument, the input. If non-nil, the input may be saved on the input | 266 | Takes one argument, the input. If non-nil, the input may be saved on the input |
| 267 | history list. Default is to save anything that isn't all whitespace.") | 267 | history 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. |
| 271 | Possible function is `comint-postoutput-scroll-to-bottom'. | 271 | One possible function is `comint-postoutput-scroll-to-bottom'. |
| 272 | These functions get one argument, a string containing the text just inserted. | ||
| 272 | 273 | ||
| 273 | This variable is buffer-local.") | 274 | This 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 | ||
| 344 | Input to, and output from, the subprocess can cause the window to scroll to | 345 | Input to, and output from, the subprocess can cause the window to scroll to |
| 345 | the end of the buffer. See variables `comint-output-filter-hook', | 346 | the 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 | ||
| 348 | If you accidentally suspend your process, use \\[comint-continue-subjob] | 349 | If 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. |
| 1157 | Movement occurs if point in the selected window is not after the process mark, | 1163 | Movement occurs if point in the selected window is not after the process mark, |
| 1158 | and `this-command' is an insertion command. Insertion commands recognised | 1164 | and `this-command' is an insertion command. Insertion commands recognised |
| 1159 | are `self-insert-command', `yank', `mouse-yank-at-click', and `hilit-yank'. | 1165 | are `self-insert-command', `yank', `mouse-yank-at-click', and `hilit-yank'. |
| 1160 | Depends on the value of `comint-scroll-to-bottom-on-input'. | 1166 | Depends on the value of `comint-scroll-to-bottom-on-input'. |
| 1161 | 1167 | ||
| 1162 | This function should be bound to `before-change-function'." | 1168 | This 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. |
| 1185 | Does not scroll if the current line is the last line in the buffer. | 1191 | Does not scroll if the current line is the last line in the buffer. |
| 1186 | Depends on the value of `comint-scroll-to-bottom-on-output' and | 1192 | Depends 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 | ||
| 1189 | This function should be bound to `comint-output-filter-hook'." | 1195 | This 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 | ||