1 ;;; emacs.scm -- procedures for emacs interaction: entry point
3 ;; Copyright (C) 2009, 2010, 2011 Jose Antonio Ortega Ruiz
5 ;; This program is free software; you can redistribute it and/or
6 ;; modify it under the terms of the Modified BSD License. You should
7 ;; have received a copy of the license along with this program. If
8 ;; not, see <http://www.xfree86.org/3.3.6/COPYRIGHT2.html#5>.
10 ;; Start date: Sun Feb 08, 2009 18:39
12 (define-module (geiser emacs)
13 #:use-module (ice-9 match)
14 #:use-module (system repl command)
15 #:use-module (system repl error-handling)
16 #:use-module (system repl server)
17 #:use-module (geiser evaluation)
18 #:use-module ((geiser modules) #:renamer (symbol-prefix-proc 'ge:))
19 #:use-module ((geiser completion) #:renamer (symbol-prefix-proc 'ge:))
20 #:use-module ((geiser xref) #:renamer (symbol-prefix-proc 'ge:))
21 #:use-module ((geiser doc) #:renamer (symbol-prefix-proc 'ge:)))
23 (define this-module (resolve-module '(geiser emacs)))
25 (define-meta-command ((geiser-no-values geiser) repl)
27 No-op command used internally by Geiser."
30 (define-meta-command ((geiser-newline geiser) repl)
32 Meta-command used by Geiser to emit a new line."
35 (define-meta-command ((geiser-eval geiser) repl (mod form args) . rest)
36 "geiser-eval module form args ()
37 Meta-command used by Geiser to evaluate and compile code."
39 (call-with-error-handling
40 (lambda () (ge:compile form mod)))
41 (let ((proc (eval form this-module)))
42 (ge:eval `(,proc ,@args) mod))))
44 (define-meta-command ((geiser-load-file geiser) repl file)
45 "geiser-load-file file
46 Meta-command used by Geiser to load and compile files."
47 (call-with-error-handling
48 (lambda () (ge:compile-file file))))
51 (define-meta-command ((geiser-start-server geiser) repl)
53 Meta-command used by Geiser to start a REPL server."
54 (let* ((sock (make-tcp-server-socket #:port 0))
55 (port (sockaddr:port (getsockname sock))))
57 (write (list 'port port))