Commit 9d133481 authored by Richard M. Stallman's avatar Richard M. Stallman
Browse files

(term-exec): Set up sentinel.

(term-sentinel): New function.
(term-handle-exit): New function.
parent 617631c0
......@@ -1290,6 +1290,7 @@ buffer. The hook term-exec-hook is run after each exec."
(goto-char (point-max))
(set-marker (process-mark proc) (point))
(set-process-filter proc 'term-emulate-terminal)
(set-process-sentinel proc 'term-sentinel)
;; Feed it the startfile.
(cond (startfile
;;This is guaranteed to wait long enough
......@@ -1306,6 +1307,49 @@ buffer. The hook term-exec-hook is run after each exec."
(run-hooks 'term-exec-hook)
(defun term-sentinel (proc msg)
"Sentinel for term buffers.
The main purpose is to get rid of the local keymap."
(let ((buffer (process-buffer proc)))
(if (memq (process-status proc) '(signal exit))
(if (null (buffer-name buffer))
;; buffer killed
(set-process-buffer proc nil)
(let ((obuf (current-buffer)))
;; save-excursion isn't the right thing if
;; process-buffer is current-buffer
;; Write something in the compilation buffer
;; and hack its mode line.
(set-buffer buffer)
;; Get rid of local keymap.
(use-local-map nil)
(term-handle-exit (process-name proc)
;; Since the buffer and mode line will show that the
;; process is dead, we can delete it now. Otherwise it
;; will stay around until M-x list-processes.
(delete-process proc))
(set-buffer obuf))))
(defun term-handle-exit (process-name msg)
"Write process exit (or other change) message MSG in the current buffer."
(let ((buffer-read-only nil)
(omax (point-max))
(opoint (point)))
;; Record where we put the message, so we can ignore it
;; later on.
(goto-char omax)
(insert ?\n "Process " process-name " " msg)
;; Force mode line redisplay soon.
(if (and opoint (< opoint omax))
(goto-char opoint))))
;;; Name to use for TERM.
;;; Using "emacs" loses, because bash disables editing if TERM == emacs.
(defvar term-term-name "eterm")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment