From eafe05ed39cf33ed8a3dd6d6a875dc2be00a19d2 Mon Sep 17 00:00:00 2001 From: Jose Antonio Ortega Ruiz Date: Mon, 9 Mar 2009 23:52:04 +0100 Subject: Support for multiple Scheme implementations, Chapter 1. * Evaluation system is now pluggable * The rest of the system understands said pluggability * Guile provides its own implementation (geiser-guile) * The reload system is aware of the new kids on the block --- elisp/geiser-eval.el | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) (limited to 'elisp/geiser-eval.el') diff --git a/elisp/geiser-eval.el b/elisp/geiser-eval.el index 3e5e7aa..8574cdc 100644 --- a/elisp/geiser-eval.el +++ b/elisp/geiser-eval.el @@ -34,14 +34,22 @@ ;;; Plug-able functions: (make-variable-buffer-local - (defvar geiser-eval--current-module-function 'geiser-syntax--buffer-module)) + (defvar geiser-eval--get-module-function 'geiser-syntax--buffer-module + "Function used to obtain the module for current buffer. It +takes an optional argument, for cases where we want to force its value.")) -(defsubst geiser-eval--current-module-function (fun) - (setq geiser-eval--current-module-function fun)) +(defsubst geiser-eval--get-module (&optional module) + (and geiser-eval--get-module-function + (funcall geiser-eval--get-module-function module))) -(defsubst geiser-eval--current-module () - (and geiser-eval--current-module-function - (funcall geiser-eval--current-module-function))) +(make-variable-buffer-local + (defvar geiser-eval--geiser-procedure-function nil + "Translate a bare procedure symbol to one executable in Guile's +context. Return NULL for unsupported ones; at the very least, +EVAL, COMPILE, LOAD-FILE and COMPILE-FILE should be supported.")) + +(defsubst geiser-eval--form (proc) + (funcall geiser-eval--geiser-procedure-function proc)) ;;; Code formatting: @@ -64,28 +72,27 @@ (defsubst geiser-eval--eval (code) (geiser-eval--scheme-str - `((@ (geiser emacs) ge:eval) (quote ,(nth 0 code)) (:module ,(nth 1 code))))) + `(,(geiser-eval--form 'eval) (quote ,(nth 0 code)) (:module ,(nth 1 code))))) (defsubst geiser-eval--comp (code) (geiser-eval--scheme-str - `((@ (geiser emacs) ge:compile) (quote ,(nth 0 code)) (:module ,(nth 1 code))))) + `(,(geiser-eval--form 'compile (quote ,(nth 0 code)) (:module ,(nth 1 code)))))) (defsubst geiser-eval--load-file (file) - (geiser-eval--scheme-str `((@ (geiser emacs) ge:load-file) ,file))) + (geiser-eval--scheme-str `(,(geiser-eval--form 'load-file) ,file))) (defsubst geiser-eval--comp-file (file) - (geiser-eval--scheme-str `((@ (geiser emacs) ge:compile-file) ,file))) + (geiser-eval--scheme-str `(,(geiser-eval--form 'compile-file) ,file))) (defsubst geiser-eval--module (code) (geiser-eval--scheme-str - (cond ((or (eq code '(())) (null code)) - `(quote ,(or (geiser-eval--current-module) :f))) - ((listp code) `(quote ,code)) - ((stringp code) (:scm code)) - (t (error "Invalid module spec: %S" code))))) + (cond ((or (null code) (eq code :t) (eq code :buffer)) + (list 'quote (funcall geiser-eval--get-module-function))) + ((or (eq code :repl) (eq code :f)) :f) + (t (list 'quote (funcall geiser-eval--get-module-function code)))))) (defsubst geiser-eval--ge (proc) - (format "(@ (geiser emacs) ge:%s)" proc)) + (geiser-eval--scheme-str (geiser-eval--form proc))) ;;; Code sending: -- cgit v1.2.3