diff --git a/ci/compile-tests/cct-lib.el b/ci/compile-tests/cct-lib.el index 45d966178..e19224497 100644 --- a/ci/compile-tests/cct-lib.el +++ b/ci/compile-tests/cct-lib.el @@ -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 diff --git a/ci/simple-tests/README.md b/ci/simple-tests/README.md index 4c9613bc8..abd2abff8 100644 --- a/ci/simple-tests/README.md +++ b/ci/simple-tests/README.md @@ -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 diff --git a/ci/simple-tests/coq-test-changes-in-comments.el b/ci/simple-tests/coq-test-changes-in-comments.el index 0fd1cdc3c..23f316d83 100644 --- a/ci/simple-tests/coq-test-changes-in-comments.el +++ b/ci/simple-tests/coq-test-changes-in-comments.el @@ -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. ;; diff --git a/ci/simple-tests/coq-test-coqtop-unavailable.el b/ci/simple-tests/coq-test-coqtop-unavailable.el index 02ca960f4..1da1811ac 100644 --- a/ci/simple-tests/coq-test-coqtop-unavailable.el +++ b/ci/simple-tests/coq-test-coqtop-unavailable.el @@ -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. ;; diff --git a/ci/simple-tests/coq-test-goals-present.el b/ci/simple-tests/coq-test-goals-present.el index c7adb360b..3d5fa3f12 100644 --- a/ci/simple-tests/coq-test-goals-present.el +++ b/ci/simple-tests/coq-test-goals-present.el @@ -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. ;; diff --git a/ci/simple-tests/coq-test-hook-variables.el b/ci/simple-tests/coq-test-hook-variables.el new file mode 100644 index 000000000..eae268a41 --- /dev/null +++ b/ci/simple-tests/coq-test-hook-variables.el @@ -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 diff --git a/ci/simple-tests/coq-test-omit-proofs.el b/ci/simple-tests/coq-test-omit-proofs.el index ffc8e6aa0..ef6394337 100644 --- a/ci/simple-tests/coq-test-omit-proofs.el +++ b/ci/simple-tests/coq-test-omit-proofs.el @@ -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. ;; diff --git a/ci/simple-tests/coq-test-par-job-needs-compilation-quick.el b/ci/simple-tests/coq-test-par-job-needs-compilation-quick.el index a9fce9ddc..03ef09ca6 100644 --- a/ci/simple-tests/coq-test-par-job-needs-compilation-quick.el +++ b/ci/simple-tests/coq-test-par-job-needs-compilation-quick.el @@ -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. diff --git a/ci/simple-tests/coq-test-prelude-correct.el b/ci/simple-tests/coq-test-prelude-correct.el index 427851c7f..7330cdb5c 100644 --- a/ci/simple-tests/coq-test-prelude-correct.el +++ b/ci/simple-tests/coq-test-prelude-correct.el @@ -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. ;; diff --git a/ci/simple-tests/coq-test-proof-stat.el b/ci/simple-tests/coq-test-proof-stat.el index a4ed2602b..194a9e32e 100644 --- a/ci/simple-tests/coq-test-proof-stat.el +++ b/ci/simple-tests/coq-test-proof-stat.el @@ -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. ;; diff --git a/ci/simple-tests/coq-test-response-after-show.el b/ci/simple-tests/coq-test-response-after-show.el index b4fb8117b..bdbabecc6 100644 --- a/ci/simple-tests/coq-test-response-after-show.el +++ b/ci/simple-tests/coq-test-response-after-show.el @@ -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. ;; diff --git a/ci/simple-tests/coq-test-three-window.el b/ci/simple-tests/coq-test-three-window.el index 44a94a572..13b035dc7 100644 --- a/ci/simple-tests/coq-test-three-window.el +++ b/ci/simple-tests/coq-test-three-window.el @@ -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 diff --git a/ci/simple-tests/qrhl-test-input.el b/ci/simple-tests/qrhl-test-input.el index c654dcafd..eed7a6026 100644 --- a/ci/simple-tests/qrhl-test-input.el +++ b/ci/simple-tests/qrhl-test-input.el @@ -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. ;; diff --git a/ci/test-indent/coq-test-indent.el b/ci/test-indent/coq-test-indent.el index 232043313..d0faa255f 100644 --- a/ci/test-indent/coq-test-indent.el +++ b/ci/test-indent/coq-test-indent.el @@ -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 diff --git a/coq/coq-mode.el b/coq/coq-mode.el index fa0b108f7..0a6d6f47e 100644 --- a/coq/coq-mode.el +++ b/coq/coq-mode.el @@ -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) diff --git a/coq/coq-queries.el b/coq/coq-queries.el index 3f8ff469c..709a0216c 100644 --- a/coq/coq-queries.el +++ b/coq/coq-queries.el @@ -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. diff --git a/doc/PG-adapting.texi b/doc/PG-adapting.texi index b9ca6d68c..14a6d4b25 100644 --- a/doc/PG-adapting.texi +++ b/doc/PG-adapting.texi @@ -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 @@ -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 diff --git a/doc/docstring-magic.el b/doc/docstring-magic.el index 7ff84883b..8e086bda5 100644 --- a/doc/docstring-magic.el +++ b/doc/docstring-magic.el @@ -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. diff --git a/easycrypt/easycrypt-abbrev.el b/easycrypt/easycrypt-abbrev.el index fa9cdcfc7..6e0200b03 100644 --- a/easycrypt/easycrypt-abbrev.el +++ b/easycrypt/easycrypt-abbrev.el @@ -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 diff --git a/easycrypt/easycrypt-hooks.el b/easycrypt/easycrypt-hooks.el index 376936f61..8d05523ac 100644 --- a/easycrypt/easycrypt-hooks.el +++ b/easycrypt/easycrypt-hooks.el @@ -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 diff --git a/easycrypt/easycrypt-keywords.el b/easycrypt/easycrypt-keywords.el index fa5ab9711..39aed9741 100644 --- a/easycrypt/easycrypt-keywords.el +++ b/easycrypt/easycrypt-keywords.el @@ -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 diff --git a/easycrypt/easycrypt-syntax.el b/easycrypt/easycrypt-syntax.el index 4b84d3bd3..2d3d54d0a 100644 --- a/easycrypt/easycrypt-syntax.el +++ b/easycrypt/easycrypt-syntax.el @@ -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 diff --git a/easycrypt/easycrypt.el b/easycrypt/easycrypt.el index 802fd69c7..66d444fbd 100644 --- a/easycrypt/easycrypt.el +++ b/easycrypt/easycrypt.el @@ -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 diff --git a/etc/emacsbugs/visiblity-attempt.el b/etc/emacsbugs/visiblity-attempt.el index b64861161..3d81c5718 100644 --- a/etc/emacsbugs/visiblity-attempt.el +++ b/etc/emacsbugs/visiblity-attempt.el @@ -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. diff --git a/etc/testsuite/pg-pgip-test.el b/etc/testsuite/pg-pgip-test.el index 871763123..f38ee0668 100644 --- a/etc/testsuite/pg-pgip-test.el +++ b/etc/testsuite/pg-pgip-test.el @@ -1,4 +1,4 @@ -;;; Tests for pg-pgip.el +;;; Tests for pg-pgip.el -*- lexical-binding: t; -*- ;; This file is part of Proof General. diff --git a/etc/testsuite/pg-test.el b/etc/testsuite/pg-test.el index ce973427e..8381450b0 100644 --- a/etc/testsuite/pg-test.el +++ b/etc/testsuite/pg-test.el @@ -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. diff --git a/generic/pg-assoc.el b/generic/pg-assoc.el index a76408177..d8ea18b75 100644 --- a/generic/pg-assoc.el +++ b/generic/pg-assoc.el @@ -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. diff --git a/generic/pg-autotest.el b/generic/pg-autotest.el index 9525adb67..2accd73f1 100644 --- a/generic/pg-autotest.el +++ b/generic/pg-autotest.el @@ -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. diff --git a/generic/pg-custom.el b/generic/pg-custom.el index a013bd6ca..abff0b82a 100644 --- a/generic/pg-custom.el +++ b/generic/pg-custom.el @@ -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. diff --git a/generic/pg-goals.el b/generic/pg-goals.el index 49de8d550..478a2ea53 100644 --- a/generic/pg-goals.el +++ b/generic/pg-goals.el @@ -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. diff --git a/generic/pg-movie.el b/generic/pg-movie.el index 69de71606..13b181bd4 100644 --- a/generic/pg-movie.el +++ b/generic/pg-movie.el @@ -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. diff --git a/generic/pg-pgip.el b/generic/pg-pgip.el index 767b9d8dc..f50f69cf9 100644 --- a/generic/pg-pgip.el +++ b/generic/pg-pgip.el @@ -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. @@ -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))))) diff --git a/generic/pg-response.el b/generic/pg-response.el index 8725dd398..81d80023b 100644 --- a/generic/pg-response.el +++ b/generic/pg-response.el @@ -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. diff --git a/generic/pg-vars.el b/generic/pg-vars.el index e34c9865e..38854326e 100644 --- a/generic/pg-vars.el +++ b/generic/pg-vars.el @@ -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. diff --git a/generic/proof-auxmodes.el b/generic/proof-auxmodes.el index dfeb42654..8de20ffd3 100644 --- a/generic/proof-auxmodes.el +++ b/generic/proof-auxmodes.el @@ -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. diff --git a/generic/proof-config.el b/generic/proof-config.el index 0b0aa943b..8c89db43a 100644 --- a/generic/proof-config.el +++ b/generic/proof-config.el @@ -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. diff --git a/generic/proof-easy-config.el b/generic/proof-easy-config.el index 6639e9b26..6fb818902 100644 --- a/generic/proof-easy-config.el +++ b/generic/proof-easy-config.el @@ -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. diff --git a/generic/proof-faces.el b/generic/proof-faces.el index 7473fc268..76783f87c 100644 --- a/generic/proof-faces.el +++ b/generic/proof-faces.el @@ -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. diff --git a/generic/proof-indent.el b/generic/proof-indent.el index d8062cc10..29404a544 100644 --- a/generic/proof-indent.el +++ b/generic/proof-indent.el @@ -1,4 +1,4 @@ -;;; proof-indent.el --- Generic indentation for proof assistants +;;; proof-indent.el --- Generic indentation for proof assistants -*- lexical-binding: t; -*- ;; This file is part of Proof General. diff --git a/generic/proof-maths-menu.el b/generic/proof-maths-menu.el index 1c91c00ec..4486b03dd 100644 --- a/generic/proof-maths-menu.el +++ b/generic/proof-maths-menu.el @@ -1,4 +1,4 @@ -;;; proof-maths-menu.el --- Support for maths menu mode package +;;; proof-maths-menu.el --- Support for maths menu mode package -*- lexical-binding: t; -*- ;; This file is part of Proof General. diff --git a/generic/proof-menu.el b/generic/proof-menu.el index f697753fb..ce031beef 100644 --- a/generic/proof-menu.el +++ b/generic/proof-menu.el @@ -1,4 +1,4 @@ -;;; proof-menu.el --- Menus, keymaps, misc commands for Proof General +;;; proof-menu.el --- Menus, keymaps, misc commands for Proof General -*- lexical-binding: t; -*- ;; This file is part of Proof General. @@ -1054,28 +1054,31 @@ NB: variable `curvalue' is dynamically scoped (used in `proof-assistant-format') (defun proof-assistant-format-lambda (value) (funcall value)) -(defun proof-assistant-format (string curvalue) - "Replace a format characters in STRING by formatted CURVALUE. +(defun proof-assistant-format (string curvalue-arg) + "Replace a format characters in STRING by formatted CURVALUE-ARG. Format character is one of %b, %i, %f, %s, or %l. Formatting suitable for current proof assistant, controlled by `proof-assistant-format-table' which see. Finally, apply `proof-assistant-setting-format' if non-nil. Alternatively, STRING can be a function which yields a string when applied -to the CURVALUE. +to CURVALUE-ARG. As another special case for boolean settings: the setting STRING can be a cons cell of two strings, the first one for true (non-nil value) and the second for false." (let ((setting (cond ((stringp string) ;; use % format characters - ;; Dynbind for use in proof-assistant-format-table! + ;; Dynbind for use in proof-assistant-format-table! The + ;; argument must not have the same name: in interpreted + ;; code, the lexical argument would hide the dynamic binding + ;; when reading `curvalue' in this function. (with-no-warnings (defvar curvalue)) - (let ((curvalue curvalue)) + (let ((curvalue curvalue-arg)) (proof-format proof-assistant-format-table string))) ((functionp string) ;; call the function - (funcall string curvalue)) + (funcall string curvalue-arg)) ((consp string) ;; true/false options - (if curvalue (car string) (cdr string))) + (if curvalue-arg (car string) (cdr string))) (t ;; no idea what to do (error "Function proof-assistant-format: called with invalid string arg %s" string))))) (if proof-assistant-setting-format diff --git a/generic/proof-shell.el b/generic/proof-shell.el index 989e1f006..811bbc03b 100644 --- a/generic/proof-shell.el +++ b/generic/proof-shell.el @@ -1,4 +1,4 @@ -;;; proof-shell.el --- Proof General shell mode +;;; proof-shell.el --- Proof General shell mode -*- lexical-binding: t; -*- ;; This file is part of Proof General. @@ -587,6 +587,7 @@ shell buffer, called by `proof-shell-bail-out' if process exits." (proc (get-buffer-process (current-buffer))) (bufname (buffer-name))) (message "%s, cleaning up and exiting..." bufname) + (defvar prover-was-busy) ; see `proof-shell-signal-interrupt-hook' (let (prover-was-busy) ;; hook functions might set prover-was-busy (run-hooks 'proof-shell-signal-interrupt-hook)) @@ -949,6 +950,7 @@ In the first case, PG will terminate the queue of commands at the first available point. In the second case, you may need to press enter inside the prover command buffer (e.g., with Isabelle2009 press RET inside *isabelle*)." (interactive) + (defvar prover-was-busy) ; see `proof-shell-signal-interrupt-hook' (let ((prover-was-busy nil)) (unless (proof-shell-live-buffer) (error "Proof process not started!")) @@ -975,18 +977,19 @@ the prover command buffer (e.g., with Isabelle2009 press RET inside *isabelle*). ;; ;;;###autoload -(defun proof-shell-insert (strings action &optional scriptspan) +(defun proof-shell-insert (strings action-arg &optional scriptspan-arg) "Insert STRINGS at the end of the proof shell, call `scomint-send-input'. STRINGS is a list of strings (which will be concatenated), or a single string. -The ACTION argument is a symbol which is typically the name of a +The ACTION-ARG argument is a symbol which is typically the name of a callback for when each string has been processed. -This calls `proof-shell-insert-hook'. The arguments ACTION and -SCRIPTSPAN may be examined by the hook to determine how to modify -the string variable (exploiting dynamic scoping) which will be +This calls `proof-shell-insert-hook'. The hook functions see +ACTION-ARG and SCRIPTSPAN-ARG in the dynamically bound variables +`action' and `scriptspan', which they may examine to determine how +to modify the dynamically bound variable `string', which will be the command actually sent to the shell. Note that the hook is not called for the empty (null) string @@ -1006,9 +1009,18 @@ used in `proof-add-to-queue' when we start processing a queue, and in (with-current-buffer proof-shell-buffer (goto-char (point-max)) + ;; Functions on `proof-shell-insert-hook' read and modify these + ;; variables through dynamic scoping. Arguments must not have the + ;; same names: in interpreted code, the lexical argument would + ;; hide the dynamic binding when reading the variable here. + (defvar string) + (defvar action) + (defvar scriptspan) ;; TEMP: next step: preprocess list of strings directly (let ((string (if (stringp strings) strings - (apply 'concat strings)))) + (apply 'concat strings))) + (action action-arg) + (scriptspan scriptspan-arg)) ;; Hook for munging `string' and other dirty hacks. (run-hooks 'proof-shell-insert-hook) @@ -1210,18 +1222,26 @@ This function calls `proof-add-to-queue' with args QUEUEITEMS and QUEUEMODE." ;;;###autoload -(defun proof-extend-queue (end queueitems) - "Extend the current queue with QUEUEITEMS, queue end END. +(defun proof-extend-queue (end queueitems-arg) + "Extend the current queue with QUEUEITEMS-ARG, queue end END. To make sense, the commands should correspond to processing actions for processing a region from (buffer-queue-or-locked-end) to END. -The queue mode is set to \\+`advancing'" +The queue mode is set to \\+`advancing'. +The functions on `proof-shell-extend-queue-hook' see QUEUEITEMS-ARG +in the dynamically bound variable `queueitems' and may modify it." (proof-set-queue-endpoints (proof-unprocessed-begin) end) - (condition-case err - (run-hooks 'proof-shell-extend-queue-hook) - ((error quit) - (proof-detach-queue) - (signal (car err) (cdr err)))) - (proof-add-to-queue queueitems 'advancing)) + ;; Functions on `proof-shell-extend-queue-hook' read and may modify + ;; `queueitems' through dynamic scoping. The argument must not have + ;; the same name: in interpreted code, the lexical argument would + ;; hide the dynamic binding when reading `queueitems' below. + (defvar queueitems) + (let ((queueitems queueitems-arg)) + (condition-case err + (run-hooks 'proof-shell-extend-queue-hook) + ((error quit) + (proof-detach-queue) + (signal (car err) (cdr err)))) + (proof-add-to-queue queueitems 'advancing))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/generic/proof-syntax.el b/generic/proof-syntax.el index c01eb1bfb..72e4d9a21 100644 --- a/generic/proof-syntax.el +++ b/generic/proof-syntax.el @@ -1,4 +1,4 @@ -;;; proof-syntax.el --- Functions for dealing with syntax +;;; proof-syntax.el --- Functions for dealing with syntax -*- lexical-binding: t; -*- ;; This file is part of Proof General. diff --git a/generic/proof-toolbar.el b/generic/proof-toolbar.el index 7bffbad2e..ddf4a393e 100644 --- a/generic/proof-toolbar.el +++ b/generic/proof-toolbar.el @@ -1,4 +1,4 @@ -;;; proof-toolbar.el --- Toolbar for Proof General +;;; proof-toolbar.el --- Toolbar for Proof General -*- lexical-binding: t; -*- ;; This file is part of Proof General. diff --git a/generic/proof-unicode-tokens.el b/generic/proof-unicode-tokens.el index 7e96ca95b..d1e28d8ef 100644 --- a/generic/proof-unicode-tokens.el +++ b/generic/proof-unicode-tokens.el @@ -1,4 +1,4 @@ -;;; proof-unicode-tokens.el --- Support Unicode tokens package +;;; proof-unicode-tokens.el --- Support Unicode tokens package -*- lexical-binding: t; -*- ;; This file is part of Proof General. diff --git a/generic/proof-useropts.el b/generic/proof-useropts.el index c204687f1..3ea2001d1 100644 --- a/generic/proof-useropts.el +++ b/generic/proof-useropts.el @@ -1,4 +1,4 @@ -;;; proof-useropts.el --- Global user options for Proof General +;;; proof-useropts.el --- Global user options for Proof General -*- lexical-binding: t; -*- ;; This file is part of Proof General. diff --git a/generic/proof-utils.el b/generic/proof-utils.el index e47aaab55..da0860c2a 100644 --- a/generic/proof-utils.el +++ b/generic/proof-utils.el @@ -1,4 +1,4 @@ -;;; proof-utils.el --- Proof General utility functions and macros +;;; proof-utils.el --- Proof General utility functions and macros -*- lexical-binding: t; -*- ;; This file is part of Proof General. @@ -116,6 +116,7 @@ Return nil if not a script buffer or if no active scripting buffer." (interactive) (unless (proof-try-require 'package) (error "The package feature is not available!")) + (defvar package-menu-async) (let ((package-menu-async nil)) (package-list-packages) (package-menu-mark-upgrades) @@ -366,6 +367,8 @@ If flag `proof-general-debug' is nil, do nothing." (when proof-general-debug (with-current-buffer (get-buffer-create "*PG Debug*") (help-mode) + (defvar warning-minimum-log-level) + (defvar warning-minimum-level) (let ((formatted (apply 'format msg args)) (warning-minimum-log-level :debug) (warning-minimum-level :debug) diff --git a/lib/local-vars-list.el b/lib/local-vars-list.el index d2b5ec8dc..114ad9a0d 100644 --- a/lib/local-vars-list.el +++ b/lib/local-vars-list.el @@ -1,4 +1,4 @@ -;;; local-vars.el --- local variables list utilities +;;; local-vars.el --- local variables list utilities -*- lexical-binding: t; -*- ;; This file is part of Proof General. diff --git a/lib/pg-dev.el b/lib/pg-dev.el index 20ed98380..e7f9942bc 100644 --- a/lib/pg-dev.el +++ b/lib/pg-dev.el @@ -1,4 +1,4 @@ -;;; pg-dev.el --- Developer settings for Proof General +;;; pg-dev.el --- Developer settings for Proof General -*- lexical-binding: t; -*- ;; This file is part of Proof General. diff --git a/lib/pg-fontsets.el b/lib/pg-fontsets.el index 2cb61a458..243de0f94 100644 --- a/lib/pg-fontsets.el +++ b/lib/pg-fontsets.el @@ -1,4 +1,4 @@ -;;; pg-fontsets.el --- Define fontsets useful for Proof General +;;; pg-fontsets.el --- Define fontsets useful for Proof General -*- lexical-binding: t; -*- ;; This file is part of Proof General. diff --git a/lib/scomint.el b/lib/scomint.el index eef4e522d..7be44b40d 100644 --- a/lib/scomint.el +++ b/lib/scomint.el @@ -1,4 +1,4 @@ -;;; scomint.el --- Simplified comint for less interactive shells +;;; scomint.el --- Simplified comint for less interactive shells -*- lexical-binding: t; -*- ;; This file is part of Proof General. diff --git a/lib/unicode-chars.el b/lib/unicode-chars.el index 2b8547395..f50dec8f2 100644 --- a/lib/unicode-chars.el +++ b/lib/unicode-chars.el @@ -1,4 +1,4 @@ -;;; unicode-chars.el --- table of Unicode characters +;;; unicode-chars.el --- table of Unicode characters -*- lexical-binding: t; -*- ;; This file is part of Proof General. diff --git a/obsolete/demoisa/demoisa-easy.el b/obsolete/demoisa/demoisa-easy.el index b6e0e67db..0e3ece049 100644 --- a/obsolete/demoisa/demoisa-easy.el +++ b/obsolete/demoisa/demoisa-easy.el @@ -1,4 +1,4 @@ -;; demoisa-easy.el --- Example Proof General instance for Isabelle +;; demoisa-easy.el --- Example Proof General instance for Isabelle -*- lexical-binding: t; -*- ;; ;; Copyright (C) 1999 LFCS Edinburgh. ;; diff --git a/obsolete/demoisa/demoisa.el b/obsolete/demoisa/demoisa.el index aa4bcf76e..e9f78e8c6 100644 --- a/obsolete/demoisa/demoisa.el +++ b/obsolete/demoisa/demoisa.el @@ -1,4 +1,4 @@ -;;; demoisa.el --- Example Proof General instance for Isabelle +;;; demoisa.el --- Example Proof General instance for Isabelle -*- lexical-binding: t; -*- ;; ;; Copyright (C) 1999 LFCS Edinburgh. ;; diff --git a/pghaskell/pghaskell.el b/pghaskell/pghaskell.el index 88dd44bc9..109db6157 100644 --- a/pghaskell/pghaskell.el +++ b/pghaskell/pghaskell.el @@ -1,4 +1,4 @@ -;;; pghaskell.el --- Proof General for Haskell scripts. +;;; pghaskell.el --- Proof General for Haskell scripts. -*- lexical-binding: t; -*- ;; This file is part of Proof General. diff --git a/pgocaml/pgocaml.el b/pgocaml/pgocaml.el index ce899c457..cace3de45 100644 --- a/pgocaml/pgocaml.el +++ b/pgocaml/pgocaml.el @@ -1,4 +1,4 @@ -;;; pgocaml.el --- Proof General for OCaml scripts. +;;; pgocaml.el --- Proof General for OCaml scripts. -*- lexical-binding: t; -*- ;; This file is part of Proof General. diff --git a/pgshell/pgshell.el b/pgshell/pgshell.el index 0521b3f96..c4be775a1 100644 --- a/pgshell/pgshell.el +++ b/pgshell/pgshell.el @@ -1,4 +1,4 @@ -;;; pgshell.el --- Proof General for shell scripts. +;;; pgshell.el --- Proof General for shell scripts. -*- lexical-binding: t; -*- ;; This file is part of Proof General. diff --git a/phox/phox.el b/phox/phox.el index 81ccb2b77..c52e61d2c 100644 --- a/phox/phox.el +++ b/phox/phox.el @@ -1,4 +1,4 @@ -;;; phox.el --- Major mode for the PhoX proof assistant +;;; phox.el --- Major mode for the PhoX proof assistant -*- lexical-binding: t; -*- ;; This file is part of Proof General.