diff options
| author | Richard M. Stallman | 2003-12-29 19:58:11 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2003-12-29 19:58:11 +0000 |
| commit | 9d133481d6caf87ff3f230caaca07da9b69dcf12 (patch) | |
| tree | 8ab3e3410b75070550549e9f58503f0fe3bd53b6 | |
| parent | 617631c0f39083d73c5007d0612f689ea941642a (diff) | |
| download | emacs-9d133481d6caf87ff3f230caaca07da9b69dcf12.tar.gz emacs-9d133481d6caf87ff3f230caaca07da9b69dcf12.zip | |
(term-exec): Set up sentinel.
(term-sentinel): New function.
(term-handle-exit): New function.
| -rw-r--r-- | lisp/term.el | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/lisp/term.el b/lisp/term.el index d2088a29785..b329004c083 100644 --- a/lisp/term.el +++ b/lisp/term.el | |||
| @@ -1290,6 +1290,7 @@ buffer. The hook term-exec-hook is run after each exec." | |||
| 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 |
| @@ -1306,6 +1307,49 @@ buffer. The hook term-exec-hook is run after each exec." | |||
| 1306 | (run-hooks 'term-exec-hook) | 1307 | (run-hooks 'term-exec-hook) |
| 1307 | buffer))) | 1308 | buffer))) |
| 1308 | 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 | |||
| 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") |