aboutsummaryrefslogtreecommitdiff
path: root/lib/edit.ml
diff options
context:
space:
mode:
Diffstat (limited to 'lib/edit.ml')
-rw-r--r--lib/edit.ml22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/edit.ml b/lib/edit.ml
index 096fa5dc13..06a55d171d 100644
--- a/lib/edit.ml
+++ b/lib/edit.ml
@@ -84,6 +84,28 @@ let undo e n =
errorlabstrm "Edit.undo" (str"Undo stack exhausted");
repeat n Bstack.pop bs
+(* Return the depth of the focused proof of [e] stack, this is used to
+ put informations in coq prompt (in emacs mode). *)
+let depth e =
+ match e.focus with
+ | None -> invalid_arg "Edit.depth"
+ | Some d ->
+ let (bs,_) = Hashtbl.find e.buf d in
+ Bstack.depth bs
+
+(* Undo focused proof of [e] to reach depth [n] *)
+let undo_todepth e n =
+ match e.focus with
+ | None ->
+ if n <> 0
+ then errorlabstrm "Edit.undo_todepth" (str"No proof in progress")
+ else () (* if there is no proof in progress, then n must be zero *)
+ | Some d ->
+ let (bs,_) = Hashtbl.find e.buf d in
+ if Bstack.depth bs < n then
+ errorlabstrm "Edit.undo_todepth" (str"Undo stack would be exhausted");
+ repeat (Bstack.depth bs - n) Bstack.pop bs
+
let create e (d,b,c,udepth) =
if Hashtbl.mem e.buf d then
errorlabstrm "Edit.create"