Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions ci/simple-tests/coq-test-queries.el
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
(defvar coq-ask-printing-width-function)
(defvar coq-shell-current-line-width)
(defvar coq-use-yasnippet)
(defvar coq-menu-common-entries)

(declare-function proof-shell-exit "proof-shell")
(declare-function proof-shell-invisible-command "proof-shell")
Expand All @@ -52,6 +53,7 @@
(declare-function coq-insert-as-in-next-command "coq-queries")
(declare-function coq-run-query "coq-queries")
(declare-function coq-About "coq-queries")
(declare-function coq-Print-implicit "coq-queries")
(declare-function coq-Check "coq-queries")
(declare-function coq-Search "coq-queries")
(declare-function coq-id-under-mouse-query "coq-queries")
Expand Down Expand Up @@ -316,6 +318,31 @@ query."
(should (string-match-p "Nat\\.add" (coq-test-queries-response)))
(should (coq-flag-is-on-p "Test Printing Notations"))))

(ert-deftest coq-test-queries-menu-commands ()
"The menu entries of the printing flags run the flag they name."
(require 'coq-abbrev)
(let (entries)
(cl-labels ((walk (menu)
(dolist (item menu)
(cond ((vectorp item) (push item entries))
((consp item) (walk (cdr item)))))))
(walk coq-menu-common-entries))
(dolist (item entries)
(let ((label (aref item 0))
(re "\\`\\(Set\\|Unset\\) Printing \\(.*\\)\\'"))
(when (and (string-match re label)
(not (equal (match-string 2 label) "Width")))
(let ((command (format "coq-%s-printing-%s"
(downcase (match-string 1 label))
(replace-regexp-in-string
" " "-" (downcase (match-string 2 label))))))
(should (equal (list label (aref item 1))
(list label (intern command))))))))
(should (eq (aref (cl-find "Print Implicit..." entries
:key (lambda (v) (aref v 0)) :test #'equal)
1)
#'coq-Print-implicit))))

(ert-deftest coq-test-queries-mouse ()
"`coq-remap-mouse-1' binds the queries at mouse click when set, in the
script, goals and response buffers, and unbinds them when unset."
Expand Down
22 changes: 20 additions & 2 deletions ci/simple-tests/coq-test-without-pg.el
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
;; Test the part of Coq mode common to all backends, with the Proof
;; General backend disabled (obsolete `coq-use-pg' nil, so `coq-backend'
;; nil): it must not load the proof shell, and the abbrevs, the
;; terminator command, the query and insertion commands and their keys
;; must be there.
;; terminator command, the query and insertion commands, their keys and
;; the insertion menu must be there.

;;; Code:

Expand All @@ -22,13 +22,15 @@
(require 'proof-site)
(require 'ert)
(require 'cl-lib)
(require 'seq)

(defvar coq-mode-abbrev-table)
(defvar coq-load-path)
(defvar coq-prog-args)
(defvar coq-query-function)
(defvar coq-use-yasnippet)
(defvar coq-goals-count-function)
(defvar coq-insert-menu)

(declare-function coq-run-query "coq-queries")
(declare-function coq-templates-setup "coq-templates")
Expand Down Expand Up @@ -174,6 +176,22 @@ indent."
(setq-local coq-goals-count-function (lambda () '(5 . 3)))
(should (equal (coq-goals-count) '(5 . 3)))))

(ert-deftest coq-test-without-pg-insert-menu ()
"The menu of the insertions is defined without backend."
(coq-test-without-pg-with-file
(should (equal (car coq-insert-menu) "INSERT"))
(let ((commands (delq nil (mapcar (lambda (item)
(and (vectorp item) (aref item 1)))
coq-insert-menu)))
(submenus (mapcar #'car (seq-filter #'consp (cdr coq-insert-menu)))))
(dolist (command '(coq-insert-intros coq-insert-tactic
coq-insert-tactical coq-insert-command
coq-insert-term coq-insert-section-or-module
coq-insert-requires))
(should (memq command commands)))
(should (equal submenus '("Tactics (menu)" "Tacticals (menu)"
"Command (menu)" "Term (menu)"))))))

(provide 'coq-test-without-pg)

;;; coq-test-without-pg.el ends here
44 changes: 4 additions & 40 deletions coq/coq-abbrev.el
Original file line number Diff line number Diff line change
Expand Up @@ -29,28 +29,6 @@
(describe-variable 'coq-local-vars-doc))


(defconst coq-tactics-menu
(append '("Tactics (menu)"
["Intros (smart)" coq-insert-intros :help "Insert \"intros h1 .. hn.\" where hi are the default names given by Coq."])
(coq-build-menu-from-db (append coq-tactics-db coq-solve-tactics-db))))

(defconst coq-tacticals-menu
(append '("Tacticals (menu)")
(coq-build-menu-from-db coq-tacticals-db)))

(defconst coq-commands-menu
(append '("Command (menu)"
;["Module/Section (smart)" coq-insert-section-or-module t]
;["Require (smart)" coq-insert-requires t]
)
(coq-build-menu-from-db coq-commands-db)))

(defconst coq-terms-menu
(append '("Term (menu)"
["Match (smart)" coq-insert-match t])
(coq-build-menu-from-db coq-terms-db)))


;; (if (fboundp 'with-undo-amalgamate) ;; emacs > 29.1
;; (with-undo-amalgamate (insert abbr) (yas-expand))
;; (progn (insert abbr) (yas-expand)))
Expand Down Expand Up @@ -317,7 +295,7 @@
["Print Section..." coq-PrintSection t]
""
["Locate notation..." coq-LocateNotation t]
["Print Implicit..." coq-Print t]
["Print Implicit..." coq-Print-implicit t]
["Print Scope/Visibility..." coq-PrintScope t])
("OPTIONS"
["Set Printing All" coq-set-printing-all t]
Expand All @@ -330,8 +308,8 @@
["Unset Printing Notations" coq-unset-printing-notations t]
["Set Printing Coercions" coq-set-printing-coercions t]
["Unset Printing Coercions" coq-unset-printing-coercions t]
["Set Printing Compact Contexts" coq-set-printing-implicit t]
["Unset Printing Compact Contexts" coq-unset-printing-implicit t]
["Set Printing Compact Contexts" coq-set-printing-compact-contexts t]
["Unset Printing Compact Contexts" coq-unset-printing-compact-contexts t]
["Set Printing Synth" coq-set-printing-synth t]
["Unset Printing Synth" coq-unset-printing-synth t]
["Set Printing Universes" coq-set-printing-universes t]
Expand All @@ -346,21 +324,7 @@
(append coq-menu-common-entries
`(
""
("INSERT"
["Intros (smart)" coq-insert-intros :help "Insert \"intros h1 .. hn.\" where hi are the default names given by Coq."]
""
["Tactic (interactive)" coq-insert-tactic t]
["Tactical (interactive)" coq-insert-tactical t]
["Command (interactive)" coq-insert-command t]
["Term (interactive)" coq-insert-term t]
""
,coq-tactics-menu
,coq-tacticals-menu
,coq-commands-menu
,coq-terms-menu
""
["Module/Section (smart)" coq-insert-section-or-module t]
["Require (smart)" coq-insert-requires t])
,coq-insert-menu
""
("ABBREVS"
["Expand At Point" expand-abbrev t]
Expand Down
44 changes: 43 additions & 1 deletion coq/coq-templates.el
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Otherwise the abbrevs of `coq-mode-abbrev-table' are available."
;; They insert text from the keyword databases of coq-syntax.el, or
;; after asking questions, without any backend.

(defvar coq-load-path) ; in coq-system.el
(defvar coq-load-path) ; in coq-project.el

(define-obsolete-variable-alias 'module-kinds-table
'coq-module-kinds-table "4.6")
Expand Down Expand Up @@ -219,6 +219,48 @@ Completion is on a quasi-exhaustive list of Coq tacticals."
(interactive)
(coq-insert-from-db coq-terms-db "Kind of term"))

;; The menu of the insertions, common to all backends. The insertions
;; built from a query (Intros, Match) are in coq-queries.el.

(defconst coq-tactics-menu
(append '("Tactics (menu)"
["Intros (smart)" coq-insert-intros :help "Insert \"intros h1 .. hn.\" where hi are the default names given by Coq."])
(coq-build-menu-from-db (append coq-tactics-db coq-solve-tactics-db))))

(defconst coq-tacticals-menu
(append '("Tacticals (menu)")
(coq-build-menu-from-db coq-tacticals-db)))

(defconst coq-commands-menu
(append '("Command (menu)"
;["Module/Section (smart)" coq-insert-section-or-module t]
;["Require (smart)" coq-insert-requires t]
)
(coq-build-menu-from-db coq-commands-db)))

(defconst coq-terms-menu
(append '("Term (menu)"
["Match (smart)" coq-insert-match t])
(coq-build-menu-from-db coq-terms-db)))

(defconst coq-insert-menu
`("INSERT"
["Intros (smart)" coq-insert-intros :help "Insert \"intros h1 .. hn.\" where hi are the default names given by Coq."]
""
["Tactic (interactive)" coq-insert-tactic t]
["Tactical (interactive)" coq-insert-tactical t]
["Command (interactive)" coq-insert-command t]
["Term (interactive)" coq-insert-term t]
""
,coq-tactics-menu
,coq-tacticals-menu
,coq-commands-menu
,coq-terms-menu
""
["Module/Section (smart)" coq-insert-section-or-module t]
["Require (smart)" coq-insert-requires t])
"Menu of the insertions, common to all Coq backends.")

(provide 'coq-templates)

;;; coq-templates.el ends here
Loading