summaryrefslogtreecommitdiff
path: root/scheme/guile/geiser/emacs.scm
blob: 54e5d348f6d5bb688496e254d16b648d84ebfffe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
;;; emacs.scm -- procedures for emacs interaction: entry point

;; Copyright (C) 2009, 2010 Jose Antonio Ortega Ruiz

;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the Modified BSD License. You should
;; have received a copy of the license along with this program. If
;; not, see <http://www.xfree86.org/3.3.6/COPYRIGHT2.html#5>.

;; Start date: Sun Feb 08, 2009 18:39

(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:))
  #:use-module ((geiser xref) :renamer (symbol-prefix-proc 'ge:))
  #:use-module ((geiser doc) :renamer (symbol-prefix-proc 'ge:)))

(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) . rest)
  "geiser-eval
Meta-command used by Geiser to evaluate and compile code."
  (if (null? args)
      (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."
  (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))