on master help sign in
Use system to allow $EDITOR with args

Fixes #2963

commit799b4321a19b41b8e74069ecd6a3dc493a7bfe63 authorNiklas Larsson <niklas@mm.st> dateSat 9 Jul 2016, 21:59 (10 years ago) parente2005e1
2 files changed+14−6
CHANGELOG.md+5 src/Idris/REPL.hs+9−6
CHANGELOG.md+5
@@ -39,6 +39,11 @@
3939* The test suite now uses [tasty-golden](https://hackage.haskell.org/package/tasty-golden). New tests must be registered in `test/TestData.hs`, as explained in the relevant `README.md`.
4040* Added OSX and Windows continous integration with Travis and Appveyor.
4141
42+## UI Changes
43+
44+* The :e command can now handle an $EDITOR with arguments in it, like "emacs -nw"
45+
46+
4247# New in 0.12:
4348
4449## Language updates
src/Idris/REPL.hs+9−6
@@ -786,10 +786,10 @@ edit f orig
786786 env <- runIO getEnvironment
787787 let editor = getEditor env
788788 let line = case errSpan i of
789− Just l -> ['+' : show (fst (fc_start l))]
790− Nothing -> []
791− let args = line ++ [fixName f]
792− runIO $ rawSystem editor args
789+ Just l -> '+' : show (fst (fc_start l))
790+ Nothing -> ""
791+ let cmdLine = intercalate " " [editor, line, fixName f]
792+ runIO $ system cmdLine
793793 clearErr
794794 -- The $!! here prevents a space leak on reloading.
795795 -- This isn't a solution - but it's a temporary stopgap.
@@ -804,8 +804,11 @@ edit f orig
804804 where getEditor env | Just ed <- lookup "EDITOR" env = ed
805805 | Just ed <- lookup "VISUAL" env = ed
806806 | otherwise = "vi"
807− fixName file | map toLower (takeExtension file) `elem` [".lidr", ".idr"] = file
808− | otherwise = addExtension file "idr"
807+ fixName file | map toLower (takeExtension file) `elem` [".lidr", ".idr"] = quote file
808+ | otherwise = quote $ addExtension file "idr"
809+ where
810+ quoteChar = if isWindows then '"' else '\''
811+ quote s = [quoteChar] ++ s ++ [quoteChar]
809812
810813
811814