blob: b0ef47324b2b9b24be7cc4a83868cffa2f0fd1d2 (
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
;; geiser-chibi.el -- Chibi Scheme's implementation of the geiser protocols
;; 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>.
(require 'geiser-connection)
(require 'geiser-syntax)
(require 'geiser-custom)
(require 'geiser-base)
(require 'geiser-eval)
(require 'geiser-edit)
(require 'geiser-log)
(require 'geiser)
(require 'compile)
(require 'info-look)
(eval-when-compile (require 'cl))
;;; Customization:
(defgroup geiser-chibi nil
"Customization for Geiser's Chibi Scheme flavour."
:group 'geiser)
(geiser-custom--defcustom geiser-chibi-binary
"chibi-scheme"
"Name to use to call the Chibi Scheme executable when starting a REPL."
:type '(choice string (repeat string))
:group 'geiser-chibi)
;;; REPL support:
(defun geiser-chibi--binary ()
(if (listp geiser-chibi-binary)
(car geiser-chibi-binary)
geiser-chibi-binary))
(defun geiser-chibi--parameters ()
"Return a list with all parameters needed to start Chibi Scheme.
This function uses `geiser-chibi-init-file' if it exists."
;; `("--load" ,(expand-file-name "chibi/geiser/load.scm" geiser-scheme-dir))
`("-I" ,(expand-file-name "chibi/geiser/" geiser-scheme-dir)
"-m" "geiser")
)
(defconst geiser-chibi--prompt-regexp "> ")
;;; Evaluation support:
(defun geiser-chibi--geiser-procedure (proc &rest args)
(case proc
((eval compile)
(let ((form (mapconcat 'identity (cdr args) " "))
(module (cond ((string-equal "'()" (car args))
"'()")
((and (car args))
(concat "'" (car args)))
(t
"#f"))))
(format "(geiser:eval %s '%s)" module form)))
((load-file compile-file)
(format "(geiser:load-file %s)" (car args)))
((no-values)
"(geiser:no-values)")
(t
(let ((form (mapconcat 'identity args " ")))
(format "(geiser:%s %s)" proc form)))))
;; (defconst geiser-chibi--module-re
;; ".*;; package: +\\(([^)]*)\\)")
(defun geiser-chibi--get-module (&optional module)
(cond ((null module)
:f)
((listp module) module)
((stringp module)
(condition-case nil
(car (geiser-syntax--read-from-string module))
(error :f)))
(t :f)))
;; (defun geiser-chibi--module-cmd (module fmt &optional def)
;; (when module
;; (let* ((module (geiser-chibi--get-module module))
;; (module (cond ((or (null module) (eq module :f)) def)
;; (t (format "%s" module)))))
;; (and module (format fmt module)))))
;; (defun geiser-chibi--enter-command (module)
;; (geiser-chibi--module-cmd module "(geiser:ge '%s)" "()"))
(defun geiser-chibi--symbol-begin (module)
(if module
(max (save-excursion (beginning-of-line) (point))
(save-excursion (skip-syntax-backward "^(>") (1- (point))))
(save-excursion (skip-syntax-backward "^'-()>") (point))))
(defun geiser-chibi--import-command (module)
(format "(import %s)" module))
(defun geiser-chibi--exit-command () "(exit 0)")
;;
;; ;;; REPL startup
(defconst geiser-chibi-minimum-version "0.7.3")
(defun geiser-chibi--version (binary)
(second (split-string (shell-command-to-string
(format "%s -V"
(shell-quote-argument binary)))
" ")))
;; (defconst geiser-chibi--path-rx "^In \\([^:\n ]+\\):\n")
(defun geiser-chibi--startup (remote)
(let ((geiser-log-verbose-p t))
(compilation-setup t)
;; (when (and (stringp geiser-chibi-source-directory)
;; (not (string-empty-p geiser-chibi-source-directory)))
;; (geiser-eval--send/wait (format "(geiser:set-chibi-scheme-source-directory %S)" geiser-chibi-source-directory)))
))
;;; Implementation definition:
(define-geiser-implementation chibi
(binary geiser-chibi--binary)
(arglist geiser-chibi--parameters)
(version-command geiser-chibi--version)
(minimum-version geiser-chibi-minimum-version)
(repl-startup geiser-chibi--startup)
(prompt-regexp geiser-chibi--prompt-regexp)
(debugger-prompt-regexp nil) ;; geiser-chibi--debugger-prompt-regexp
;; (enter-debugger geiser-chibi--enter-debugger)
(marshall-procedure geiser-chibi--geiser-procedure)
(find-module geiser-chibi--get-module)
;; (enter-command geiser-chibi--enter-command)
(exit-command geiser-chibi--exit-command)
(import-command geiser-chibi--import-command)
(find-symbol-begin geiser-chibi--symbol-begin)
;; (display-error geiser-chibi--display-error)
;; (external-help geiser-chibi--manual-look-up)
;; (check-buffer geiser-chibi--guess)
;; (keywords geiser-chibi--keywords)
;; (case-sensitive geiser-chibi-case-sensitive-p)
)
;; notes: (available-modules) in (chibi modules)
;; (env-exports (module-env (find-module '(scheme char)))), modules: (meta) (chibi modules) (chibi)
(geiser-impl--add-to-alist 'regexp "\\.scm$" 'chibi t)
(geiser-impl--add-to-alist 'regexp "\\.sld$" 'chibi t)
(provide 'geiser-chibi)
|