summaryrefslogtreecommitdiff
path: root/elisp/geiser-guile.el
diff options
context:
space:
mode:
Diffstat (limited to 'elisp/geiser-guile.el')
-rw-r--r--elisp/geiser-guile.el39
1 files changed, 26 insertions, 13 deletions
diff --git a/elisp/geiser-guile.el b/elisp/geiser-guile.el
index 3e1c03f..8f8d7af 100644
--- a/elisp/geiser-guile.el
+++ b/elisp/geiser-guile.el
@@ -113,28 +113,40 @@ This function uses `geiser-guile-init-file' if it exists."
;;; Evaluation support:
+(defun geiser-guile--linearize (str)
+ (if (string-match "\n" str)
+ (with-temp-buffer
+ (insert str)
+ (subst-char-in-region (point-min) (point-max) ?\n ? t)
+ (buffer-string))
+ str))
+
+(defsubst geiser-guile--linearize-args (args)
+ (mapconcat 'geiser-guile--linearize args " "))
(defun geiser-guile--geiser-procedure (proc &rest args)
(case proc
- ((eval compile) (format "((@ (geiser emacs) ge:compile) '%s '%s)"
- (mapconcat 'identity (cdr args) " ")
- (or (car args) "#f")))
- ((load-file compile-file)
- (format "((@ (geiser emacs) ge:%s) %s)" proc (car args)))
- ((no-values) "((@ (guile) values))")
- (t (format "(apply (@ (geiser emacs) ge:%s) (list %s))"
- proc (mapconcat 'identity args "")))))
+ ((eval compile) (format ",geiser-eval %s %s"
+ (or (car args) "#f")
+ (geiser-guile--linearize-args (cdr args))))
+ ((load-file compile-file) (format ",geiser-load-file %s" (car args)))
+ ((no-values) ",geiser-no-values")
+ (t (format "ge:%s %s" proc (geiser-guile--linearize-args args)))))
(defconst geiser-guile--module-re
"(define-module +\\(([^)]+)\\)")
+(defconst geiser-guile--library-re
+ "(library +\\(([^)]+)\\)")
+
(defun geiser-guile--get-module (&optional module)
(cond ((null module)
(save-excursion
(ignore-errors
(while (not (zerop (geiser-syntax--nesting-level)))
(backward-up-list)))
- (if (re-search-backward geiser-guile--module-re nil t)
+ (if (or (re-search-backward geiser-guile--module-re nil t)
+ (looking-at geiser-guile--library-re))
(geiser-guile--get-module (match-string-no-properties 1))
:f)))
((listp module) module)
@@ -173,7 +185,7 @@ This function uses `geiser-guile-init-file' if it exists."
(if geiser-guile-debug-show-bt-p "bt" "fr"))))
(compilation-forget-errors)
(goto-char (point-max))
- (comint-send-string nil "((@ (geiser emacs) ge:newline))\n")
+ (comint-send-string nil ",geiser-newline\n")
(comint-send-string nil ",error-message\n")
(comint-send-string nil bt-cmd)
(when geiser-guile-show-debug-help-p
@@ -247,9 +259,10 @@ it spawn a server thread."
(font-lock-add-keywords nil
`((,geiser-guile--path-rx 1
compilation-error-face)))
- (geiser-eval--send/result
- `(:scm ,(format "(set! %%load-path (cons %S %%load-path))"
- (expand-file-name "guile/" geiser-scheme-dir))))
+ (geiser-eval--send/wait
+ (format "(set! %%load-path (cons %S %%load-path))"
+ (expand-file-name "guile/" geiser-scheme-dir)))
+ (geiser-eval--send/wait ",use (geiser emacs)")
(geiser-guile-update-warning-level))