summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--elisp/geiser-guile.el13
-rw-r--r--elisp/geiser-racket.el11
-rw-r--r--elisp/geiser-repl.el17
3 files changed, 38 insertions, 3 deletions
diff --git a/elisp/geiser-guile.el b/elisp/geiser-guile.el
index cfcba80..fb49085 100644
--- a/elisp/geiser-guile.el
+++ b/elisp/geiser-guile.el
@@ -90,8 +90,18 @@ This function uses `geiser-guile-init-file' if it exists."
(car (geiser-syntax--read-from-string module))) :f))
(t :f)))
+(defun geiser-guile--module-cmd (module fmt &optional def)
+ (when module
+ (let* ((module (geiser-guile--get-module module))
+ (module (cond ((or (null module) (eq module :f)) def)
+ (t (format "%s" module)))))
+ (and module (format fmt module)))))
+
+(defun geiser-guile--import-command (module)
+ (geiser-guile--module-cmd module ",i %s"))
+
(defun geiser-guile--enter-command (module)
- (and module (format ",m %s" (geiser-guile--get-module module))))
+ (geiser-guile--module-cmd module ",m %s" "(guile-user)"))
(defun geiser-guile--symbol-begin (module)
(if module
@@ -204,6 +214,7 @@ This function uses `geiser-guile-init-file' if it exists."
(marshall-procedure geiser-guile--geiser-procedure)
(find-module geiser-guile--get-module)
(enter-command geiser-guile--enter-command)
+ (import-command geiser-guile--import-command)
(find-symbol-begin geiser-guile--symbol-begin)
(display-error geiser-guile--display-error)
(display-help)
diff --git a/elisp/geiser-racket.el b/elisp/geiser-racket.el
index e5f8780..7f00810 100644
--- a/elisp/geiser-racket.el
+++ b/elisp/geiser-racket.el
@@ -113,7 +113,15 @@ This function uses `geiser-racket-init-file' if it exists."
(save-excursion (skip-syntax-backward "^-()>") (point)))
(defun geiser-racket--enter-command (module)
- (and (stringp module) (format "(enter! (file %S))" module)))
+ (when (stringp module)
+ (cond ((zerop (length module)) "(enter! #f)")
+ ((file-name-absolute-p module) (format "(enter! (file %S))" module))
+ (t (format "(enter! %s)" module)))))
+
+(defun geiser-racket--import-command (module)
+ (and (stringp module)
+ (not (zerop (length module)))
+ (format "(require %s)" module)))
(defconst geiser-racket--binding-forms
'(for for/list for/hash for/hasheq for/and for/or
@@ -192,6 +200,7 @@ This function uses `geiser-racket-init-file' if it exists."
(marshall-procedure geiser-racket--geiser-procedure)
(find-module geiser-racket--get-module)
(enter-command geiser-racket--enter-command)
+ (import-command geiser-racket--import-command)
(find-symbol-begin geiser-racket--symbol-begin)
(display-error geiser-racket--display-error)
(display-help geiser-racket--external-help)
diff --git a/elisp/geiser-repl.el b/elisp/geiser-repl.el
index 3e52361..c9f3d26 100644
--- a/elisp/geiser-repl.el
+++ b/elisp/geiser-repl.el
@@ -251,6 +251,21 @@ module command as a string")
(switch-to-geiser)
(geiser-repl--send cmd)))
+(geiser-impl--define-caller geiser-repl--import-cmd import-command (module)
+ "Function taking a module designator and returning a REPL import
+module command as a string")
+
+(defun geiser-repl-import-module (&optional module)
+ "Import a given module in the current namespace."
+ (interactive)
+ (let* ((module (or module
+ (geiser-completion--read-module "Import module: ")))
+ (cmd (and module
+ (geiser-repl--import-cmd geiser-impl--implementation
+ module))))
+ (switch-to-geiser)
+ (geiser-repl--send cmd)))
+
(defun geiser-repl-nuke ()
"Try this command if the REPL becomes unresponsive."
(interactive)
@@ -395,7 +410,7 @@ module command as a string")
:enable (symbol-at-point))
--
("Switch to module..." ("\C-c\C-m" "\C-cm") switch-to-geiser-module)
- ("Load module" ("\C-c\C-l" "\C-cl") geiser-load-file)
+ ("Import module" ("\C-c\C-i" "\C-ci") geiser-repl-import-module)
--
("Previous matching input" "\M-p" comint-previous-matching-input-from-input
"Previous input matching current")