allow to gracefully quit utop in emacs
Ignore-this: 3360f5c57bfb97f64d4f4509901ea0cd darcs-hash:20120213092110-c41ad-88847c98d4a92479772b02d4fe88cdfa85fad9b6
This commit is contained in:
parent
3fe28723e2
commit
12dd581b99
|
@ -567,6 +567,8 @@ module Emacs(M : sig end) = struct
|
||||||
send "history-end" "";
|
send "history-end" "";
|
||||||
loop_commands (input :: history_prev) history_next
|
loop_commands (input :: history_prev) history_next
|
||||||
end
|
end
|
||||||
|
| Some ("exit", code) ->
|
||||||
|
exit (int_of_string code)
|
||||||
| Some (command, _) ->
|
| Some (command, _) ->
|
||||||
Printf.ksprintf (send "stderr") "unrecognized command %S!" command;
|
Printf.ksprintf (send "stderr") "unrecognized command %S!" command;
|
||||||
exit 1
|
exit 1
|
||||||
|
|
|
@ -131,6 +131,8 @@ This hook is only run if exiting actually kills the buffer."
|
||||||
(define-key map [(control ?c) (control ?c)] 'utop-interrupt)
|
(define-key map [(control ?c) (control ?c)] 'utop-interrupt)
|
||||||
(define-key map [(control ?c) (control ?i)] 'utop-interrupt)
|
(define-key map [(control ?c) (control ?i)] 'utop-interrupt)
|
||||||
(define-key map [(control ?c) (control ?k)] 'utop-kill)
|
(define-key map [(control ?c) (control ?k)] 'utop-kill)
|
||||||
|
(define-key map [(control ?c) (control ?g)] 'utop-exit)
|
||||||
|
(define-key map [(control ?c) (control ?s)] 'utop)
|
||||||
map)
|
map)
|
||||||
"The utop local keymap.")
|
"The utop local keymap.")
|
||||||
|
|
||||||
|
@ -672,6 +674,14 @@ To automatically do that just add these lines to your .emacs:
|
||||||
(with-current-buffer utop-buffer-name
|
(with-current-buffer utop-buffer-name
|
||||||
(kill-process utop-process)))
|
(kill-process utop-process)))
|
||||||
|
|
||||||
|
(defun utop-exit (&optional exit-code)
|
||||||
|
"Try to gracefully exit utop.
|
||||||
|
|
||||||
|
EXIT-CODE is the exit code that shoud be used. It defaults to 0."
|
||||||
|
(interactive)
|
||||||
|
(with-current-buffer utop-buffer-name
|
||||||
|
(process-send-string utop-process (format "exit:%d\n" (or exit-code 0)))))
|
||||||
|
|
||||||
(defun utop-sentinel (process msg)
|
(defun utop-sentinel (process msg)
|
||||||
"Callback for process' state change."
|
"Callback for process' state change."
|
||||||
(let ((buffer (get-buffer utop-buffer-name)))
|
(let ((buffer (get-buffer utop-buffer-name)))
|
||||||
|
@ -769,6 +779,7 @@ To automatically do that just add these lines to your .emacs:
|
||||||
["Start OCaml" utop t]
|
["Start OCaml" utop t]
|
||||||
["Interrupt OCaml" utop-interrupt :active (utop-is-running)]
|
["Interrupt OCaml" utop-interrupt :active (utop-is-running)]
|
||||||
["Kill OCaml" utop-kill :active (utop-is-running)]
|
["Kill OCaml" utop-kill :active (utop-is-running)]
|
||||||
|
["Exit utop gracefully" utop-exit :active (utop-is-running)]
|
||||||
["Evaluate Phrase" utop-eval-input-auto-end :active (and (utop-is-running) (eq utop-state 'edit))]
|
["Evaluate Phrase" utop-eval-input-auto-end :active (and (utop-is-running) (eq utop-state 'edit))]
|
||||||
"---"
|
"---"
|
||||||
["Customize utop" (customize-group 'utop) t]
|
["Customize utop" (customize-group 'utop) t]
|
||||||
|
|
Loading…
Reference in New Issue