From 7fe12503929dd8557a6daee1ad33d91ceef9293b Mon Sep 17 00:00:00 2001 From: Jose Antonio Ortega Ruiz Date: Sat, 30 Oct 2010 22:46:12 +0200 Subject: Guile: using meta-commands to talk with Guile --- scheme/guile/geiser/emacs.scm | 48 +++++++++++++++++--------------------- scheme/guile/geiser/evaluation.scm | 17 +++++++++----- 2 files changed, 32 insertions(+), 33 deletions(-) (limited to 'scheme') diff --git a/scheme/guile/geiser/emacs.scm b/scheme/guile/geiser/emacs.scm index af1a052..c3696f8 100644 --- a/scheme/guile/geiser/emacs.scm +++ b/scheme/guile/geiser/emacs.scm @@ -10,37 +10,31 @@ ;; Start date: Sun Feb 08, 2009 18:39 (define-module (geiser emacs) - #:re-export (ge:macroexpand - ge:compile-file - ge:load-file - ge:autodoc - ge:completions - ge:module-completions - ge:symbol-location - ge:generic-methods - ge:symbol-documentation - ge:module-exports - ge:module-location - ge:callers - ge:callees - ge:find-file) - #:export (ge:compile - ge:no-values - ge:newline) #:use-module (ice-9 match) + #:use-module (system repl command) #:use-module (geiser evaluation) #:use-module ((geiser modules) :renamer (symbol-prefix-proc 'ge:)) #:use-module ((geiser completion) :renamer (symbol-prefix-proc 'ge:)) #:use-module ((geiser xref) :renamer (symbol-prefix-proc 'ge:)) #:use-module ((geiser doc) :renamer (symbol-prefix-proc 'ge:))) -(define (ge:no-values) (values)) -(define ge:newline newline) - -(define (ge:compile form mod) - (match form - (`((@ (geiser emacs) . ,_) . ,_) (compile/no-warns form mod)) - (_ (compile/warns form mod)))) - - -;;; emacs.scm ends here +(define this-module (resolve-module '(geiser emacs))) + +(define-meta-command ((geiser-no-values geiser) repl) + "geiser-no-values +No-op command used internally by Geiser." + (values)) + +(define-meta-command ((geiser-eval geiser) repl mod form . args) + "geiser-eval +Meta-command used by Geiser to evaluate and compile code." + (display form) (newline) + (if (null? args) + (ge:compile form mod) + (let ((proc (eval form this-module))) + (ge:eval `(,proc ,@args) mod)))) + +(define-meta-command ((geiser-load-file geiser) repl file) + "geiser-load-file +Meta-command used by Geiser to load and compile files." + (ge:compile-file file)) diff --git a/scheme/guile/geiser/evaluation.scm b/scheme/guile/geiser/evaluation.scm index 1cc21a7..ef082db 100644 --- a/scheme/guile/geiser/evaluation.scm +++ b/scheme/guile/geiser/evaluation.scm @@ -10,8 +10,8 @@ ;; Start date: Mon Mar 02, 2009 02:46 (define-module (geiser evaluation) - #:export (compile/warns - compile/no-warns + #:export (ge:compile + ge:eval ge:macroexpand ge:compile-file ge:load-file @@ -71,10 +71,7 @@ (set! result (thunk))))))) (write-result result output))) -(define (compile/no-warns form module) - (compile* form module '())) - -(define (compile/warns form module) +(define (ge:compile form module) (compile* form module compile-opts)) (define (compile* form module-name opts) @@ -92,6 +89,14 @@ (lambda vs (map object->string vs)))))) (call-with-result ev))) +(define (ge:eval form module-name) + (let* ((module (or (find-module module-name) (current-module))) + (ev (lambda () + (call-with-values + (lambda () (eval form module)) + (lambda vs (map object->string vs)))))) + (call-with-result ev))) + (define (ge:compile-file path) (call-with-result (lambda () -- cgit v1.2.3 From 32592d3fd04db3a9facd9061d20c6ff7da2ce8f8 Mon Sep 17 00:00:00 2001 From: Jose Antonio Ortega Ruiz Date: Sat, 30 Oct 2010 23:49:06 +0200 Subject: Guile: debug leftover deleted --- scheme/guile/geiser/emacs.scm | 1 - 1 file changed, 1 deletion(-) (limited to 'scheme') diff --git a/scheme/guile/geiser/emacs.scm b/scheme/guile/geiser/emacs.scm index c3696f8..ba6b100 100644 --- a/scheme/guile/geiser/emacs.scm +++ b/scheme/guile/geiser/emacs.scm @@ -28,7 +28,6 @@ No-op command used internally by Geiser." (define-meta-command ((geiser-eval geiser) repl mod form . args) "geiser-eval Meta-command used by Geiser to evaluate and compile code." - (display form) (newline) (if (null? args) (ge:compile form mod) (let ((proc (eval form this-module))) -- cgit v1.2.3 From e0dca7b01b40b3548f03298a16dee252f310a567 Mon Sep 17 00:00:00 2001 From: Jose Antonio Ortega Ruiz Date: Sun, 31 Oct 2010 01:46:29 +0200 Subject: Guile: reactivating the debugger during evaluation --- elisp/geiser-guile.el | 2 +- scheme/guile/geiser/emacs.scm | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'scheme') diff --git a/elisp/geiser-guile.el b/elisp/geiser-guile.el index c406d88..8f8d7af 100644 --- a/elisp/geiser-guile.el +++ b/elisp/geiser-guile.el @@ -185,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 diff --git a/scheme/guile/geiser/emacs.scm b/scheme/guile/geiser/emacs.scm index ba6b100..73c02d0 100644 --- a/scheme/guile/geiser/emacs.scm +++ b/scheme/guile/geiser/emacs.scm @@ -12,6 +12,7 @@ (define-module (geiser emacs) #:use-module (ice-9 match) #:use-module (system repl command) + #:use-module (system repl error-handling) #:use-module (geiser evaluation) #:use-module ((geiser modules) :renamer (symbol-prefix-proc 'ge:)) #:use-module ((geiser completion) :renamer (symbol-prefix-proc 'ge:)) @@ -29,11 +30,18 @@ No-op command used internally by Geiser." "geiser-eval Meta-command used by Geiser to evaluate and compile code." (if (null? args) - (ge:compile form mod) + (call-with-error-handling + (lambda () (ge:compile form mod))) (let ((proc (eval form this-module))) (ge:eval `(,proc ,@args) mod)))) (define-meta-command ((geiser-load-file geiser) repl file) "geiser-load-file Meta-command used by Geiser to load and compile files." - (ge:compile-file file)) + (call-with-error-handling + (lambda () (ge:compile-file file)))) + +(define-meta-command ((geiser-newline geiser) repl) + "geiser-newline +Meta-command used by Geiser to emit a new line." + (newline)) -- cgit v1.2.3 From 52f219c47fc5aa1831735823530c83bb34056aef Mon Sep 17 00:00:00 2001 From: Jose Antonio Ortega Ruiz Date: Sun, 31 Oct 2010 02:34:30 +0100 Subject: Autodoc: fix for improper macro arglists scanning --- scheme/guile/geiser/doc.scm | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'scheme') diff --git a/scheme/guile/geiser/doc.scm b/scheme/guile/geiser/doc.scm index 4722238..f5471b5 100644 --- a/scheme/guile/geiser/doc.scm +++ b/scheme/guile/geiser/doc.scm @@ -87,12 +87,14 @@ (else #f)))) (define (macro-args tf) + (define* (collect args #:optional (req '())) + (cond ((null? args) (arglist->args `(,(reverse req) #f #f r #f))) + ((symbol? args) (arglist->args `(,(reverse req) #f #f r ,args))) + ((and (pair? args) (symbol? (car args))) + (collect (cdr args) (cons (car args) req))) + (else #f))) (let* ((pats (procedure-property tf 'patterns)) - (args (and pats (filter identity - (map (lambda (p) - (and (every symbol? p) - (list (cons 'required p)))) - pats))))) + (args (and pats (filter-map collect pats)))) (or (and args (not (null? args)) args) default-macro-args))) (define (arity->args art) -- cgit v1.2.3 From ea42746970657bc05b31c462a01df21d079e4a9e Mon Sep 17 00:00:00 2001 From: Jose Antonio Ortega Ruiz Date: Mon, 1 Nov 2010 01:45:58 +0100 Subject: Guile: better meta-command args handling --- elisp/geiser-guile.el | 26 +++++--------------------- scheme/guile/geiser/emacs.scm | 2 +- 2 files changed, 6 insertions(+), 22 deletions(-) (limited to 'scheme') diff --git a/elisp/geiser-guile.el b/elisp/geiser-guile.el index f0d090d..93d1237 100644 --- a/elisp/geiser-guile.el +++ b/elisp/geiser-guile.el @@ -113,34 +113,18 @@ 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 - (set-syntax-table scheme-mode-syntax-table) - (insert str) - (goto-char (point-min)) - (let ((kill-whole-line nil)) - (while (> (skip-syntax-forward "^<") 0) - (let ((p (point))) - (end-of-line) - (kill-region p (point))))) - (goto-char (point-min)) - (while (search-forward-regexp "\n[ \t\r\n]*" nil t) - (replace-match " ")) - (buffer-string)) - str)) - (defsubst geiser-guile--linearize-args (args) - (mapconcat 'geiser-guile--linearize args " ")) + (mapconcat 'identity args " ")) (defun geiser-guile--geiser-procedure (proc &rest args) (case proc - ((eval compile) (format ",geiser-eval %s %s" + ((eval compile) (format ",geiser-eval %s %s%s" (or (car args) "#f") - (geiser-guile--linearize-args (cdr args)))) + (geiser-guile--linearize-args (cdr args)) + (if (cddr 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))))) + (t (format "ge:%s (%s)" proc (geiser-guile--linearize-args args))))) (defconst geiser-guile--module-re "(define-module +\\(([^)]+)\\)") diff --git a/scheme/guile/geiser/emacs.scm b/scheme/guile/geiser/emacs.scm index 73c02d0..54e5d34 100644 --- a/scheme/guile/geiser/emacs.scm +++ b/scheme/guile/geiser/emacs.scm @@ -26,7 +26,7 @@ No-op command used internally by Geiser." (values)) -(define-meta-command ((geiser-eval geiser) repl mod form . args) +(define-meta-command ((geiser-eval geiser) repl (mod form args) . rest) "geiser-eval Meta-command used by Geiser to evaluate and compile code." (if (null? args) -- cgit v1.2.3