@@ -121,16 +121,19 @@ instance SExpable OutputAnnotation where
121 (SymbolAtom "doc-overview", StringAtom doc)] ++
121 (SymbolAtom "doc-overview", StringAtom doc)] ++
122 if not (null name) then [(SymbolAtom "name", StringAtom name)] else []
122 if not (null name) then [(SymbolAtom "name", StringAtom name)] else []
123 toSExp AnnKeyword = toSExp [(SymbolAtom "decor", SymbolAtom "keyword")]
123 toSExp AnnKeyword = toSExp [(SymbolAtom "decor", SymbolAtom "keyword")]
124− toSExp (AnnFC (FC f (sl, sc) (el, ec))) = toSExp [(SymbolAtom "source-loc",
124+ toSExp (AnnFC fc) = toSExp [(SymbolAtom "source-loc", toSExp fc)]
125− ((SymbolAtom "filename", StringAtom f),
126− (SymbolAtom "start", IntegerAtom (toInteger sl), IntegerAtom (toInteger sc)),
127− (SymbolAtom "end", IntegerAtom (toInteger el), IntegerAtom (toInteger ec))))]
128 toSExp (AnnTextFmt fmt) = toSExp [(SymbolAtom "text-formatting", SymbolAtom format)]
125 toSExp (AnnTextFmt fmt) = toSExp [(SymbolAtom "text-formatting", SymbolAtom format)]
129 where format = case fmt of
126 where format = case fmt of
130 BoldText -> "bold"
127 BoldText -> "bold"
131 ItalicText -> "italic"
128 ItalicText -> "italic"
132 UnderlineText -> "underline"
129 UnderlineText -> "underline"
131+instance SExpable FC where
132+ toSExp (FC f (sl, sc) (el, ec)) =
133+ toSExp ((SymbolAtom "filename", StringAtom f),
134+ (SymbolAtom "start", IntegerAtom (toInteger sl), IntegerAtom (toInteger sc)),
135+ (SymbolAtom "end", IntegerAtom (toInteger el), IntegerAtom (toInteger ec)))
134escape :: String -> String
137escape :: String -> String
135escape = concatMap escapeChar
138escape = concatMap escapeChar
@@ -171,9 +174,9 @@ data IdeSlaveCommand = REPLCompletions String
171 | AddProofClause Int String
174 | AddProofClause Int String
172 | AddMissing Int String
175 | AddMissing Int String
173 | MakeWithBlock Int String
176 | MakeWithBlock Int String
174− | ProofSearch Bool Int String [String]
177+ | ProofSearch Bool Int String [String] (Maybe Int) -- ^^ Recursive?, line, name, hints, depth
175 | MakeLemma Int String
178 | MakeLemma Int String
176− | LoadFile String
179+ | LoadFile String (Maybe Int)
177 | DocsFor String
180 | DocsFor String
178 | Apropos String
181 | Apropos String
179 | GetOpts
182 | GetOpts
@@ -186,7 +189,8 @@ sexpToCommand :: SExp -> Maybe IdeSlaveCommand
186sexpToCommand (SexpList (x:[])) = sexpToCommand x
189sexpToCommand (SexpList (x:[])) = sexpToCommand x
187sexpToCommand (SexpList [SymbolAtom "interpret", StringAtom cmd]) = Just (Interpret cmd)
190sexpToCommand (SexpList [SymbolAtom "interpret", StringAtom cmd]) = Just (Interpret cmd)
188sexpToCommand (SexpList [SymbolAtom "repl-completions", StringAtom prefix]) = Just (REPLCompletions prefix)
191sexpToCommand (SexpList [SymbolAtom "repl-completions", StringAtom prefix]) = Just (REPLCompletions prefix)
189−sexpToCommand (SexpList [SymbolAtom "load-file", StringAtom filename]) = Just (LoadFile filename)
192+sexpToCommand (SexpList [SymbolAtom "load-file", StringAtom filename, IntegerAtom line]) = Just (LoadFile filename (Just (fromInteger line)))
193+sexpToCommand (SexpList [SymbolAtom "load-file", StringAtom filename]) = Just (LoadFile filename Nothing)
190sexpToCommand (SexpList [SymbolAtom "type-of", StringAtom name]) = Just (TypeOf name)
194sexpToCommand (SexpList [SymbolAtom "type-of", StringAtom name]) = Just (TypeOf name)
191sexpToCommand (SexpList [SymbolAtom "case-split", IntegerAtom line, StringAtom name]) = Just (CaseSplit (fromInteger line) name)
195sexpToCommand (SexpList [SymbolAtom "case-split", IntegerAtom line, StringAtom name]) = Just (CaseSplit (fromInteger line) name)
192sexpToCommand (SexpList [SymbolAtom "add-clause", IntegerAtom line, StringAtom name]) = Just (AddClause (fromInteger line) name)
196sexpToCommand (SexpList [SymbolAtom "add-clause", IntegerAtom line, StringAtom name]) = Just (AddClause (fromInteger line) name)
@@ -196,12 +200,17 @@ sexpToCommand (SexpList [SymbolAtom "make-with", IntegerAtom line, StringAtom na
196-- The Boolean in ProofSearch means "search recursively"
200-- The Boolean in ProofSearch means "search recursively"
197-- If it's False, that means "refine", i.e. apply the name and fill in any
201-- If it's False, that means "refine", i.e. apply the name and fill in any
198-- arguments which can be done by unification.
202-- arguments which can be done by unification.
199−sexpToCommand (SexpList [SymbolAtom "proof-search", IntegerAtom line, StringAtom name, SexpList hintexp]) | Just hints <- getHints hintexp = Just (ProofSearch True (fromInteger line) name hints)
203+sexpToCommand (SexpList (SymbolAtom "proof-search" : IntegerAtom line : StringAtom name : rest))
204+ | [] <- rest = Just (ProofSearch True (fromInteger line) name [] Nothing)
205+ | [SexpList hintexp] <- rest
206+ , Just hints <- getHints hintexp = Just (ProofSearch True (fromInteger line) name hints Nothing)
207+ | [SexpList hintexp, IntegerAtom depth] <- rest
208+ , Just hints <- getHints hintexp = Just (ProofSearch True (fromInteger line) name hints (Just (fromInteger depth)))
200− where getHints = mapM (\h -> case h of
209+ where getHints = mapM (\h -> case h of
201− StringAtom s -> Just s
210+ StringAtom s -> Just s
202− _ -> Nothing)
211+ _ -> Nothing)
203sexpToCommand (SexpList [SymbolAtom "make-lemma", IntegerAtom line, StringAtom name]) = Just (MakeLemma (fromInteger line) name)
212sexpToCommand (SexpList [SymbolAtom "make-lemma", IntegerAtom line, StringAtom name]) = Just (MakeLemma (fromInteger line) name)
204−sexpToCommand (SexpList [SymbolAtom "refine", IntegerAtom line, StringAtom name, StringAtom hint]) = Just (ProofSearch False (fromInteger line) name [hint])
213+sexpToCommand (SexpList [SymbolAtom "refine", IntegerAtom line, StringAtom name, StringAtom hint]) = Just (ProofSearch False (fromInteger line) name [hint] Nothing)
205sexpToCommand (SexpList [SymbolAtom "docs-for", StringAtom name]) = Just (DocsFor name)
214sexpToCommand (SexpList [SymbolAtom "docs-for", StringAtom name]) = Just (DocsFor name)
206sexpToCommand (SexpList [SymbolAtom "apropos", StringAtom search]) = Just (Apropos search)
215sexpToCommand (SexpList [SymbolAtom "apropos", StringAtom search]) = Just (Apropos search)
207sexpToCommand (SymbolAtom "get-options") = Just GetOpts
216sexpToCommand (SymbolAtom "get-options") = Just GetOpts