]> rhodes.io Git - swankr.git/commitdiff
Christophe Weblog Wiki Code Publications Music
make contribs load when the working directory isn't swankr's
authorChristophe Rhodes <csr21@cantab.net>
Sat, 20 Aug 2011 08:57:50 +0000 (09:57 +0100)
committerChristophe Rhodes <csr21@cantab.net>
Sat, 20 Aug 2011 08:57:50 +0000 (09:57 +0100)
depends on swank.R itself being source()d with chdir=TRUE, but doesn't
break any previously-working use case.

swank.R

diff --git a/swank.R b/swank.R
index ebf580c510af115b66c703f4557797917b72c27e..11210e28d415f6f102899b4e9b672d0b352453c4 100644 (file)
--- a/swank.R
+++ b/swank.R
 ### latest version of the GNU General Public Licence is available at
 ### <http://www.gnu.org/licenses/gpl.txt>.
 
+### KLUDGE: this assumes that we're being sourced with chdir=TRUE.
+### (If not, `swank:swank-require` will work under the circumstances
+### that it used to work anyway -- i.e. the working directory is the
+### swankr directory)
+swankrPath <- getwd() 
+
 swank <- function(port=4005) {
   acceptConnections(port, FALSE)
 }
@@ -288,7 +294,7 @@ printToString <- function(val) {
 
 `swank:swank-require` <- function (slimeConnection, sldbState, contribs) {
   for(contrib in contribs) {
-    filename <- sprintf("%s.R", as.character(contrib))
+    filename <- sprintf("%s/%s.R", swankrPath, as.character(contrib))
     if(file.exists(filename)) {
       source(filename)
     }