X-Git-Url: http://christophe.rhodes.io/gitweb/?p=swankr.git;a=blobdiff_plain;f=swank.R;h=11210e28d415f6f102899b4e9b672d0b352453c4;hp=8c5bafdccd1d5d198f534d971db0455fba703095;hb=03de6608402c91c474d0e5fb57569631ded3701a;hpb=f362dbb2a366f194cb12a336d99403287e09f8ae diff --git a/swank.R b/swank.R index 8c5bafd..11210e2 100644 --- a/swank.R +++ b/swank.R @@ -13,15 +13,26 @@ ### latest version of the GNU General Public Licence is available at ### . +### 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) } startSwank <- function(portFile) { - acceptConnections(FALSE, portFile) + acceptConnections(4005, portFile) } acceptConnections <- function(port, portFile) { + if(portFile != FALSE) { + f <- file(portFile, open="w+") + cat(port, file=f) + close(f) + } s <- socketConnection(host="localhost", server=TRUE, port=port, open="r+b") on.exit(close(s)) serve(s) @@ -283,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) }