(term-exec): Set up sentinel.
(term-sentinel): New function. (term-handle-exit): New function.
This commit is contained in:
parent
617631c0f3
commit
9d133481d6
1 changed files with 44 additions and 0 deletions
44
lisp/term.el
44
lisp/term.el
|
|
@ -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)
|
||||
buffer)))
|
||||
|
||||
(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))
|
||||
(progn
|
||||
(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
|
||||
(unwind-protect
|
||||
(progn
|
||||
;; 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)
|
||||
msg)
|
||||
;; 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.
|
||||
(force-mode-line-update)
|
||||
(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")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue