From 5a47685bfb52bcb09385c1e19a24f337aed26472 Mon Sep 17 00:00:00 2001 From: "wojciech.meyer" Date: Wed, 1 Aug 2012 01:48:41 +0200 Subject: [PATCH] Factor out code to utop-eval-string Ignore-this: 42d0ac92ee18eb0a7865743fe5058a5c darcs-hash:20120731234841-33bd9-68f9230ddc9e8f41b48efa62dd9d048f2ae506d4 --- src/top/utop.el | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/top/utop.el b/src/top/utop.el index 762f17e..b4553e2 100644 --- a/src/top/utop.el +++ b/src/top/utop.el @@ -722,6 +722,20 @@ when byte-compiling." ;; Put it in utop mode (with-current-buffer buf (utop-mode))))))) +(defun utop-eval-string (string) + (with-current-buffer utop-buffer-name + (cond + ((eq utop-state 'edit) + ;; Insert it at the end of the utop buffer + (goto-char (point-max)) + (insert string) + ;; Send input to utop now, telling it to automatically add the + ;; phrase terminator + (utop-eval-input nil t nil)) + ((eq utop-state 'wait) + ;; utop is starting, save the initial command to send + (setq utop-initial-command string))))) + (defun utop-eval (start end) "Eval the given region in utop." ;; From tuareg @@ -738,18 +752,7 @@ when byte-compiling." (utop-choose-call "skip-to-end-of-phrase") (setq end (point)) (buffer-substring-no-properties start end)))) - (with-current-buffer utop-buffer-name - (cond - ((eq utop-state 'edit) - ;; Insert it at the end of the utop buffer - (goto-char (point-max)) - (insert text) - ;; Send input to utop now, telling it to automatically add the - ;; phrase terminator - (utop-eval-input nil t nil)) - ((eq utop-state 'wait) - ;; utop is starting, save the initial command to send - (setq utop-initial-command text)))))) + (utop-eval-string text))) (defun utop-eval-region (start end) "Eval the current region in utop."