summaryrefslogtreecommitdiff
path: root/elisp
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2010-03-07 05:16:20 +0100
committerJose Antonio Ortega Ruiz <jao@gnu.org>2010-03-07 05:16:20 +0100
commita7d5b74b8fcda5952da0557bcd5d3cbb45fc6403 (patch)
tree48bfa6f97f9ba4543886fb3d27d600d95ab3a2e7 /elisp
parent6301342e046ccca8a981c072b1968496b0e9e43a (diff)
downloadgeiser-a7d5b74b8fcda5952da0557bcd5d3cbb45fc6403.tar.gz
geiser-a7d5b74b8fcda5952da0557bcd5d3cbb45fc6403.tar.bz2
New command to switch to REPL and put it in current module.
Diffstat (limited to 'elisp')
-rw-r--r--elisp/geiser-mode.el10
-rw-r--r--elisp/geiser-plt.el6
-rw-r--r--elisp/geiser-repl.el14
3 files changed, 27 insertions, 3 deletions
diff --git a/elisp/geiser-mode.el b/elisp/geiser-mode.el
index d083973..3e0f522 100644
--- a/elisp/geiser-mode.el
+++ b/elisp/geiser-mode.el
@@ -1,6 +1,6 @@
;; geiser-mode.el -- minor mode for scheme buffers
-;; Copyright (C) 2009 Jose Antonio Ortega Ruiz
+;; Copyright (C) 2009, 2010 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
@@ -150,6 +150,12 @@ With prefix, recursively macro-expand the resulting expression."
(geiser-impl--set-buffer-implementation impl)
(geiser-repl--get-repl impl)))
+(defun geiser-mode-switch-to-repl (arg)
+ "Switches to Geiser REPL.
+With prefix, try to enter the current's buffer module."
+ (interactive "P")
+ (if arg (switch-to-geiser-module) (switch-to-geiser)))
+
;;; Geiser mode:
@@ -201,7 +207,7 @@ interacting with the Geiser REPL is at your disposal.
(define-key geiser-mode-map (vector '(control ?c) `(control ,p) k) c)
(define-key geiser-mode-map (vector '(control ?c) `(control ,p) `(control ,k)) c))
-(define-key geiser-mode-map "\C-c\C-z" 'switch-to-geiser)
+(define-key geiser-mode-map "\C-c\C-z" 'geiser-mode-switch-to-repl)
(define-key geiser-mode-map "\C-c\C-s" 'geiser-set-scheme)
(define-key geiser-mode-map "\C-c\C-l" 'geiser-load-current-buffer)
diff --git a/elisp/geiser-plt.el b/elisp/geiser-plt.el
index d9b3ca9..c808ed5 100644
--- a/elisp/geiser-plt.el
+++ b/elisp/geiser-plt.el
@@ -109,6 +109,9 @@ This function uses `geiser-plt-init-file' if it exists."
(defun geiser-plt--symbol-begin (module)
(save-excursion (skip-syntax-backward "^-()>") (point)))
+(defun geiser-plt--enter-command (module)
+ (and (stringp module) (format "(enter! (file %S))" module)))
+
;;; External help
@@ -169,13 +172,14 @@ This function uses `geiser-plt-init-file' if it exists."
;;; Implementation definition:
(define-geiser-implementation plt
+ (unsupported-procedures '(callers callees generic-methods))
(binary geiser-plt--binary)
(arglist geiser-plt--parameters)
(startup)
- (unsupported-procedures '(callers callees generic-methods))
(prompt-regexp geiser-plt--prompt-regexp)
(marshall-procedure geiser-plt--geiser-procedure)
(find-module geiser-plt--get-module)
+ (enter-command geiser-plt--enter-command)
(find-symbol-begin geiser-plt--symbol-begin)
(display-error geiser-plt--display-error)
(display-help geiser-plt--external-help)
diff --git a/elisp/geiser-repl.el b/elisp/geiser-repl.el
index 2afdcef..facae50 100644
--- a/elisp/geiser-repl.el
+++ b/elisp/geiser-repl.el
@@ -227,6 +227,20 @@ If no REPL is running, execute `run-geiser' to start a fresh one."
(defalias 'geiser 'switch-to-geiser)
+(geiser-impl--define-caller geiser-repl--enter-cmd enter-command (module)
+ "Function taking a module designator and returning a REPL enter
+module command as a string")
+
+(defun switch-to-geiser-module ()
+ "Switch to running Geiser REPL and try to enter current module."
+ (interactive)
+ (let ((m (geiser-repl--enter-cmd geiser-impl--implementation
+ (geiser-eval--get-module))))
+ (switch-to-geiser)
+ (when m
+ (comint-send-string nil m)
+ (comint-send-eof))))
+
(defun geiser-repl-nuke ()
"Try this command if the REPL becomes unresponsive."
(interactive)