blob: f90c24d8d0e0db2bb3657f8eba3bc4724131362b (
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
|
;; geiser-compile.el -- compile/load scheme files
;; Copyright (C) 2009 Jose Antonio Ortega Ruiz
;; Author: Jose Antonio Ortega Ruiz <jao@gnu.org>
;; Start date: Wed Feb 11, 2009 00:16
;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3 of the License, or
;; (at your option) any later version.
;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Comentary:
;; Functions to compile and load Scheme files.
;;; Code:
(require 'geiser-eval)
(require 'geiser-popup)
(require 'geiser-base)
;;; Compilation buffer:
(define-derived-mode geiser-compile-mode compilation-mode "Geiser Compilation"
"Major mode showing the results of compiling or loading scheme files.
\{geiser-compile-mode-keymap}")
(geiser-popup--define compile "*Geiser compilation*" geiser-compile-mode)
;;; Compile file command:
(defun geiser-compile-file (&optional path)
"Compile and load Scheme file."
(interactive (or path (read-file-name "Scheme file: " nil nil t)))
(let ((buffer (find-file-noselect path))
(msg (format "Compiling %s ..." path)))
(when (and (buffer-modified-p buffer)
(y-or-n-p "Save buffer? "))
(save-buffer buffer))
(message msg)
(let* ((ret (geiser-eval--send/wait `(:gs ((:ge compile-file) ,path))))
(err (geiser-eval--retort-error ret))
(output (geiser-eval--retort-output ret)))
(geiser-compile--with-buffer
(erase-buffer)
(insert msg)
(newline)
(when output
(insert output)
(newline))
(when err
(insert "\n" (geiser-eval--error-str err) "\n")))
(if (not err)
(message "%s %s" msg (if output (geiser--chomp output) "OK!"))
(message "")
(geiser-compile--pop-to-buffer)))))
(defun geiser-compile-current-buffer ()
"Compile and load current Scheme file."
(interactive)
(geiser-compile-file (buffer-file-name (current-buffer))))
(provide 'geiser-compile)
;;; geiser-compile.el ends here
|