summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2009-02-11 10:47:12 +0100
committerJose Antonio Ortega Ruiz <jao@gnu.org>2009-02-11 10:47:12 +0100
commite4c958fe1e5bad829e08dbce31f1a23e458ebd6b (patch)
treeb6144afe718d65839bb1f60ae13d496525be4a03
parent2b2355b6134f5068dfff424f8fda32ae0236a516 (diff)
downloadgeiser-guile-e4c958fe1e5bad829e08dbce31f1a23e458ebd6b.tar.gz
geiser-guile-e4c958fe1e5bad829e08dbce31f1a23e458ebd6b.tar.bz2
Load file commands.
-rw-r--r--elisp/geiser-compile.el80
-rw-r--r--elisp/geiser-mode.el12
-rw-r--r--elisp/geiser-repl.el1
-rw-r--r--scheme/guile/geiser/emacs.scm6
-rw-r--r--scheme/guile/geiser/eval.scm11
5 files changed, 75 insertions, 35 deletions
diff --git a/elisp/geiser-compile.el b/elisp/geiser-compile.el
index f90c24d..a7a7daf 100644
--- a/elisp/geiser-compile.el
+++ b/elisp/geiser-compile.el
@@ -38,39 +38,69 @@
(geiser-popup--define compile "*Geiser compilation*" geiser-compile-mode)
-;;; Compile file command:
+;;; Auxiliary functions:
+
+(defun geiser-compile--buffer/path (&optional path)
+ (let ((path (or path (read-file-name "Scheme file: " nil nil t))))
+ (let ((buffer (find-file-noselect path)))
+ (when (and (buffer-modified-p buffer)
+ (y-or-n-p "Save buffer? "))
+ (save-buffer buffer))
+ (cons buffer path))))
+
+(defun geiser-compile--display-result (title ret)
+ (let ((err (geiser-eval--retort-error ret))
+ (output (geiser-eval--retort-output ret)))
+ (geiser-compile--with-buffer
+ (erase-buffer)
+ (insert title)
+ (newline)
+ (when output
+ (insert output)
+ (newline))
+ (when err
+ (insert "\n" (geiser-eval--error-msg err) "\n"))
+ (goto-char (point-min)))
+ (if (not err)
+ (message "%s %s" title (if (> 0 (length output))
+ (geiser--chomp output)
+ (or (geiser-eval--retort-result ret)
+ "OK!")))
+ (message "")
+ (geiser-compile--pop-to-buffer))))
+
+(defun geiser-compile--file-op (path op msg)
+ (let* ((b/p (geiser-compile--buffer/path path))
+ (buffer (car b/p))
+ (path (cdr b/p))
+ (msg (format "%s %s ..." msg path)))
+ (message msg)
+ (geiser-compile--display-result
+ msg (geiser-eval--send/wait `(:gs ((:ge ,op) ,path))))))
+
+
+;;; User commands::
-(defun geiser-compile-file (&optional path)
+(defun geiser-compile-file (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)))))
+ (interactive "FScheme file: ")
+ (geiser-compile--file-op path 'compile-file "Compiling"))
(defun geiser-compile-current-buffer ()
"Compile and load current Scheme file."
(interactive)
(geiser-compile-file (buffer-file-name (current-buffer))))
+(defun geiser-load-file (path)
+ "Load Scheme file."
+ (interactive "FScheme file: ")
+ (geiser-compile--file-op path 'load-file "Loading"))
+
+(defun geiser-load-current-buffer ()
+ "Load current Scheme file."
+ (interactive)
+ (geiser-load-file (buffer-file-name (current-buffer))))
+
(provide 'geiser-compile)
diff --git a/elisp/geiser-mode.el b/elisp/geiser-mode.el
index 18accb4..f5798e5 100644
--- a/elisp/geiser-mode.el
+++ b/elisp/geiser-mode.el
@@ -137,21 +137,25 @@ interacting with the Geiser REPL is at your disposal.
;;; Keys:
+(define-key geiser-mode-map "\C-c\C-z" 'switch-to-guile)
+(define-key geiser-mode-map "\C-c\C-l" 'geiser-load-current-buffer)
+(define-key geiser-mode-map "\C-c\C-k" 'geiser-compile-current-buffer)
+
(define-key geiser-mode-map (kbd "M-TAB") 'geiser-completion--complete-symbol)
+
(define-key geiser-mode-map "\M-\C-x" 'geiser-send-definition)
-(define-key geiser-mode-map "\C-c\C-a" 'geiser-autodoc-mode)
(define-key geiser-mode-map "\C-x\C-e" 'geiser-send-last-sexp)
(define-key geiser-mode-map "\C-c\C-e" 'geiser-send-definition)
(define-key geiser-mode-map "\C-c\M-e" 'geiser-send-definition-and-go)
(define-key geiser-mode-map "\C-c\C-r" 'geiser-send-region)
(define-key geiser-mode-map "\C-c\M-r" 'geiser-send-region-and-go)
+
+(define-key geiser-mode-map "\C-c\C-a" 'geiser-autodoc-mode)
+
(define-key geiser-mode-map "\C-c\M-c" 'geiser-compile-definition)
(define-key geiser-mode-map "\C-c\C-c" 'geiser-compile-definition-and-go)
(define-key geiser-mode-map "\C-c\C-t" 'geiser-trace-procedure)
(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-current-buffer)
(provide 'geiser-mode)
diff --git a/elisp/geiser-repl.el b/elisp/geiser-repl.el
index 3cb84b8..d757bef 100644
--- a/elisp/geiser-repl.el
+++ b/elisp/geiser-repl.el
@@ -143,6 +143,7 @@ the Geiser REPL buffer."
(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 "\C-cl" 'geiser-load-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)
diff --git a/scheme/guile/geiser/emacs.scm b/scheme/guile/geiser/emacs.scm
index 318b07a..38ddc7c 100644
--- a/scheme/guile/geiser/emacs.scm
+++ b/scheme/guile/geiser/emacs.scm
@@ -27,11 +27,13 @@
(define-module (geiser emacs)
#:re-export (ge:proc-args
ge:completions
- ge:compile-file)
+ ge:compile-file
+ ge:load-file)
#:use-module ((geiser introspection)
:renamer (symbol-prefix-proc 'ge:))
#:use-module ((geiser eval)
- :select ((comp-file . ge:compile-file))))
+ :select ((comp-file . ge:compile-file)
+ (load-file . ge:load-file))))
;;; emacs.scm ends here
diff --git a/scheme/guile/geiser/eval.scm b/scheme/guile/geiser/eval.scm
index 530099d..1400566 100644
--- a/scheme/guile/geiser/eval.scm
+++ b/scheme/guile/geiser/eval.scm
@@ -25,7 +25,7 @@
;;; Code:
(define-module (geiser eval)
- #:export (eval-in comp-file)
+ #:export (eval-in comp-file load-file)
#:use-module (srfi srfi-1))
(define (eval-in form module-name)
@@ -70,9 +70,12 @@ SUBR, MSG and REST."
(current (getcwd)))
(dynamic-wind
(lambda () (chdir dest))
- (lambda ()
- (compile-file path)
- (compile-and-load path))
+ (lambda () (compile-file path))
(lambda () (chdir current)))))
+(define (load-file path)
+ "Load file, given its full @var{path}."
+ (compile-and-load path))
+
+
;;; eval.scm ends here