summaryrefslogtreecommitdiff
path: root/elisp/geiser-chicken.el
diff options
context:
space:
mode:
authorDan Leslie <dan@ironoxide.ca>2015-09-01 21:13:32 -0700
committerDan Leslie <dan@ironoxide.ca>2015-09-01 21:17:35 -0700
commit42f70b098aaed948de64891165c8cbeebd61b230 (patch)
tree242ff0d0cd4a1f952b1c297d92b33228f05c1250 /elisp/geiser-chicken.el
parentef3a1a51cf88ff9a86f79d90c71c70d059f934a7 (diff)
downloadgeiser-chez-42f70b098aaed948de64891165c8cbeebd61b230.tar.gz
geiser-chez-42f70b098aaed948de64891165c8cbeebd61b230.tar.bz2
Add compiled .so caching to Chicken support
- Now give compile-file a reasonable destination for the output - Check for aforementioned output and skip the compile if exists - None of the above happens if the system-type is 'windows-nt, which may not be a necessary restriction. And, the existing geiser-chicken-compile-geiser-p var applies. Resolves jaor/geiser#73 for non-windows system
Diffstat (limited to 'elisp/geiser-chicken.el')
-rw-r--r--elisp/geiser-chicken.el38
1 files changed, 23 insertions, 15 deletions
diff --git a/elisp/geiser-chicken.el b/elisp/geiser-chicken.el
index 070d916..5bf45f2 100644
--- a/elisp/geiser-chicken.el
+++ b/elisp/geiser-chicken.el
@@ -263,23 +263,31 @@ This function uses `geiser-chicken-init-file' if it exists."
(interactive)
(geiser-connect 'chicken))
+(defun geiser-chicken--compile-or-load (force-load)
+ (let ((target
+ (expand-file-name "chicken/geiser/emacs.so" geiser-scheme-dir))
+ (source
+ (expand-file-name "chicken/geiser/emacs.scm" geiser-scheme-dir))
+ (force-load (or force-load (eq system-type 'windows-nt)))
+ (suppression-prefix
+ "(define geiser-stdout (current-output-port))(current-output-port (make-output-port (lambda a #f) (lambda a #f)))")
+ (suppression-postfix
+ "(current-output-port geiser-stdout)"))
+ (let ((load-sequence
+ (cond
+ (force-load
+ (format "(load \"%s\")\n" source))
+ ((file-exists-p target)
+ (format "%s(load \"%s\")(import geiser)%s\n"
+ suppression-prefix target suppression-postfix))
+ (t
+ (format "%s(use utils)(compile-file \"%s\" options: '(\"-O3\") output-file: \"%s\" load: #t)(import geiser)%s\n"
+ suppression-prefix source target suppression-postfix)))))
+ (geiser-eval--send/wait load-sequence))))
+
(defun geiser-chicken--startup (remote)
(compilation-setup t)
- (let ((geiser-log-verbose-p t)
- (geiser-chicken-load-file (expand-file-name "chicken/geiser/emacs.scm" geiser-scheme-dir)))
- (if geiser-chicken-compile-geiser-p
- (geiser-eval--send/wait (format "
-;; Sadly, (use import compile-file) must be run at top-level, so we have a stdout binding
-(define geiser-stdout (current-output-port))
-(current-output-port (make-output-port (lambda a #f) (lambda a #f)))
-(use utils)
-(compile-file \"%s\")
-(import geiser)
-(current-output-port geiser-stdout)
-"
- geiser-chicken-load-file))
- (geiser-eval--send/wait (format "(load \"%s\")"
- geiser-chicken-load-file)))))
+ (geiser-chicken--compile-or-load (not geiser-chicken-compile-geiser-p)))
;;; Implementation definition: