on master help sign in
Support :l in server to allow editing multiple files

As long as files are in the same directory, you can interactively edit multiple things now since the vim mode loads the appropriate file before querying/modifying it.

commit386e2a5d3aa52b0a87352a81fc8e830675d98f94 authorEdwin Brady <ecb10@st-andrews.ac.uk> dateTue 29 Oct 2013, 09:45 (13 years ago) parentd7d31d1
2 files changed+24−19
contribs/idriscasesplit.vim+2−1 src/Idris/REPL.hs+22−18
contribs/idriscasesplit.vim+2−1
@@ -1,5 +1,6 @@
11function IdrisReload()
2− let tc = system("idris --client :r")
2+ let file = expand("%")
3+ let tc = system("idris --client :l " . file)
34 if (! (tc is ""))
45 echo tc
56 endif
src/Idris/REPL.hs+22−18
@@ -113,35 +113,39 @@ startServer orig stvar fn_in = do tid <- runIO $ forkOS serverLoop
113113 serverLoop = withSocketsDo $
114114 do sock <- listenOn $ PortNumber 4294
115115 i <- readMVar stvar
116− loop i sock
116+ loop fn i sock
117117
118118 fn = case fn_in of
119119 (f:_) -> f
120120 _ -> ""
121121
122− loop ist sock = do (h,host,_) <- accept sock
123− if (host == "localhost" ||
124− host == "127.0.0.1") then do
125− cmd <- hGetLine h
126− takeMVar stvar
127− ist' <- processNetCmd stvar orig ist h fn cmd
128− putMVar stvar ist'
129− hClose h
130− loop ist' sock
131− else hClose h
122+ loop fn ist sock
123+ = do (h,host,_) <- accept sock
124+ if (host == "localhost" ||
125+ host == "127.0.0.1")
126+ then do
127+ cmd <- hGetLine h
128+ takeMVar stvar
129+ (ist', fn) <- processNetCmd stvar orig ist h fn cmd
130+ putMVar stvar ist'
131+ hClose h
132+ loop fn ist' sock
133+ else hClose h
132134
133135processNetCmd :: MVar IState ->
134− IState -> IState -> Handle -> FilePath -> String -> IO IState
136+ IState -> IState -> Handle -> FilePath -> String ->
137+ IO (IState, FilePath)
135138processNetCmd stvar orig i h fn cmd
136139 = do res <- case parseCmd i "(net)" cmd of
137140 Failure err -> return (Left (Msg " invalid command"))
138141 Success c -> runErrorT $ evalStateT (processNet fn c) i
139142 case res of
140− Right ist -> return ist
143+ Right x -> return x
141144 Left err -> do hPutStrLn h (show err)
142− return i
145+ return (i, fn)
143146 where
144− processNet fn Reload =
147+ processNet fn Reload = processNet fn (Load fn)
148+ processNet fn (Load f) =
145149 do let ist = orig { idris_options = idris_options i
146150 , idris_colourTheme = idris_colourTheme i
147151 , idris_colourRepl = False
@@ -151,12 +155,12 @@ processNetCmd stvar orig i h fn cmd
151155 setOutH h
152156 setQuiet True
153157 setVerbose False
154− mods <- loadInputs h [fn]
158+ mods <- loadInputs h [f]
155159 ist <- getIState
156− return ist
160+ return (ist, f)
157161 processNet fn c = do process h fn c
158162 ist <- getIState
159− return ist
163+ return (ist, fn)
160164
161165-- | Run a command on the server on localhost
162166runClient :: String -> IO ()