add a sentinel in the emacs mode to print status at the end of the buffer
Ignore-this: a28596e0b3eaf811a1ce7ffb9b56c0c8 darcs-hash:20120202153104-c41ad-e872c7f5e94c3469e6b44bfdd2f9a5ae184a0ef9
This commit is contained in:
parent
ff8ef4b766
commit
db6cbf1f61
|
@ -437,6 +437,26 @@ sub-process."
|
|||
(with-current-buffer utop-buffer-name
|
||||
(kill-process utop-process)))
|
||||
|
||||
(defun utop-sentinel (process msg)
|
||||
"Callback for process' state change."
|
||||
(with-current-buffer utop-buffer-name
|
||||
(let ((status (process-status utop-process)))
|
||||
(when (or (eq status 'exit) (eq status 'signal))
|
||||
;; The process is terminated
|
||||
(let ((inhibit-read-only t) (exit-code (process-exit-status utop-process)))
|
||||
;; Insert a message at the end
|
||||
(goto-char (point-max))
|
||||
(cond
|
||||
((eq status 'exit)
|
||||
(insert "\n\nProcess utop exited with code " (number-to-string exit-code) "\n"))
|
||||
((eq status 'signal)
|
||||
(insert "\n\nProcess utop has been killed by signal " (number-to-string exit-code) "\n")))
|
||||
;; Make the whole buffer sticky and read-only
|
||||
(remove-text-properties (point-min) (point-max) '(rear-nonsticky nil))
|
||||
(add-text-properties (point-min) (point-max) '(read-only t))
|
||||
;; Go to the end of the buffer
|
||||
(goto-char (point-max)))))))
|
||||
|
||||
;; +-----------------------------------------------------------------+
|
||||
;; | The mode |
|
||||
;; +-----------------------------------------------------------------+
|
||||
|
@ -473,6 +493,9 @@ sub-process."
|
|||
;; Filter the output of the sub-process with our filter function
|
||||
(set-process-filter utop-process 'utop-process-output)
|
||||
|
||||
;; Set the process sentinel
|
||||
(set-process-sentinel utop-process 'utop-sentinel)
|
||||
|
||||
;; Define keys
|
||||
(define-key utop-mode-map [return] 'utop-send-input)
|
||||
(define-key utop-mode-map [(control ?m)] 'utop-send-input)
|
||||
|
|
Loading…
Reference in New Issue