summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2013-04-12 00:57:23 +0200
committerJose Antonio Ortega Ruiz <jao@gnu.org>2013-04-12 00:57:23 +0200
commit5b1b700926173c1ffa11fae558bce06b31c0bc30 (patch)
tree05a81b9ad6d3d6d17fef2da1f058a8cef116303e
parent516d3e90613c5910d6af34842aa613275344d924 (diff)
downloadgeiser-5b1b700926173c1ffa11fae558bce06b31c0bc30.tar.gz
geiser-5b1b700926173c1ffa11fae558bce06b31c0bc30.tar.bz2
Simplifications to previous patch
-rw-r--r--elisp/geiser-debug.el9
-rw-r--r--elisp/geiser-eval.el22
-rw-r--r--elisp/geiser-mode.el27
3 files changed, 24 insertions, 34 deletions
diff --git a/elisp/geiser-debug.el b/elisp/geiser-debug.el
index 184d9c8..611e50e 100644
--- a/elisp/geiser-debug.el
+++ b/elisp/geiser-debug.el
@@ -1,6 +1,6 @@
;;; geiser-debug.el -- displaying debug information and evaluation results
-;; Copyright (C) 2009, 2010, 2011, 2012 Jose Antonio Ortega Ruiz
+;; Copyright (C) 2009, 2010, 2011, 2012, 2013 Jose Antonio Ortega Ruiz
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the Modified BSD License. You should
@@ -161,18 +161,19 @@ buffer.")
(match-string 1 str)
str))
-(defun geiser-debug--send-region (compile start end and-go wrap)
+(defun geiser-debug--send-region (compile start end and-go wrap &optional nomsg)
(let* ((str (buffer-substring-no-properties start end))
(wrapped (if wrap (geiser-debug--wrap-region str) str))
(code `(,(if compile :comp :eval) (:scm ,wrapped)))
(ret (geiser-eval--send/wait code))
- (res (geiser-eval--retort-result-str ret))
+ (res (geiser-eval--retort-result-str ret nil))
(err (geiser-eval--retort-error ret)))
(when and-go (funcall and-go))
(when (not err)
(save-excursion
(goto-char (/ (+ end start) 2))
- (geiser-autodoc--clean-cache)))
+ (geiser-autodoc--clean-cache))
+ (unless nomsg (message "%s" res)))
(geiser-debug--display-retort (geiser-syntax--scheme-str str) ret res)
ret))
diff --git a/elisp/geiser-eval.el b/elisp/geiser-eval.el
index 5d61580..28da110 100644
--- a/elisp/geiser-eval.el
+++ b/elisp/geiser-eval.el
@@ -1,6 +1,6 @@
;;; geiser-eval.el -- sending scheme code for evaluation
-;; Copyright (C) 2009, 2010, 2011, 2012 Jose Antonio Ortega Ruiz
+;; Copyright (C) 2009, 2010, 2011, 2012, 2013 Jose Antonio Ortega Ruiz
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the Modified BSD License. You should
@@ -167,21 +167,13 @@ module-exports, autodoc, callers, callees and generic-methods.")
(let ((values (cdr (assoc 'result ret))))
(car (geiser-syntax--read-from-string (car values)))))
-(defun geiser-eval--retort-result-str (ret)
- (let ((values (cdr (assoc 'result ret))))
+(defun geiser-eval--retort-result-str (ret prefix)
+ (let* ((prefix (or prefix "=> "))
+ (nlprefix (concat "\n" prefix))
+ (values (cdr (assoc 'result ret))))
(if values
- (concat "=> " (mapconcat 'identity values "\n=> "))
- "(No value)")))
-
-(defun geiser-eval--retort-result-list (ret)
- "Return the list of results."
- (cdr (assoc 'result ret)))
-
-(defun geiser-eval--retort-result-to-buffer (ret)
- "Return a string formated for printing to buffer."
- (mapconcat 'identity
- (geiser-eval--retort-result-list ret)
- "\n"))
+ (concat prefix (mapconcat 'identity values nlprefix))
+ (or prefix "(No value)"))))
(defsubst geiser-eval--retort-output (ret) (cdr (assoc 'output ret)))
(defsubst geiser-eval--retort-error (ret) (cdr (assoc 'error ret)))
diff --git a/elisp/geiser-mode.el b/elisp/geiser-mode.el
index a47a92b..8d66a8a 100644
--- a/elisp/geiser-mode.el
+++ b/elisp/geiser-mode.el
@@ -72,7 +72,7 @@ active when `geiser-mode' is activated in a buffer."
(push-mark)
(goto-char (point-max)))
-(defun geiser-eval-region (start end &optional and-go raw)
+(defun geiser-eval-region (start end &optional and-go raw nomsg)
"Eval the current region in the Geiser REPL.
With prefix, goes to the REPL buffer afterwards (as
`geiser-eval-region-and-go')"
@@ -84,7 +84,8 @@ With prefix, goes to the REPL buffer afterwards (as
start
end
(and and-go 'geiser--go-to-repl)
- (not raw)))
+ (not raw)
+ nomsg))
(defun geiser-eval-region-and-go (start end)
"Eval the current region in the Geiser REPL and visit it afterwads."
@@ -109,21 +110,17 @@ With prefix, goes to the REPL buffer afterwards (as
(defun geiser-eval-last-sexp (print-to-buffer-p)
"Eval the previous sexp in the Geiser REPL.
-
With a prefix, print the result of the evaluation to the buffer."
(interactive "P")
- (let ((ret (geiser-eval-region (save-excursion (backward-sexp) (point))
- (point)
- nil
- t)))
- (if print-to-buffer-p
- (let ((str (geiser-eval--retort-result-to-buffer ret)))
- ;; It's possible that a procedure returns nothing, so we
- ;; don't want to `push-mark' if it's not necessary
- (unless (string= "" str)
- (push-mark)
- (insert str)))
- (message "%s" (geiser-eval--retort-result-str ret)))))
+ (let* ((ret (geiser-eval-region (save-excursion (backward-sexp) (point))
+ (point)
+ nil
+ t
+ print-to-buffer-p))
+ (str (geiser-eval--retort-result-str ret (when print-to-buffer-p ""))))
+ (when (and print-to-buffer-p (not (string= "" str)))
+ (push-mark)
+ (insert str))))
(defun geiser-compile-definition (&optional and-go)
"Compile the current definition in the Geiser REPL.