feat(emacs/lean-info): add goal visualization options 'lean-proofstate-display-style'
lean-proofstate-display-style: - 'show-all: Show all goals a : Prop, b : Prop, c : Prop, H_1 : a, H_2 : b, H_3 : c ⊢ id a a : Prop, b : Prop, c : Prop, H_1 : a, H_2 : b, H_3 : c ⊢ b ∧ c - 'show-first: Show only the first a : Prop, b : Prop, c : Prop, H_1 : a, H_2 : b, H_3 : c ⊢ id a - 'show-first-and-other-conclusions: Show the first goal, and the conclusions of all other goals (DEFAULT OPTION) a : Prop, b : Prop, c : Prop, H_1 : a, H_2 : b, H_3 : c ⊢ id a ⊢ b ∧ c Close #279
This commit is contained in:
parent
a98b12f067
commit
6973d3e7aa
3 changed files with 41 additions and 11 deletions
|
@ -229,11 +229,32 @@
|
||||||
(cl-third proofstate))
|
(cl-third proofstate))
|
||||||
(defun lean-info-proofstate-state-str (string-seq)
|
(defun lean-info-proofstate-state-str (string-seq)
|
||||||
(string-join string-seq "\n"))
|
(string-join string-seq "\n"))
|
||||||
(defun lean-info-proofstate-states-str (proofstate)
|
(defun lean-info-proofstate-extract-conclusion (string-seq)
|
||||||
(string-join
|
(--drop-while (not (s-starts-with? "⊢" it)) string-seq))
|
||||||
(-map 'lean-info-proofstate-state-str
|
(defun lean-info-proofstate-extract-premises (string-seq)
|
||||||
(lean-info-proofstate-states proofstate))
|
(--take-while (not (s-starts-with? "⊢" it)) string-seq))
|
||||||
"\n\n"))
|
(defun lean-info-proofstate-states-str (proofstate &optional display-style)
|
||||||
|
(let* ((states (lean-info-proofstate-states proofstate))
|
||||||
|
(first-state (-first-item states))
|
||||||
|
(rest-states (cdr states))
|
||||||
|
(display-style (or display-style lean-proofstate-display-style)))
|
||||||
|
(cond
|
||||||
|
(first-state
|
||||||
|
(pcase display-style
|
||||||
|
(`show-all
|
||||||
|
(string-join
|
||||||
|
(-map 'lean-info-proofstate-state-str states)
|
||||||
|
"\n\n"))
|
||||||
|
(`show-first
|
||||||
|
(lean-info-proofstate-state-str first-state))
|
||||||
|
(`show-first-and-other-conclusions
|
||||||
|
(string-join
|
||||||
|
(-map 'lean-info-proofstate-state-str
|
||||||
|
(cons first-state (-map
|
||||||
|
'lean-info-proofstate-extract-conclusion
|
||||||
|
rest-states)))
|
||||||
|
"\n\n"))))
|
||||||
|
(t "No Goal"))))
|
||||||
|
|
||||||
;; Basic
|
;; Basic
|
||||||
;; -----
|
;; -----
|
||||||
|
@ -469,9 +490,7 @@ Take out \"BEGININFO\" and \"ENDINFO\" and Use \"ACK\" as a delim."
|
||||||
(propertize "overloaded" 'face 'font-lock-keyword-face)
|
(propertize "overloaded" 'face 'font-lock-keyword-face)
|
||||||
overload-str))))
|
overload-str))))
|
||||||
(when proofstate
|
(when proofstate
|
||||||
(cond ((not (lean-info-proofstate-states proofstate))
|
(setq str (lean-info-proofstate-states-str proofstate)))
|
||||||
(setq str "No Goal"))
|
|
||||||
(t (setq str (lean-info-proofstate-states-str proofstate)))))
|
|
||||||
(when (and stale str)
|
(when (and stale str)
|
||||||
(setq stale-str (format "[%s]"
|
(setq stale-str (format "[%s]"
|
||||||
(propertize "stale" 'face '(foreground-color . "red")))))
|
(propertize "stale" 'face '(foreground-color . "red")))))
|
||||||
|
|
|
@ -134,4 +134,11 @@ false (nil)."
|
||||||
:group 'lean
|
:group 'lean
|
||||||
:type 'boolean)
|
:type 'boolean)
|
||||||
|
|
||||||
|
(defcustom lean-proofstate-display-style 'show-first-and-other-conclusions
|
||||||
|
"Choose how to display proof state in *lean-info* buffer."
|
||||||
|
:group 'lean
|
||||||
|
:type '(choice (const :tag "Show all goals" show-all)
|
||||||
|
(const :tag "Show only the first" show-first)
|
||||||
|
(const :tag "Show the first goal, and the conclusions of all other goals" show-first-and-other-conclusions)))
|
||||||
|
|
||||||
(provide 'lean-settings)
|
(provide 'lean-settings)
|
||||||
|
|
|
@ -59,15 +59,19 @@ buffer. It's used to avoid outputting the same message")
|
||||||
"Continuation for lean-eldoc-documentation-function"
|
"Continuation for lean-eldoc-documentation-function"
|
||||||
(let* ((info-strings (lean-info-record-to-strings info-record))
|
(let* ((info-strings (lean-info-record-to-strings info-record))
|
||||||
(info-string-mini-buffer (and info-strings (string-join info-strings " ")))
|
(info-string-mini-buffer (and info-strings (string-join info-strings " ")))
|
||||||
(info-string-info-buffer (and info-strings (-last-item info-strings))))
|
(info-string-info-buffer (and info-strings (-last-item info-strings)))
|
||||||
|
(proofstate (lean-info-record-proofstate info-record)))
|
||||||
(when info-strings
|
(when info-strings
|
||||||
(when add-to-kill-ring
|
(when add-to-kill-ring
|
||||||
(kill-new
|
(kill-new
|
||||||
(substring-no-properties info-string-mini-buffer)))
|
(substring-no-properties info-string-mini-buffer)))
|
||||||
|
;; Display on Mini-buffer
|
||||||
(when (or lean-show-proofstate-in-minibuffer
|
(when (or lean-show-proofstate-in-minibuffer
|
||||||
(not (lean-info-record-proofstate info-record)))
|
(not proofstate))
|
||||||
(message "%s" info-string-mini-buffer))
|
(message "%s" info-string-mini-buffer))
|
||||||
(lean-output-to-lean-info-buffer "%s" (list info-string-info-buffer)))))
|
;; Display on Info Buffer
|
||||||
|
(when info-string-info-buffer
|
||||||
|
(lean-output-to-lean-info-buffer "%s" (list info-string-info-buffer))))))
|
||||||
|
|
||||||
(defun lean-eldoc-documentation-function (&optional add-to-kill-ring)
|
(defun lean-eldoc-documentation-function (&optional add-to-kill-ring)
|
||||||
"Show information of lean expression at point if any"
|
"Show information of lean expression at point if any"
|
||||||
|
|
Loading…
Reference in a new issue