summaryrefslogtreecommitdiff
path: root/elisp
diff options
context:
space:
mode:
Diffstat (limited to 'elisp')
-rw-r--r--elisp/geiser-base.el3
-rw-r--r--elisp/geiser-compile.el77
-rw-r--r--elisp/geiser-mode.el3
-rw-r--r--elisp/geiser-repl.el5
4 files changed, 85 insertions, 3 deletions
diff --git a/elisp/geiser-base.el b/elisp/geiser-base.el
index 4634a29..439a047 100644
--- a/elisp/geiser-base.el
+++ b/elisp/geiser-base.el
@@ -77,6 +77,9 @@
;;; Utilities:
+(defsubst geiser--chomp (str)
+ (if (string-match-p ".*\n$" str) (substring str 0 -1) str))
+
(defun geiser--shorten-str (str len &optional sep)
(let ((str-len (length str)))
(if (<= str-len len)
diff --git a/elisp/geiser-compile.el b/elisp/geiser-compile.el
new file mode 100644
index 0000000..f90c24d
--- /dev/null
+++ b/elisp/geiser-compile.el
@@ -0,0 +1,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
diff --git a/elisp/geiser-mode.el b/elisp/geiser-mode.el
index b5abfca..18accb4 100644
--- a/elisp/geiser-mode.el
+++ b/elisp/geiser-mode.el
@@ -25,6 +25,7 @@
;;; Code:
+(require 'geiser-compile)
(require 'geiser-completion)
(require 'geiser-autodoc)
(require 'geiser-eval)
@@ -150,7 +151,7 @@ interacting with the Geiser REPL is at your disposal.
(define-key geiser-mode-map "\C-c\C-x" 'geiser-expand-current-form)
(define-key geiser-mode-map "\C-c\C-z" 'switch-to-guile)
(define-key geiser-mode-map "\C-c\C-l" 'geiser-load-file)
-(define-key geiser-mode-map "\C-c\C-k" 'geiser-compile-file)
+(define-key geiser-mode-map "\C-c\C-k" 'geiser-compile-current-buffer)
(provide 'geiser-mode)
diff --git a/elisp/geiser-repl.el b/elisp/geiser-repl.el
index fcc0daa..3cb84b8 100644
--- a/elisp/geiser-repl.el
+++ b/elisp/geiser-repl.el
@@ -25,6 +25,7 @@
;;; Code:
+(require 'geiser-compile)
(require 'geiser-eval)
(require 'geiser-connection)
(require 'geiser-base)
@@ -141,18 +142,18 @@ the Geiser REPL buffer."
(define-key geiser-repl-mode-map "\C-c\C-z" 'run-guile)
(define-key geiser-repl-mode-map "\C-a" 'geiser-repl--bol)
(define-key geiser-repl-mode-map "\C-ca" 'geiser-autodoc-mode)
+(define-key geiser-repl-mode-map "\C-ck" 'geiser-compile-file)
(define-key geiser-repl-mode-map "\M-p" 'comint-previous-matching-input-from-input)
(define-key geiser-repl-mode-map "\M-n" 'comint-next-matching-input-from-input)
(define-key geiser-repl-mode-map "\C-c\M-p" 'comint-previous-input)
-(define-key geiser-repl-mode-map "\C-c\M-n" 'comint-next-input))
+(define-key geiser-repl-mode-map "\C-c\M-n" 'comint-next-input)
(define-key geiser-repl-mode-map (kbd "TAB") 'geiser-completion--complete-symbol)
;; (define-key geiser-repl-mode-map "\C-ch" 'geiser-help)
;; (define-key geiser-repl-mode-map "\C-cp" 'geiser-apropos)
;; (define-key geiser-repl-mode-map "\M-." 'geiser-edit-word-at-point)
-;; (define-key geiser-repl-mode-map "\C-ck" 'geiser-compile-file)
(provide 'geiser-repl)