wrap process-send-string with utop-send-string

Ignore-this: feb94f7ed3efee69e26ad73ac8503e8a
This adds needed checks, and start utop when the rest of the code wants to send string to the process and utop is not loaded

darcs-hash:20120303180200-33bd9-4aff67226cd9d3db1194c53a48f1bbe195c4badc
This commit is contained in:
wojciech.meyer 2012-03-03 19:02:00 +01:00
parent 023e72933d
commit bd61b32e8a
1 changed files with 8 additions and 8 deletions

View File

@ -242,13 +242,13 @@ to add the newline character if it is not accepted).")
"Send current input to utop" "Send current input to utop"
(let ((lines (split-string (buffer-substring-no-properties utop-prompt-max (point-max)) "\n"))) (let ((lines (split-string (buffer-substring-no-properties utop-prompt-max (point-max)) "\n")))
;; Send all lines to utop ;; Send all lines to utop
(process-send-string utop-process cmd) (utop-send-string cmd)
(while lines (while lines
;; Send the line ;; Send the line
(process-send-string utop-process (concat "data:" (car lines) "\n")) (utop-send-string (concat "data:" (car lines) "\n"))
;; Remove it and continue ;; Remove it and continue
(setq lines (cdr lines))) (setq lines (cdr lines)))
(process-send-string utop-process "end:\n"))) (utop-send-string "end:\n")))
;; +-----------------------------------------------------------------+ ;; +-----------------------------------------------------------------+
;; | Edition control | ;; | Edition control |
@ -316,7 +316,7 @@ to add the newline character if it is not accepted).")
(interactive) (interactive)
(with-current-buffer utop-buffer-name (with-current-buffer utop-buffer-name
(unless (eq utop-state 'done) (unless (eq utop-state 'done)
(process-send-string utop-process "save-history:\n")))) (utop-send-string "save-history:\n"))))
;; +-----------------------------------------------------------------+ ;; +-----------------------------------------------------------------+
;; | Receiving input from the utop sub-process | ;; | Receiving input from the utop sub-process |
@ -548,13 +548,13 @@ If ADD-TO-HISTORY is t then the input will be added to history."
;; We are now waiting for completion ;; We are now waiting for completion
(utop-set-state 'comp) (utop-set-state 'comp)
;; Send all lines to utop ;; Send all lines to utop
(process-send-string utop-process "complete:\n") (utop-send-string "complete:\n")
(while lines (while lines
;; Send the line ;; Send the line
(process-send-string utop-process (concat "data:" (car lines) "\n")) (utop-send-string (concat "data:" (car lines) "\n"))
;; Remove it and continue ;; Remove it and continue
(setq lines (cdr lines))) (setq lines (cdr lines)))
(process-send-string utop-process "end:\n"))))) (utop-send-string "end:\n")))))
;; +-----------------------------------------------------------------+ ;; +-----------------------------------------------------------------+
;; | Tuareg/Typerex integration | ;; | Tuareg/Typerex integration |
@ -717,7 +717,7 @@ defaults to 0."
(interactive) (interactive)
(with-current-buffer utop-buffer-name (with-current-buffer utop-buffer-name
(unless (eq utop-state 'done) (unless (eq utop-state 'done)
(process-send-string utop-process (format "exit:%d\n" (or exit-code 0)))))) (utop-send-string (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."