Skip to content
Open
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
2 changes: 1 addition & 1 deletion ci/compile-tests/cct-lib.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; cct-lib.el --- Background compilation test helpers
;;; cct-lib.el --- Background compilation test helpers -*- lexical-binding: t; -*-
;; This file is part of Proof General.
;;
;; © Copyright 2020 - 2021 Hendrik Tews
Expand Down
4 changes: 4 additions & 0 deletions ci/simple-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ coq-test-proof-stat
coq-test-time-commands
: test that `coq-time-commands` prefixes the commands sent to Coq with
Time, except bullets and internal commands
coq-test-hook-variables
: test that the hooks of proof-shell.el can read and modify the
variables they share with Proof General through dynamic binding,
with proof-shell.el interpreted and byte-compiled
coq-test-silent-option
: test that `coq-run-completely-silent` is ignored with a warning for
Rocq >= 9.2, which does not print goals any more (skipped for older
Expand Down
2 changes: 1 addition & 1 deletion ci/simple-tests/coq-test-changes-in-comments.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; coq-test-changes-in-comments.el --- Test changes inside comments
;;; coq-test-changes-in-comments.el --- Test changes inside comments -*- lexical-binding: t; -*-
;;
;; This file is part of Proof General.
;;
Expand Down
2 changes: 1 addition & 1 deletion ci/simple-tests/coq-test-coqtop-unavailable.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; coq-test-coqtop-unavailable.el --- Test for when coqtop is unavailable
;;; coq-test-coqtop-unavailable.el --- Test for when coqtop is unavailable -*- lexical-binding: t; -*-
;;
;; This file is part of Proof General.
;;
Expand Down
2 changes: 1 addition & 1 deletion ci/simple-tests/coq-test-goals-present.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; coq-test-goals-present.el --- Test that Proof General shows goals correctly in various situations
;;; coq-test-goals-present.el --- Test that Proof General shows goals correctly in various situations -*- lexical-binding: t; -*-
;;
;; This file is part of Proof General.
;;
Expand Down
108 changes: 108 additions & 0 deletions ci/simple-tests/coq-test-hook-variables.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
;;; coq-test-hook-variables.el --- Test variables shared with proof shell hooks -*- lexical-binding: t -*-
;;
;; This file is part of Proof General.
;;
;; License: GPL (GNU GENERAL PUBLIC LICENSE)

;;; Commentary:
;;
;; Some hooks of proof-shell.el communicate with the hook functions
;; through dynamically bound variables: `queueitems' for
;; `proof-shell-extend-queue-hook', `string', `action' and
;; `scriptspan' for `proof-shell-insert-hook' and `prover-was-busy'
;; for `proof-shell-signal-interrupt-hook'. Since proof-shell.el uses
;; lexical binding, these variables need special care, and interpreted
;; and byte-compiled code may behave differently. Therefore, test each
;; hook with proof-shell.el loaded from source and byte-compiled.
;;
;; These tests do not need Coq, they only use the generic part of
;; Proof General.

;;; Code:

(require 'ert)
;; Make byte-compile-dest-file-function special before binding it below.
(require 'bytecomp)
(require 'proof-site)
(proof-ready-for-assistant 'coq)
(require 'proof-shell)

(defvar queueitems)
(defvar string)
(defvar action)
(defvar scriptspan)
(defvar prover-was-busy)


;;; utility functions

(defun hook-vars-load-proof-shell (mode)
"Load proof-shell.el from source if MODE is `interpreted'.
Otherwise byte-compile it into a temporary file and load that."
(let ((source (locate-library "proof-shell.el" t)))
(if (eq mode 'interpreted)
(load source nil t t)
(let* ((elc (make-temp-file "proof-shell" nil ".elc"))
(byte-compile-dest-file-function (lambda (_) elc)))
(unwind-protect
(progn
(should (byte-compile-file source))
(load elc nil t t))
(delete-file elc))))))

(defmacro hook-vars-in-both-modes (&rest body)
"Run BODY once with interpreted and once with byte-compiled proof-shell.el."
(declare (indent 0))
`(dolist (mode '(interpreted compiled))
(hook-vars-load-proof-shell mode)
(ert-info ((format "proof-shell.el %s" mode))
,@body)))


;;; tests

(ert-deftest hook-vars-extend-queue ()
"Functions on `proof-shell-extend-queue-hook' can modify `queueitems'."
(hook-vars-in-both-modes
(with-temp-buffer
(let ((proof-locked-span (make-overlay 1 1))
(proof-queue-span (make-overlay 1 1))
(proof-shell-extend-queue-hook
(list (lambda () (setq queueitems (cdr queueitems)))))
added)
(cl-letf (((symbol-function 'proof-add-to-queue)
(lambda (items _mode) (setq added items))))
(proof-extend-queue 1 '(require-item other-item)))
(should (equal added '(other-item)))))))

(ert-deftest hook-vars-shell-insert ()
"Functions on `proof-shell-insert-hook' see `action' and `scriptspan'
and can modify `string'."
(hook-vars-in-both-modes
(with-temp-buffer
(let ((proof-shell-buffer (current-buffer))
(proof-marker (make-marker))
(proof-shell-strip-crs-from-input nil)
(proof-shell-insert-hook
(list (lambda ()
(should (eq action 'test-action))
(should (eq scriptspan 'test-span))
(setq string (concat "Modified " string))))))
(cl-letf (((symbol-function 'scomint-send-input) #'ignore))
(proof-shell-insert "Command." 'test-action 'test-span))
(should (equal (buffer-string) "Modified Command."))))))

(ert-deftest hook-vars-interrupt ()
"Functions on `proof-shell-signal-interrupt-hook' can set `prover-was-busy'.
Otherwise `proof-interrupt-process' signals an error when the prover
itself is idle, as it happens during background compilation."
(hook-vars-in-both-modes
(let ((proof-shell-busy nil)
(proof-shell-signal-interrupt-hook
(list (lambda () (setq prover-was-busy t)))))
(cl-letf (((symbol-function 'proof-shell-live-buffer) (lambda () t)))
(proof-interrupt-process)))))

(provide 'coq-test-hook-variables)

;;; coq-test-hook-variables.el ends here
2 changes: 1 addition & 1 deletion ci/simple-tests/coq-test-omit-proofs.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; coq-test-omit-proofs.el --- Test the omit proofs feature
;;; coq-test-omit-proofs.el --- Test the omit proofs feature -*- lexical-binding: t; -*-
;;
;; This file is part of Proof General.
;;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; test-coq-par-job-needs-compilation-quick.el --- test compilation internals
;;; test-coq-par-job-needs-compilation-quick.el --- test compilation internals -*- lexical-binding: t; -*-

;; This file is part of Proof General.

Expand Down
2 changes: 1 addition & 1 deletion ci/simple-tests/coq-test-prelude-correct.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; coq-test-prelude-correct.el --- Test that the Proof General prelude is correct
;;; coq-test-prelude-correct.el --- Test that the Proof General prelude is correct -*- lexical-binding: t; -*-
;;
;; This file is part of Proof General.
;;
Expand Down
2 changes: 1 addition & 1 deletion ci/simple-tests/coq-test-proof-stat.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; coq-test-proof-stat.el --- Tests for proof-check-report and proof-check-annotate
;;; coq-test-proof-stat.el --- Tests for proof-check-report and proof-check-annotate -*- lexical-binding: t; -*-
;;
;; This file is part of Proof General.
;;
Expand Down
2 changes: 1 addition & 1 deletion ci/simple-tests/coq-test-response-after-show.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; coq-test-response-after-show.el --- Test messages displayed around the automatic Show
;;; coq-test-response-after-show.el --- Test messages displayed around the automatic Show -*- lexical-binding: t; -*-
;;
;; This file is part of Proof General.
;;
Expand Down
2 changes: 1 addition & 1 deletion ci/simple-tests/coq-test-three-window.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; coq-test-three-window.el --- Test starting Proof General in three-pane mode
;;; coq-test-three-window.el --- Test starting Proof General in three-pane mode -*- lexical-binding: t; -*-
;; This file is part of Proof General.
;;
;; © Copyright 2024 Hendrik Tews
Expand Down
2 changes: 1 addition & 1 deletion ci/simple-tests/qrhl-test-input.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; qrhl-test-input.el --- Tests related to the qRHL prover
;;; qrhl-test-input.el --- Tests related to the qRHL prover -*- lexical-binding: t; -*-
;;
;; This file is part of Proof General.
;;
Expand Down
2 changes: 1 addition & 1 deletion ci/test-indent/coq-test-indent.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; Regression testing of indentation.
;;; Regression testing of indentation. -*- lexical-binding: t; -*-

;;; Initially the file is indented as it is supposed to be. Each line
;;; is unindented, then indented. If the new indentation differ a
Expand Down
2 changes: 0 additions & 2 deletions coq/coq-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@
(declare-function coq-pg-setup "coq") ; coq.el requires this file
(require 'coq-project) ; load path and project file, idem

(declare-function coq-pg-setup "coq") ; coq.el requires this file

(defgroup coq-mode ()
"Major mode to edit Coq code."
:group 'programming)
Expand Down
1 change: 1 addition & 0 deletions coq/coq-queries.el
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
(defvar proof-minibuffer-history)
(defvar coq-one-command-per-line)
(declare-function coq-terminator-insert "coq-mode")
(declare-function yas-expand-snippet "yasnippet")

(defvar-local coq-query-function nil
"Function running a query, set by each Coq backend.
Expand Down
27 changes: 16 additions & 11 deletions doc/PG-adapting.texi
Original file line number Diff line number Diff line change
Expand Up @@ -4109,19 +4109,23 @@ Input to the proof shell via the queue region is managed by the
functions @code{proof-extend-queue} and @code{proof-shell-exec-loop}.

@c TEXI DOCSTRING MAGIC: proof-extend-queue
@defun proof-extend-queue end queueitems
Extend the current queue with @var{queueitems}, queue end @var{end}.@*
@defun proof-extend-queue end queueitems-arg
Extend the current queue with @var{queueitems-arg}, queue end @var{end}.@*
To make sense, the commands should correspond to processing actions
for processing a region from (buffer-queue-or-locked-end) to @var{end}.
The queue mode is set to @code{advancing}
The queue mode is set to @code{advancing}.
The functions on @code{proof-shell-extend-queue-hook} see @var{queueitems-arg}
in the dynamically bound variable @code{queueitems} and may modify it.
@end defun

@c TEXI DOCSTRING MAGIC: proof-extend-queue
@defun proof-extend-queue end queueitems
Extend the current queue with @var{queueitems}, queue end @var{end}.@*
@defun proof-extend-queue end queueitems-arg
Extend the current queue with @var{queueitems-arg}, queue end @var{end}.@*
To make sense, the commands should correspond to processing actions
for processing a region from (buffer-queue-or-locked-end) to @var{end}.
The queue mode is set to @code{advancing}
The queue mode is set to @code{advancing}.
The functions on @code{proof-shell-extend-queue-hook} see @var{queueitems-arg}
in the dynamically bound variable @code{queueitems} and may modify it.
@end defun
@vindex proof-action-list
@c TEXI DOCSTRING MAGIC: proof-shell-exec-loop
Expand Down Expand Up @@ -4149,18 +4153,19 @@ Input is actually inserted into the shell buffer and sent to the process
by the low-level function @code{proof-shell-insert}.

@c TEXI DOCSTRING MAGIC: proof-shell-insert
@defun proof-shell-insert strings action &optional scriptspan
@defun proof-shell-insert strings action-arg &optional scriptspan-arg
Insert @var{strings} at the end of the proof shell, call @code{scomint-send-input}.

@var{strings} is a list of strings (which will be concatenated), or a
single string.

The @var{action} argument is a symbol which is typically the name of a
The @var{action-arg} argument is a symbol which is typically the name of a
callback for when each string has been processed.

This calls @code{proof-shell-insert-hook}. The arguments @var{action} and
@var{scriptspan} may be examined by the hook to determine how to modify
the string variable (exploiting dynamic scoping) which will be
This calls @code{proof-shell-insert-hook}. The hook functions see
@var{action-arg} and @var{scriptspan-arg} in the dynamically bound variables
@code{action} and @code{scriptspan}, which they may examine to determine how
to modify the dynamically bound variable @code{string}, which will be
the command actually sent to the shell.

Note that the hook is not called for the empty (null) string
Expand Down
2 changes: 1 addition & 1 deletion doc/docstring-magic.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; doc/docstring-magic.el --- hack for using texi-docstring-magic.
;;; doc/docstring-magic.el --- hack for using texi-docstring-magic. -*- lexical-binding: t; -*-

;; This file is part of Proof General.

Expand Down
2 changes: 1 addition & 1 deletion easycrypt/easycrypt-abbrev.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; easycrypt-abbrev.el --- Abbrev table and menus for EasyCrypt mode
;;; easycrypt-abbrev.el --- Abbrev table and menus for EasyCrypt mode -*- lexical-binding: t; -*-

;; --------------------------------------------------------------------
;; Copyright (c) - 2012--2016 - IMDEA Software Institute
Expand Down
2 changes: 1 addition & 1 deletion easycrypt/easycrypt-hooks.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; easycrypt-hooks.el --- Auxiliary functions for EasyCrypt mode
;;; easycrypt-hooks.el --- Auxiliary functions for EasyCrypt mode -*- lexical-binding: t; -*-

;; --------------------------------------------------------------------
;; Copyright (c) - 2012--2016 - IMDEA Software Institute
Expand Down
2 changes: 1 addition & 1 deletion easycrypt/easycrypt-keywords.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; easycrypt-keywords.el --- Definition of keywords for EasyCrypt mode
;;; easycrypt-keywords.el --- Definition of keywords for EasyCrypt mode -*- lexical-binding: t; -*-

;; --------------------------------------------------------------------
;; Copyright (c) - 2012--2016 - IMDEA Software Institute
Expand Down
2 changes: 1 addition & 1 deletion easycrypt/easycrypt-syntax.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; easycrypt-syntax.el --- Syntax definitions for EasyCrypt mode
;;; easycrypt-syntax.el --- Syntax definitions for EasyCrypt mode -*- lexical-binding: t; -*-

;; --------------------------------------------------------------------
;; Copyright (c) - 2012--2016 - IMDEA Software Institute
Expand Down
2 changes: 1 addition & 1 deletion easycrypt/easycrypt.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; easycrypt.el --- Major mode for EasyCrypt
;;; easycrypt.el --- Major mode for EasyCrypt -*- lexical-binding: t; -*-

;; --------------------------------------------------------------------
;; Copyright (c) - 2012--2016 - IMDEA Software Institute
Expand Down
2 changes: 1 addition & 1 deletion etc/emacsbugs/visiblity-attempt.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; visiblity-attempt.el --- Test area for invisibility
;;; visiblity-attempt.el --- Test area for invisibility -*- lexical-binding: t; -*-

;; This file is part of Proof General.

Expand Down
2 changes: 1 addition & 1 deletion etc/testsuite/pg-pgip-test.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; Tests for pg-pgip.el
;;; Tests for pg-pgip.el -*- lexical-binding: t; -*-

;; This file is part of Proof General.

Expand Down
2 changes: 1 addition & 1 deletion etc/testsuite/pg-test.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; pg-test.el --- Simple test framework for Proof General.
;;; pg-test.el --- Simple test framework for Proof General. -*- lexical-binding: t; -*-

;; This file is part of Proof General.

Expand Down
2 changes: 1 addition & 1 deletion generic/pg-assoc.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; pg-assoc.el --- Functions for associated buffers
;;; pg-assoc.el --- Functions for associated buffers -*- lexical-binding: t; -*-

;; This file is part of Proof General.

Expand Down
2 changes: 1 addition & 1 deletion generic/pg-autotest.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; pg-autotest.el --- Simple testing framework for Proof General
;;; pg-autotest.el --- Simple testing framework for Proof General -*- lexical-binding: t; -*-

;; This file is part of Proof General.

Expand Down
2 changes: 1 addition & 1 deletion generic/pg-custom.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; pg-custom.el --- Proof General per-prover settings
;;; pg-custom.el --- Proof General per-prover settings -*- lexical-binding: t; -*-

;; This file is part of Proof General.

Expand Down
2 changes: 1 addition & 1 deletion generic/pg-goals.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; pg-goals.el --- Proof General goals buffer mode.
;;; pg-goals.el --- Proof General goals buffer mode. -*- lexical-binding: t; -*-

;; This file is part of Proof General.

Expand Down
2 changes: 1 addition & 1 deletion generic/pg-movie.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; pg-movie.el --- Export a processed script buffer for external replay
;;; pg-movie.el --- Export a processed script buffer for external replay -*- lexical-binding: t; -*-

;; This file is part of Proof General.

Expand Down
5 changes: 2 additions & 3 deletions generic/pg-pgip.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; pg-pgip.el --- PGIP manipulation for Proof General
;;; pg-pgip.el --- PGIP manipulation for Proof General -*- lexical-binding: t; -*-

;; This file is part of Proof General.

Expand Down Expand Up @@ -398,8 +398,7 @@ Also sets local proverid and srcid variables for buffer."
(find-file file)
(let ((buffer (get-file-buffer file)))
(with-current-buffer buffer
(make-local-variable 'proverid)
(setq proverid proverid))
(set (make-local-variable 'proverid) proverid))
(set pg-pgip-srcids (cl-acons srcid (list buffer file) pg-pgip-srcids)))))


Expand Down
2 changes: 1 addition & 1 deletion generic/pg-response.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; pg-response.el --- Proof General response buffer mode.
;;; pg-response.el --- Proof General response buffer mode. -*- lexical-binding: t; -*-

;; This file is part of Proof General.

Expand Down
2 changes: 1 addition & 1 deletion generic/pg-vars.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; pg-vars.el --- Proof General global variables
;;; pg-vars.el --- Proof General global variables -*- lexical-binding: t; -*-

;; This file is part of Proof General.

Expand Down
2 changes: 1 addition & 1 deletion generic/proof-auxmodes.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; proof-auxmodes.el --- Arrange for auxiliary modes to be loaded when required
;;; proof-auxmodes.el --- Arrange for auxiliary modes to be loaded when required -*- lexical-binding: t; -*-

;; This file is part of Proof General.

Expand Down
2 changes: 1 addition & 1 deletion generic/proof-config.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; proof-config.el --- Proof General configuration for proof assistant
;;; proof-config.el --- Proof General configuration for proof assistant -*- lexical-binding: t; -*-

;; This file is part of Proof General.

Expand Down
2 changes: 1 addition & 1 deletion generic/proof-easy-config.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; proof-easy-config.el --- Easy configuration for Proof General
;;; proof-easy-config.el --- Easy configuration for Proof General -*- lexical-binding: t; -*-

;; This file is part of Proof General.

Expand Down
2 changes: 1 addition & 1 deletion generic/proof-faces.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; proof-faces.el --- Faces for Proof General
;;; proof-faces.el --- Faces for Proof General -*- lexical-binding: t; -*-

;; This file is part of Proof General.

Expand Down
Loading
Loading