summaryrefslogtreecommitdiff
path: root/scheme/guile/geiser/emacs.scm
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2009-03-02 03:13:59 +0100
committerJose Antonio Ortega Ruiz <jao@gnu.org>2009-03-02 03:13:59 +0100
commit1f80c5048e78d0251c18634b8bf7d3f8ea4733b0 (patch)
tree53f3731ffe00a9c5f361398b086d325ec213c7e0 /scheme/guile/geiser/emacs.scm
parentab27ee71db711b8295dfb6e9f89d059d2310cc5e (diff)
downloadgeiser-chez-1f80c5048e78d0251c18634b8bf7d3f8ea4733b0.tar.gz
geiser-chez-1f80c5048e78d0251c18634b8bf7d3f8ea4733b0.tar.bz2
Breakdown of schemeland into neat submodules.
Diffstat (limited to 'scheme/guile/geiser/emacs.scm')
-rw-r--r--scheme/guile/geiser/emacs.scm128
1 files changed, 12 insertions, 116 deletions
diff --git a/scheme/guile/geiser/emacs.scm b/scheme/guile/geiser/emacs.scm
index f2f3d45..0c99216 100644
--- a/scheme/guile/geiser/emacs.scm
+++ b/scheme/guile/geiser/emacs.scm
@@ -25,128 +25,24 @@
;;; Code:
(define-module (geiser emacs)
- #:export (ge:eval
- ge:compile
- ge:macroexpand
- ge:compile-file
- ge:load-file)
- #:re-export (ge:autodoc
+ #:re-export (ge:eval
+ ge:compile
+ ge:macroexpand
+ ge:compile-file
+ ge:load-file
+ ge:autodoc
ge:completions
ge:symbol-location
+ ge:generic-methods
ge:symbol-documentation
ge:all-modules
ge:module-children
ge:module-location)
- #:use-module (srfi srfi-1)
- #:use-module (system base compile)
- #:use-module (system vm program)
- #:use-module (ice-9 debugger utils)
- #:use-module (ice-9 pretty-print)
- #:use-module ((geiser introspection) :renamer (symbol-prefix-proc 'ge:)))
+ #: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 (make-result result output)
- (list (cons 'result result) (cons 'output output)))
-
-(define (make-error key args stack)
- (list (cons 'error (apply parse-error (cons key args)))
- (cons 'stack (parse-stack stack))))
-
-(define (parse-stack stack)
- (if stack
- (map (lambda (n) (parse-frame (stack-ref stack n)))
- (iota (stack-length stack)))
- '()))
-
-(define (parse-frame frame)
- (list (cons 'frame (frame-number frame))
- (cons 'procedure (or (and (frame-procedure? frame)
- (procedure-name (frame-procedure frame)))
- '()))
- (cons 'source (or (frame->source-position frame) '()))
- (cons 'description (with-output-to-string
- (lambda ()
- (if (frame-procedure? frame)
- (write-frame-short/application frame)
- (write-frame-short/expression frame)))))))
-
-(define (frame->source-position frame)
- (let ((source (if (frame-procedure? frame)
- (or (frame-source frame)
- (let ((proc (frame-procedure frame)))
- (and proc
- (procedure? proc)
- (procedure-source proc))))
- (frame-source frame))))
- (and source
- (cond ((string? (source-property source 'filename))
- (list (source-property source 'filename)
- (+ 1 (source-property source 'line))
- (source-property source 'column)))
- ((and (pair? source) (list? (cadr source)))
- (list (caadr source)
- (+ 1 (caddr source))
- (cdddr source)))
- (else #f)))))
-
-(define (parse-error key . args)
- (let* ((len (length args))
- (subr (and (> len 0) (first args)))
- (msg (and (> len 1) (second args)))
- (margs (and (> len 2) (third args)))
- (rest (and (> len 3) (fourth args))))
- (list (cons 'key key)
- (cons 'subr (or subr '()))
- (cons 'msg (if msg (apply format (cons #f (cons msg margs))) '()))
- (cons 'rest (or rest '())))))
-
-(define (evaluate form module-name evaluator)
- (let ((module (or (and (list? module-name)
- (resolve-module module-name))
- (current-module)))
- (result #f)
- (captured-stack #f)
- (error #f))
- (let ((output
- (with-output-to-string
- (lambda ()
- (set! result
- (catch #t
- (lambda ()
- (start-stack 'id (evaluator form module)))
- (lambda (key . args)
- (set! error (make-error key args captured-stack)))
- (lambda (key . args)
- (set! captured-stack (make-stack #t 2 2)))))))))
- (write (or error (make-result result output)))
- (newline))))
-
-(define (eval-compile form module)
- (save-module-excursion
- (lambda ()
- (set-current-module module)
- (compile form))))
-
-(define (ge:eval form module-name)
- (evaluate form module-name eval))
-
-(define (ge:compile form module-name)
- (evaluate form module-name eval-compile))
-
-(define (ge:compile-file path)
- "Compile and load file, given its full @var{path}."
- (evaluate `(and (compile-file ,path)
- (load-compiled ,(compiled-file-name path)))
- #f
- eval))
-
-(define (ge:load-file path)
- "Load file, given its full @var{path}."
- (evaluate `(load ,path) #f eval))
-
-(define (ge:macroexpand form . all)
- (let ((all (and (not (null? all)) (car all))))
- (with-output-to-string
- (lambda ()
- (pretty-print ((if all macroexpand macroexpand-1) form))))))
;;; emacs.scm ends here