Skip to content

Commit

Permalink
proof-script,test-omit-proofs: style and documentation improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
hendriktews committed Mar 5, 2023
1 parent 8416875 commit 60fde3a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
4 changes: 2 additions & 2 deletions ci/simple-tests/test-omit-proofs.el
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
;;
;; Test that with proof-omit-proofs-option
;; - the proof _is_ processed when using a prefix argument
;; - in this case the proof as normal locked color
;; - in this case the proof has normal locked color
;; - without prefix arg, the proof is omitted
;; - the proof has omitted color then
;; - stuff before the proof still has normal color
Expand Down Expand Up @@ -52,7 +52,7 @@ therefore have a higher priority."

(defun overlays-at-point-sorted ()
"Return overlays at point in decreasing order of priority.
Works only if no overlays has a priority property. Same
Works only if no overlay has a priority property. Same
'(overlays-at (point) t)', except that it also works on Emacs <= 25."
(sort (overlays-at (point) t) 'overlay-less))

Expand Down
30 changes: 23 additions & 7 deletions generic/proof-script.el
Original file line number Diff line number Diff line change
Expand Up @@ -2022,23 +2022,32 @@ start is found inside a proof."
proof-script-proof-admit-command)
nil
"proof-script omit proof feature not properly configured")
(let (result maybe-result inside-proof
(let (;; result vanillas with omitted proofs in reverse order
result
;; commands of current proof before deciding opaqueness in reverse order
maybe-result
inside-proof
proof-start-span-start proof-start-span-end
item cmd)
;; the current vanilla item
item
;; the command of the current item
cmd)
(while vanillas
(setq item (car vanillas))
;; cdr vanillas is at the end of the loop
(setq cmd (mapconcat #'identity (nth 1 item) " "))

(if inside-proof
(progn
(if (string-match proof-script-proof-start-regexp cmd)
;; found another proof start inside a proof
;; stop omitting and pass the remainder unmodified
;; the result in `result' is aggregated in reverse
;; order, need to reverse vanillas
;; Found another proof start inside a proof.
;; Stop omitting and pass the remainder unmodified.
;; The result in `result' is aggregated in reverse
;; order, need to reverse vanillas.
(progn
(setq result (nconc (nreverse vanillas) maybe-result result))
(setq maybe-result nil)
;; terminate the while loop
(setq vanillas nil)
;; for Coq nobody will notice the warning, because
;; the error about nested proofs will pop up shortly
Expand All @@ -2050,6 +2059,8 @@ start is found inside a proof."
(format (concat "found second proof start at line %d"
" - are there nested proofs?")
(line-number-at-pos (span-end (car item))))))

;; else - no nested proof, but still inside-proof
(if (string-match proof-script-proof-end-regexp cmd)
(let
;; Reuse the Qed span for the whole proof,
Expand Down Expand Up @@ -2089,6 +2100,8 @@ start is found inside a proof."
'proof-done-advancing nil)
result)
(setq inside-proof nil))

;; else - no nested proof, no opaque proof, but still inside
(if (string-match proof-script-definition-end-regexp cmd)
;; A proof ending in Defined or something similar.
;; Need to keep all commands from the start of the proof.
Expand All @@ -2099,7 +2112,8 @@ start is found inside a proof."
;; normal proof command - maybe it belongs to a
;; Defined, keep it separate, until we know.
(push item maybe-result)))))
;; outside proof

;; else - outside proof
(if (string-match proof-script-proof-start-regexp cmd)
(progn
(setq maybe-result nil)
Expand All @@ -2111,6 +2125,8 @@ start is found inside a proof."
;; outside, no proof start - keep it unmodified
(push item result)))
(setq vanillas (cdr vanillas)))

;; end of loop - return filtered vanillas
(nreverse (nconc maybe-result result))))


Expand Down

0 comments on commit 60fde3a

Please sign in to comment.