Mercurial > emacs
comparison lisp/term.el @ 53413:c4a65e59063d
(term-exec): Set up sentinel.
(term-sentinel): New function.
(term-handle-exit): New function.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 29 Dec 2003 19:58:11 +0000 |
parents | 695cf19ef79e |
children | 422169b36462 |
comparison
equal
deleted
inserted
replaced
53412:a2bba9e88b95 | 53413:c4a65e59063d |
---|---|
1288 (setq term-ptyp process-connection-type) ; t if pty, nil if pipe. | 1288 (setq term-ptyp process-connection-type) ; t if pty, nil if pipe. |
1289 ;; Jump to the end, and set the process mark. | 1289 ;; Jump to the end, and set the process mark. |
1290 (goto-char (point-max)) | 1290 (goto-char (point-max)) |
1291 (set-marker (process-mark proc) (point)) | 1291 (set-marker (process-mark proc) (point)) |
1292 (set-process-filter proc 'term-emulate-terminal) | 1292 (set-process-filter proc 'term-emulate-terminal) |
1293 (set-process-sentinel proc 'term-sentinel) | |
1293 ;; Feed it the startfile. | 1294 ;; Feed it the startfile. |
1294 (cond (startfile | 1295 (cond (startfile |
1295 ;;This is guaranteed to wait long enough | 1296 ;;This is guaranteed to wait long enough |
1296 ;;but has bad results if the term does not prompt at all | 1297 ;;but has bad results if the term does not prompt at all |
1297 ;; (while (= size (buffer-size)) | 1298 ;; (while (= size (buffer-size)) |
1303 (setq startfile (buffer-substring (point) (point-max))) | 1304 (setq startfile (buffer-substring (point) (point-max))) |
1304 (delete-region (point) (point-max)) | 1305 (delete-region (point) (point-max)) |
1305 (term-send-string proc startfile))) | 1306 (term-send-string proc startfile))) |
1306 (run-hooks 'term-exec-hook) | 1307 (run-hooks 'term-exec-hook) |
1307 buffer))) | 1308 buffer))) |
1309 | |
1310 (defun term-sentinel (proc msg) | |
1311 "Sentinel for term buffers. | |
1312 The main purpose is to get rid of the local keymap." | |
1313 (let ((buffer (process-buffer proc))) | |
1314 (if (memq (process-status proc) '(signal exit)) | |
1315 (progn | |
1316 (if (null (buffer-name buffer)) | |
1317 ;; buffer killed | |
1318 (set-process-buffer proc nil) | |
1319 (let ((obuf (current-buffer))) | |
1320 ;; save-excursion isn't the right thing if | |
1321 ;; process-buffer is current-buffer | |
1322 (unwind-protect | |
1323 (progn | |
1324 ;; Write something in the compilation buffer | |
1325 ;; and hack its mode line. | |
1326 (set-buffer buffer) | |
1327 ;; Get rid of local keymap. | |
1328 (use-local-map nil) | |
1329 (term-handle-exit (process-name proc) | |
1330 msg) | |
1331 ;; Since the buffer and mode line will show that the | |
1332 ;; process is dead, we can delete it now. Otherwise it | |
1333 ;; will stay around until M-x list-processes. | |
1334 (delete-process proc)) | |
1335 (set-buffer obuf)))) | |
1336 )))) | |
1337 | |
1338 (defun term-handle-exit (process-name msg) | |
1339 "Write process exit (or other change) message MSG in the current buffer." | |
1340 (let ((buffer-read-only nil) | |
1341 (omax (point-max)) | |
1342 (opoint (point))) | |
1343 ;; Record where we put the message, so we can ignore it | |
1344 ;; later on. | |
1345 (goto-char omax) | |
1346 (insert ?\n "Process " process-name " " msg) | |
1347 ;; Force mode line redisplay soon. | |
1348 (force-mode-line-update) | |
1349 (if (and opoint (< opoint omax)) | |
1350 (goto-char opoint)))) | |
1351 | |
1308 | 1352 |
1309 ;;; Name to use for TERM. | 1353 ;;; Name to use for TERM. |
1310 ;;; Using "emacs" loses, because bash disables editing if TERM == emacs. | 1354 ;;; Using "emacs" loses, because bash disables editing if TERM == emacs. |
1311 (defvar term-term-name "eterm") | 1355 (defvar term-term-name "eterm") |
1312 ; Format string, usage: | 1356 ; Format string, usage: |