Christophe Weblog Wiki Code Publications Music
implement swank:load-file and swank:compile-file-for-emacs
authorChristophe Rhodes <csr21@cantab.net>
Fri, 1 Oct 2010 18:58:33 +0000 (19:58 +0100)
committerChristophe Rhodes <csr21@cantab.net>
Fri, 1 Oct 2010 18:58:33 +0000 (19:58 +0100)
Easy, peasy.  The only trick here is to use parse() in the case that
compile-file-for-emacs is not being asked to load the `compiled' file.

TODO.org
swank.R

index 4dc1cde..180cd94 100644 (file)
--- a/TODO.org
+++ b/TODO.org
@@ -3,7 +3,7 @@
 #+EMAIL: csr21@cantab.net
 #+OPTIONS: H:2
 * Protocol requests
-** core slimefuns [31/95]
+** core slimefuns [33/95]
    - [ ] ping
    - [X] create-repl
    - [ ] create-listener
    - [ ] sldb-step
    - [ ] sldb-next
    - [ ] sldb-out
-   - [ ] compile-file-for-emacs
+   - [X] compile-file-for-emacs
    - [X] compile-string-for-emacs
    - [ ] compile-multiple-strings-for-emacs
    - [ ] compile-file-if-needed
-   - [ ] load-file
+   - [X] load-file
    - [X] swank-require
    - [ ] swank-macroexpand-1
    - [ ] swank-macroexpand
diff --git a/swank.R b/swank.R
index 5fe20bb..22cec64 100644 (file)
--- a/swank.R
+++ b/swank.R
@@ -622,3 +622,17 @@ emacsInspect.numeric <- function(numeric) {
   setwd(directory)
   `swank:default-directory`(slimeConnection, sldbState)
 }
+
+`swank:load-file` <- function(slimeConnection, sldbState, filename) {
+  source(filename, local=FALSE)
+  TRUE
+}
+
+`swank:compile-file-for-emacs` <- function(slimeConnection, sldbState, filename, loadp, ...) {
+  if(loadp==quote(`t`)) {
+    source(filename, local=FALSE)
+  } else {
+    parse(filename)
+  }
+  TRUE
+}