summaryrefslogtreecommitdiff
path: root/elisp/geiser-debug.el
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2009-05-03 01:22:01 +0200
committerJose Antonio Ortega Ruiz <jao@gnu.org>2009-05-03 01:22:01 +0200
commita63280cd55b342046966f95943ca9a45b2870c07 (patch)
tree25b827e6006563a52af7128ae02760221e0b0eab /elisp/geiser-debug.el
parentd485cecc04bbdd3fff177b3c179ca1fd1dbc9500 (diff)
downloadgeiser-a63280cd55b342046966f95943ca9a45b2870c07.tar.gz
geiser-a63280cd55b342046966f95943ca9a45b2870c07.tar.bz2
Wrapping arbitrary regions with a begin block before evaluation/expansion.
Diffstat (limited to 'elisp/geiser-debug.el')
-rw-r--r--elisp/geiser-debug.el28
1 files changed, 18 insertions, 10 deletions
diff --git a/elisp/geiser-debug.el b/elisp/geiser-debug.el
index c8fb3f4..0573716 100644
--- a/elisp/geiser-debug.el
+++ b/elisp/geiser-debug.el
@@ -91,28 +91,36 @@
(insert "In expression:\n"))
(insert (format "%s%s\n" (make-string offset ?\ ) description))))
-(defun geiser-debug--send-region (compile start end and-go)
+(defsubst geiser-debug--wrap-region (str)
+ (format "(begin %s)" str))
+
+(defun geiser-debug--unwrap (str)
+ (if (string-match "(begin[ \t\n\v\r]+\\(.+\\)*)" str)
+ (match-string 1 str)
+ str))
+
+(defun geiser-debug--send-region (compile start end and-go wrap)
(let* ((str (buffer-substring-no-properties start end))
- (code `(,(if compile :comp :eval) (:scm ,str)))
+ (wrapped (if wrap (geiser-debug--wrap-region str) str))
+ (code `(,(if compile :comp :eval) (:scm ,wrapped)))
(ret (geiser-eval--send/wait code))
(err (geiser-eval--retort-error ret)))
- (when and-go
- (switch-to-geiser)
- (push-mark)
- (goto-char (point-max)))
+ (when and-go (funcall and-go))
(when (not err) (message (format "=> %s" (geiser-eval--retort-result ret))))
(geiser-debug--display-retort str ret)))
-(defun geiser-debug--expand-region (start end all)
+(defun geiser-debug--expand-region (start end all wrap)
(let* ((str (buffer-substring-no-properties start end))
- (code `(:eval ((:ge macroexpand) (quote (:scm ,str)) ,(if all :t :f))))
+ (wrapped (if wrap (geiser-debug--wrap-region str) str))
+ (code `(:eval ((:ge macroexpand) (quote (:scm ,wrapped)) ,(if all :t :f))))
(ret (geiser-eval--send/wait code))
- (err (geiser-eval--retort-error ret)))
+ (err (geiser-eval--retort-error ret))
+ (result (geiser-eval--retort-result ret)))
(if err
(geiser-debug--display-retort str ret)
(geiser-debug--with-buffer
(erase-buffer)
- (insert (format "%s" (geiser-eval--retort-result ret)))
+ (insert (format "%s" (if wrap (geiser-debug--unwrap result) result)))
(goto-char (point-min)))
(geiser-debug--pop-to-buffer))))