3232(require 'cl-lib )
3333
3434(require 'span )
35+ (require 'proof-syntax )
36+ (require 'proof-useropts )
37+ (require 'proof-utils )
3538(eval-when-compile
3639 (require 'proof-utils )
3740 (require 'span )
3841 (require 'outline )
3942 (require 'newcomment )
4043 (require 'etags ))
44+
4145(defvar proof-info ) ; dynamic scope in proof-tree-urgent-action
42- (defvar action ) ; dynamic scope in coq-insert-as stuff
43- (defvar string ) ; dynamic scope in coq-insert-as stuff
4446(defvar old-proof-marker )
4547(defvar coq-keymap )
4648(defvar coq-one-command-per-line )
@@ -177,7 +179,7 @@ It is mostly useful in three window mode, see also
177179`proof-three-window-mode-policy' for details."
178180
179181 :type 'boolean
180- :safe 'booleanp
182+ :safe # 'booleanp
181183 :group 'coq-auto-compile )
182184
183185; ;
@@ -591,11 +593,11 @@ and read by function `coq-empty-action-list-command'.")
591593 (span-set-property span 'statenum val))
592594
593595(defsubst coq-get-span-goalcmd (span )
594- " Return the ' goalcmd flag of the SPAN."
596+ " Return the ` goalcmd' flag of the SPAN."
595597 (span-property span 'goalcmd ))
596598
597599(defsubst coq-set-span-goalcmd (span val )
598- " Set the ' goalcmd flag of the SPAN to VAL."
600+ " Set the ` goalcmd' flag of the SPAN to VAL."
599601 (span-set-property span 'goalcmd val))
600602
601603(defsubst coq-set-span-proofnum (span val )
@@ -625,7 +627,7 @@ and read by function `coq-empty-action-list-command'.")
625627
626628(defun coq-set-state-infos ()
627629 " Set the last locked span's state number to the number found last time.
628- This number is in the *last but one* prompt (variable `coq-last-but-one-statenum' ).
630+ This number is in the *last but one* prompt (var `coq-last-but-one-statenum' ).
629631If locked span already has a state number, then do nothing. Also updates
630632`coq-last-but-one-statenum' to the last state number for next time."
631633 (if proof-shell-last-prompt
@@ -815,7 +817,7 @@ If C is nil, return nil."
815817 (or (equal (char-syntax c) ?\. ) (equal (char-syntax c) ?\_ ))))
816818
817819(defun coq-grab-punctuation-left (pos )
818- " Return a string made of punctuations chars found immediately before position POS."
820+ " Return the punctuation chars found immediately before position POS."
819821 (let ((res nil )
820822 (currpos pos))
821823 (while (coq-is-symbol-or-punct (char-before currpos))
@@ -931,7 +933,7 @@ Otherwise propose identifier at point if any."
931933
932934(defun coq-command-with-set-unset (setcmd cmd unsetcmd &optional postformatcmd testcmd )
933935 " Play commands SETCMD then CMD and then silently UNSETCMD.
934- The last UNSETCMD is performed with tag ' empty-action-list so that it
936+ The last UNSETCMD is performed with tag ` empty-action-list' so that it
935937does not trigger ‘proof-shell-empty-action’ (which does \" Show\" at
936938the time of writing this documentation)."
937939 (let* ((postform (if (eq postformatcmd nil ) 'identity postformatcmd))
@@ -1119,7 +1121,7 @@ With flag Printing All if some prefix arg is given (C-u)."
11191121 (coq-ask-do-show-all " Check" " Check" ))
11201122
11211123(defun coq-get-response-string-at (&optional pt )
1122- " Go forward from PT until reaching a ' response property, and return it.
1124+ " Go forward from PT until reaching a ` response' property, and return it.
11231125Response span only starts at first non space character of a
11241126command, so we may have to go forward to find it. Starts
11251127from (point) if pt is nil. Precondition: pt (or point if nil)
@@ -1183,6 +1185,27 @@ Printing All set."
11831185(add-hook 'proof-assert-command-hook #'coq-adapt-printing-width )
11841186(add-hook 'proof-retract-command-hook #'coq-reset-printing-width )
11851187
1188+ (defun coq-diffs--setter (symbol new-value )
1189+ " :set function fo `coq-diffs' .
1190+ Set Diffs setting if Coq is running and has a version >= 8.10."
1191+ (set symbol new-value)
1192+ (if (proof-shell-available-p)
1193+ (let ((cmd (coq-diffs)))
1194+ (if (equal cmd " " )
1195+ (message " Ignore coq-diffs setting %s for Coq before 8.10 "
1196+ (symbol-name coq-diffs))
1197+ (proof-shell-invisible-command cmd)))))
1198+
1199+ (defcustom coq-diffs 'off
1200+ " Controls Coq Diffs option"
1201+ :type '(radio
1202+ (const :tag " Don't show diffs" off)
1203+ (const :tag " Show diffs: only added" on)
1204+ (const :tag " Show diffs: added and removed" removed))
1205+ :safe (lambda (v ) (member v '(off on removed)))
1206+ :set #'coq-diffs--setter
1207+ :group 'coq )
1208+
11861209(defun coq--show-proof-stepwise-cmds ()
11871210 (when coq-show-proof-stepwise
11881211 (if (coq--post-v811)
@@ -1202,7 +1225,7 @@ Printing All set."
12021225(defun coq-empty-action-list-command (cmd )
12031226 " Return the list of commands to send to Coq after CMD
12041227if it is the last command of the action list.
1205- If CMD is tagged with ' empty-action-list then this function won't
1228+ If CMD is tagged with ` empty-action-list' then this function won't
12061229be called and no command will be sent to Coq.
12071230Note: the last command added if `coq-show-proof-stepwise' is set
12081231should match the `coq-show-proof-diffs-regexp' ."
@@ -1959,6 +1982,41 @@ at `proof-assistant-settings-cmds' evaluation time.")
19591982 (proof-config-done)
19601983 )
19611984
1985+ ; ; This variable is used by generic pg code. Every time this is detected in the
1986+ ; ; output, it sets the `proof-last-theorem-dependencies' variable. Substring 1
1987+ ; ; should contain the name of the theorem, and substring 2 should contain its
1988+ ; ; dependencies. The content of `proof-last-theorem-dependencies' is then used
1989+ ; ; by pg generic code to trigger `proof-depends-process-dependencies' , which
1990+ ; ; itself sets the 'dependencies property of the span, and calls
1991+ ; ; `proof-dependencies-system-specific' . The latter is bound to
1992+ ; ; `coq-dependencies-system-specific' below.
1993+ (defconst coq-shell-theorem-dependency-list-regexp
1994+ " <infomsg>\n ?The proof of \\ (?1:[^ \n ]+\\ )\\ (?: \\ |\n \\ )should start with one of the following commands:\\ (?: \\ |\n \\ )Proof using\\ (?2:[^.]*\\ )\\ ." )
1995+
1996+
1997+ ; ; the additional menu for "proof using". highlights the "Proof." command, and
1998+ ; ; have a entry to insert the annotation and remove the highlight.
1999+ (defvar coq-dependency-menu-system-specific
2000+ (lambda (span )
2001+ (let* ((deps (span-property-safe span 'dependencies ))
2002+ (specialspans (spans-at-region-prop (span-start span) (span-end span) 'proofusing ))
2003+ (specialspan (and specialspans (not (cdr specialspans)) (car specialspans)))
2004+ (suggested (mapconcat #'identity deps " " ))
2005+ (suggested (coq-hack-proofusing-suggestion suggested))
2006+ (name (concat " insert \" proof using " suggested " \" " ))
2007+ (fn (lambda (sp )
2008+ (coq-insert-proof-using-suggestion sp t )
2009+ (and specialspan (span-delete specialspan)))))
2010+ (list " -------------" (vector name `(,fn ,span ) t ))))
2011+ " Coq specific additional menu entry for \" Proof using\" .
2012+ annotation. See `proof-dependency-menu-system-specific' ." )
2013+
2014+ (defvar coq-dependencies-system-specific
2015+ (lambda (span )
2016+ (coq-insert-proof-using-suggestion span))
2017+ " Coq specific dependency mechanism.
2018+ Used for automatic insertion of \" Proof using\" annotations." )
2019+
19622020(defun coq-shell-mode-config ()
19632021 (setq
19642022 proof-shell-cd-cmd coq-shell-cd
@@ -2113,27 +2171,6 @@ Return the empty string if the version of Coq < 8.10."
21132171 (format " Set Diffs \" %s \" . " (symbol-name coq-diffs))
21142172 " " ))
21152173
2116- (defun coq-diffs--setter (symbol new-value )
2117- " :set function fo `coq-diffs' .
2118- Set Diffs setting if Coq is running and has a version >= 8.10."
2119- (set symbol new-value)
2120- (if (proof-shell-available-p)
2121- (let ((cmd (coq-diffs)))
2122- (if (equal cmd " " )
2123- (message " Ignore coq-diffs setting %s for Coq before 8.10 "
2124- (symbol-name coq-diffs))
2125- (proof-shell-invisible-command cmd)))))
2126-
2127- (defcustom coq-diffs 'off
2128- " Controls Coq Diffs option"
2129- :type '(radio
2130- (const :tag " Don't show diffs" off)
2131- (const :tag " Show diffs: only added" on)
2132- (const :tag " Show diffs: added and removed" removed))
2133- :safe (lambda (v ) (member v '(off on removed)))
2134- :set #'coq-diffs--setter
2135- :group 'coq )
2136-
21372174; ; Obsolete:
21382175; ;(defpacustom undo-depth coq-default-undo-limit
21392176; ; "Depth of undo history. Undo behaviour will break beyond this size."
@@ -2217,7 +2254,7 @@ Show commands before the next real proof command.
22172254The ID's of the open goals are checked with
22182255`proof-tree-sequent-hash' in order to find out if they are new.
22192256For any new goal an appropriate Show Goal command with a
2220- ' proof-tree-show-subgoal flag is inserted into
2257+ ` proof-tree-show-subgoal' flag is inserted into
22212258`proof-action-list' . Then, in the normal delayed output
22222259processing, the sequent text is send to prooftree as a sequent
22232260update (see `proof-tree-update-sequent' ) and the ID of the
@@ -2336,7 +2373,7 @@ fact in `coq--proof-tree-must-disable-evars'."
23362373 " Insert an evar printing command at the head of `proof-action-list' ."
23372374 (push (proof-shell-action-list-item
23382375 (concat cmd " Printing Dependent Evars Line." )
2339- (if callback callback 'proof-done-invisible )
2376+ (or callback # 'proof-done-invisible )
23402377 (list 'invisible ))
23412378 proof-action-list))
23422379
@@ -2406,8 +2443,10 @@ result of `coq-proof-tree-get-proof-info'."
24062443(defun coq-bullet-p (s )
24072444 (string-match coq-bullet-regexp-nospace s))
24082445
2409- ; ; Remark: `action' and `string' are known by `proof-shell-insert-hook'
24102446(defun coq-preprocessing ()
2447+ ; ; Remark: `action' and `string' are known by `proof-shell-insert-hook'
2448+ (defvar action ) ; dynamic scope in coq-insert-as stuff
2449+ (defvar string ) ; dynamic scope in coq-insert-as stuff
24112450 (when coq-time-commands
24122451 (with-no-warnings ; ; NB: dynamic scoping of `string' and `action'
24132452 ; ; Don't add the prefix if this is a command sent internally
@@ -2620,17 +2659,6 @@ Warning: this makes the error messages (and location) wrong.")
26202659; ; already performed.).
26212660
26222661
2623- ; ; This variable is used by generic pg code. Every time this is detected in the
2624- ; ; output, it sets the `proof-last-theorem-dependencies' variable. Substring 1
2625- ; ; should contain the name of the theorem, and substring 2 should contain its
2626- ; ; dependencies. The content of `proof-last-theorem-dependencies' is then used
2627- ; ; by pg generic code to trigger `proof-depends-process-dependencies' , which
2628- ; ; itself sets the 'dependencies property of the span, and calls
2629- ; ; `proof-dependencies-system-specific' . The latter is bound to
2630- ; ; `coq-dependencies-system-specific' below.
2631- (defconst coq-shell-theorem-dependency-list-regexp
2632- " <infomsg>\n ?The proof of \\ (?1:[^ \n ]+\\ )\\ (?: \\ |\n \\ )should start with one of the following commands:\\ (?: \\ |\n \\ )Proof using\\ (?2:[^.]*\\ )\\ ." )
2633-
26342662(defcustom coq-accept-proof-using-suggestion 'highlight
26352663 " Whether and how proofgeneral should insert \" Proof using\" suggestions.
26362664Suggestions are emitted by Coq at Qed time. The possible values
@@ -2674,23 +2702,6 @@ Remarks and limitations:
26742702(defun coq-hack-proofusing-suggestion (suggested )
26752703 (if (string-equal " " suggested) " Type" suggested))
26762704
2677- ; ; the additional menu for "proof using". highlights the "Proof." command, and
2678- ; ; have a entry to insert the annotation and remove the highlight.
2679- (defvar coq-dependency-menu-system-specific
2680- (lambda (span )
2681- (let* ((deps (span-property-safe span 'dependencies ))
2682- (specialspans (spans-at-region-prop (span-start span) (span-end span) 'proofusing ))
2683- (specialspan (and specialspans (not (cdr specialspans)) (car specialspans)))
2684- (suggested (mapconcat #'identity deps " " ))
2685- (suggested (coq-hack-proofusing-suggestion suggested))
2686- (name (concat " insert \" proof using " suggested " \" " ))
2687- (fn (lambda (sp )
2688- (coq-insert-proof-using-suggestion sp t )
2689- (and specialspan (span-delete specialspan)))))
2690- (list " -------------" (vector name `(,fn ,span ) t ))))
2691- " Coq specific additional menu entry for \" Proof using\" .
2692- annotation. See `proof-dependency-menu-system-specific' ." )
2693-
26942705(defconst coq-proof-using-regexp " \\ _<Proof\\ (?1:[^.]*\\ )\\ ."
26952706 " Regexp matching Coq \" Proof ....\" annotation (with no \" using\" annotation).
26962707We suppose there is no \" using\" annotation, since Coq will fail
@@ -2706,7 +2717,7 @@ insertion point for the \"using\" annotation. ")
27062717(defun coq-highlight-span-dependencies (start end _suggested )
27072718 (goto-char start)
27082719 ; Search for the "Proof" command and build a hilighted span on it
2709- (let* ((proof-pos (match-beginning 0 ))
2720+ (let* (; ; (proof-pos (match-beginning 0))
27102721 (newspan (span-make start end)))
27112722 (span-set-property newspan 'face 'proof-warning-face )
27122723 (span-set-property newspan 'help-echo " Right click to insert \" proof using\" " )
@@ -2783,12 +2794,6 @@ SPAN is the span of the whole theorem (statement + proof)."
27832794 (coq-highlight-span-dependencies proof-pos proof-end string-suggested)
27842795 (message " \" Proof using\" not set. M-x coq-insert-suggested-dependency or right click to add it. See also `coq-accept-proof-using-suggestion' ." ))))))))))
27852796
2786- (defvar coq-dependencies-system-specific
2787- (lambda (span )
2788- (coq-insert-proof-using-suggestion span))
2789- " Coq specific dependency mechanism.
2790- Used for automatic insertion of \" Proof using\" annotations." )
2791-
27922797
27932798(defun coq-insert-as-in-next-command ()
27942799 (interactive )
@@ -3483,7 +3488,6 @@ coq from the new opam switch."
34833488; ; Local Variables: ***
34843489; ; fill-column: 79 ***
34853490; ; indent-tabs-mode: nil ***
3486- ; ; coding: utf-8 ***
34873491; ; End: ***
34883492
34893493; ;; coq.el ends here
0 commit comments