From 499c24935919d98bcde058ff314111f702fa0e13 Mon Sep 17 00:00:00 2001 From: Pierre Courtieu Date: Fri, 30 Oct 2026 19:05:45 +0100 Subject: [PATCH 1/8] proof-shell.el: switch to lexical binding. Keep dynamic the variables that hook functions read or modify: string, action and scriptspan for proof-shell-insert-hook, queueitems for proof-shell-extend-queue-hook and prover-was-busy for proof-shell-signal-interrupt-hook. Co-Authored-By: Claude Opus 5.5 --- generic/proof-shell.el | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/generic/proof-shell.el b/generic/proof-shell.el index 989e1f006..966a967a7 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!")) @@ -1006,9 +1008,16 @@ 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. + (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) + (scriptspan scriptspan)) ;; Hook for munging `string' and other dirty hacks. (run-hooks 'proof-shell-insert-hook) @@ -1216,12 +1225,16 @@ 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'" (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. + (defvar queueitems) + (let ((queueitems queueitems)) + (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))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; From 8ad4d6e8cc5b3e6acbb4afcae2c4f428750d7a24 Mon Sep 17 00:00:00 2001 From: Pierre Courtieu Date: Fri, 30 Oct 2026 22:27:38 +0100 Subject: [PATCH 2/8] Switch all remaining Elisp files to lexical binding. Add the lexical-binding cookie to the first line of every Elisp file that still lacked it. The few places that relied on dynamic binding are fixed in the next commit. Co-Authored-By: Claude Opus 5.5 --- ci/compile-tests/cct-lib.el | 2 +- ci/simple-tests/coq-test-changes-in-comments.el | 2 +- ci/simple-tests/coq-test-coqtop-unavailable.el | 2 +- ci/simple-tests/coq-test-goals-present.el | 2 +- ci/simple-tests/coq-test-omit-proofs.el | 2 +- ci/simple-tests/coq-test-par-job-needs-compilation-quick.el | 2 +- ci/simple-tests/coq-test-prelude-correct.el | 2 +- ci/simple-tests/coq-test-proof-stat.el | 2 +- ci/simple-tests/coq-test-response-after-show.el | 2 +- ci/simple-tests/coq-test-three-window.el | 2 +- ci/simple-tests/qrhl-test-input.el | 2 +- ci/test-indent/coq-test-indent.el | 2 +- doc/docstring-magic.el | 2 +- easycrypt/easycrypt-abbrev.el | 2 +- easycrypt/easycrypt-hooks.el | 2 +- easycrypt/easycrypt-keywords.el | 2 +- easycrypt/easycrypt-syntax.el | 2 +- easycrypt/easycrypt.el | 2 +- etc/emacsbugs/visiblity-attempt.el | 2 +- etc/testsuite/pg-pgip-test.el | 2 +- etc/testsuite/pg-test.el | 2 +- generic/pg-assoc.el | 2 +- generic/pg-autotest.el | 2 +- generic/pg-custom.el | 2 +- generic/pg-goals.el | 2 +- generic/pg-movie.el | 2 +- generic/pg-pgip.el | 2 +- generic/pg-response.el | 2 +- generic/pg-vars.el | 2 +- generic/proof-auxmodes.el | 2 +- generic/proof-config.el | 2 +- generic/proof-easy-config.el | 2 +- generic/proof-faces.el | 2 +- generic/proof-indent.el | 2 +- generic/proof-maths-menu.el | 2 +- generic/proof-menu.el | 2 +- generic/proof-syntax.el | 2 +- generic/proof-toolbar.el | 2 +- generic/proof-unicode-tokens.el | 2 +- generic/proof-useropts.el | 2 +- generic/proof-utils.el | 2 +- lib/local-vars-list.el | 2 +- lib/pg-dev.el | 2 +- lib/pg-fontsets.el | 2 +- lib/scomint.el | 2 +- lib/unicode-chars.el | 2 +- obsolete/demoisa/demoisa-easy.el | 2 +- obsolete/demoisa/demoisa.el | 2 +- pghaskell/pghaskell.el | 2 +- pgocaml/pgocaml.el | 2 +- pgshell/pgshell.el | 2 +- phox/phox.el | 2 +- 52 files changed, 52 insertions(+), 52 deletions(-) diff --git a/ci/compile-tests/cct-lib.el b/ci/compile-tests/cct-lib.el index 797ef2862..f65ca077e 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/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 24df17fec..989b36f35 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-omit-proofs.el b/ci/simple-tests/coq-test-omit-proofs.el index a95bb8d7f..6952a3d8c 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 f58b7ee56..47735a3d4 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 1b7dad1ee..c9c32085c 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/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 d3e872855..b6793a15e 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..f2dd0739f 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. diff --git a/generic/pg-response.el b/generic/pg-response.el index 1310db03b..b4989d266 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 44977b3eb..85ae229c7 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 f9801bbae..3f708823f 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. 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 bba559d62..6db02d0ec 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 fdfc1f7f1..96339d432 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. 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 72202eec3..bad9cb5c1 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. From 917a84521d8b25f5d0bdc70431c16e2d93b9b5a3 Mon Sep 17 00:00:00 2001 From: Pierre Courtieu Date: Fri, 30 Oct 2026 22:27:42 +0100 Subject: [PATCH 3/8] Fix the places that relied on dynamic binding. * proof-utils.el (proof-upgrade-elpa-packages): declare package-menu-async special, otherwise binding it to nil has no effect on package.el. (proof-debug): same for warning-minimum-log-level and warning-minimum-level, which may not be known as special when the function is compiled or evaluated. * pg-pgip.el (pg-pgip-process-newfile): set the buffer-local proverid to the value of the local variable, instead of setting the lexical variable to itself. Co-Authored-By: Claude Opus 5.5 --- generic/pg-pgip.el | 3 +-- generic/proof-utils.el | 3 +++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/generic/pg-pgip.el b/generic/pg-pgip.el index f2dd0739f..f50f69cf9 100644 --- a/generic/pg-pgip.el +++ b/generic/pg-pgip.el @@ -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/proof-utils.el b/generic/proof-utils.el index 96339d432..e37a6b7f1 100644 --- a/generic/proof-utils.el +++ b/generic/proof-utils.el @@ -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) From 79bac231002ac5ceba0a2a0f7f68f9674f91b3f1 Mon Sep 17 00:00:00 2001 From: Pierre Courtieu Date: Fri, 30 Oct 2026 23:15:50 +0100 Subject: [PATCH 4/8] proof-extend-queue: fix queueitems in interpreted code. In interpreted code, the lexical argument queueitems hid the dynamic binding of queueitems when reading it after running proof-shell-extend-queue-hook. Changes made by the hook functions were therefore lost. For instance with coq-compile-before-require, Require commands were sent to Coq before their dependencies were compiled. Byte-compiled code was not affected. Rename the argument to avoid the clash. Co-Authored-By: Claude Opus 5.5 --- doc/PG-adapting.texi | 8 ++++---- generic/proof-shell.el | 10 ++++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/doc/PG-adapting.texi b/doc/PG-adapting.texi index b9ca6d68c..28563bdb2 100644 --- a/doc/PG-adapting.texi +++ b/doc/PG-adapting.texi @@ -4109,16 +4109,16 @@ 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 items +Extend the current queue with @var{items}, 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} @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 items +Extend the current queue with @var{items}, 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} diff --git a/generic/proof-shell.el b/generic/proof-shell.el index 966a967a7..43fb6f3d6 100644 --- a/generic/proof-shell.el +++ b/generic/proof-shell.el @@ -1219,16 +1219,18 @@ 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 items) + "Extend the current queue with ITEMS, 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'" (proof-set-queue-endpoints (proof-unprocessed-begin) end) ;; Functions on `proof-shell-extend-queue-hook' read and may modify - ;; `queueitems' through dynamic scoping. + ;; `queueitems' through dynamic scoping. The argument must not be + ;; called `queueitems': in interpreted code, the lexical argument + ;; would hide the dynamic binding when reading `queueitems' below. (defvar queueitems) - (let ((queueitems queueitems)) + (let ((queueitems items)) (condition-case err (run-hooks 'proof-shell-extend-queue-hook) ((error quit) From ae6abad42046905c41ec9f456d9524e949123e97 Mon Sep 17 00:00:00 2001 From: Pierre Courtieu Date: Fri, 30 Oct 2026 23:21:47 +0100 Subject: [PATCH 5/8] Add a test for the variables shared with proof shell hooks. Test that the functions on proof-shell-extend-queue-hook, proof-shell-insert-hook and proof-shell-signal-interrupt-hook can read and modify the variables they share with proof-shell.el through dynamic binding, with proof-shell.el both interpreted and byte-compiled. Co-Authored-By: Claude Opus 5.5 --- ci/simple-tests/README.md | 4 + ci/simple-tests/coq-test-hook-variables.el | 108 +++++++++++++++++++++ 2 files changed, 112 insertions(+) create mode 100644 ci/simple-tests/coq-test-hook-variables.el diff --git a/ci/simple-tests/README.md b/ci/simple-tests/README.md index 9d85beb0c..93d14bf69 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-proof-stat-batch-test : Batch mode test for proof-check-proofs. There is no Emacs lisp file for this test. It is programmed out in the Makefile goal 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 From 91790107403e1ad885236c42252eea057d2d77ad Mon Sep 17 00:00:00 2001 From: Pierre Courtieu Date: Fri, 30 Oct 2026 23:34:05 +0100 Subject: [PATCH 6/8] Name arguments that initialize hook variables with an -arg suffix. When an argument initializes a dynamic variable shared with hook functions, it must not have the same name as that variable: in interpreted code, the lexical argument would hide the dynamic binding when the variable is read in the function, as happened with queueitems in proof-extend-queue. Use the suffix -arg systematically for such arguments: queueitems-arg in proof-extend-queue, action-arg and scriptspan-arg in proof-shell-insert, and curvalue-arg in proof-assistant-format. Co-Authored-By: Claude Opus 5.5 --- doc/PG-adapting.texi | 27 ++++++++++++++++----------- generic/proof-menu.el | 17 ++++++++++------- generic/proof-shell.el | 35 ++++++++++++++++++++--------------- 3 files changed, 46 insertions(+), 33 deletions(-) diff --git a/doc/PG-adapting.texi b/doc/PG-adapting.texi index 28563bdb2..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 items -Extend the current queue with @var{items}, 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 items -Extend the current queue with @var{items}, 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/generic/proof-menu.el b/generic/proof-menu.el index 3f708823f..7e440d6c0 100644 --- a/generic/proof-menu.el +++ b/generic/proof-menu.el @@ -1067,28 +1067,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 43fb6f3d6..811bbc03b 100644 --- a/generic/proof-shell.el +++ b/generic/proof-shell.el @@ -977,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 @@ -1009,15 +1010,17 @@ used in `proof-add-to-queue' when we start processing a queue, and in (goto-char (point-max)) ;; Functions on `proof-shell-insert-hook' read and modify these - ;; variables through dynamic scoping. + ;; 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))) - (action action) - (scriptspan scriptspan)) + (action action-arg) + (scriptspan scriptspan-arg)) ;; Hook for munging `string' and other dirty hacks. (run-hooks 'proof-shell-insert-hook) @@ -1219,18 +1222,20 @@ This function calls `proof-add-to-queue' with args QUEUEITEMS and QUEUEMODE." ;;;###autoload -(defun proof-extend-queue (end items) - "Extend the current queue with ITEMS, 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) ;; Functions on `proof-shell-extend-queue-hook' read and may modify - ;; `queueitems' through dynamic scoping. The argument must not be - ;; called `queueitems': in interpreted code, the lexical argument - ;; would hide the dynamic binding when reading `queueitems' below. + ;; `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 items)) + (let ((queueitems queueitems-arg)) (condition-case err (run-hooks 'proof-shell-extend-queue-hook) ((error quit) From e6517e1d9e2b373a1d2aef1244e44e2d4ec9f3ce Mon Sep 17 00:00:00 2001 From: Pierre Courtieu Date: Thu, 5 Nov 2026 12:18:58 +0100 Subject: [PATCH 7/8] coq-indent.el: same require comment as master (avoids a merge conflict). Co-Authored-By: Claude Opus 5.5 --- coq/coq-indent.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coq/coq-indent.el b/coq/coq-indent.el index 695e49de0..6eaa45e8d 100644 --- a/coq/coq-indent.el +++ b/coq/coq-indent.el @@ -24,7 +24,7 @@ ;;; Code: -(require 'proof-syntax) ; proof-inside-comment +(require 'proof-syntax) ; proof-looking-at etc., no proof shell ;; debugging From fb22a409cc5b388e89c0dc0f024a3962b5ad3be5 Mon Sep 17 00:00:00 2001 From: Pierre Courtieu Date: Thu, 5 Nov 2026 16:18:58 +0100 Subject: [PATCH 8/8] coq-mode.el: remove the declare-function of coq-pg-setup, master has it. Master declares it too, next to a require this branch does not have yet: removing it here avoids a merge conflict. Co-Authored-By: Claude Opus 5.5 --- coq/coq-mode.el | 2 -- 1 file changed, 2 deletions(-) diff --git a/coq/coq-mode.el b/coq/coq-mode.el index 465c513db..5eb1213fe 100644 --- a/coq/coq-mode.el +++ b/coq/coq-mode.el @@ -31,8 +31,6 @@ (require 'coq-queries) ; common to all backends (require 'coq-templates) ; abbrevs and yasnippets, idem -(declare-function coq-pg-setup "coq") ; coq.el requires this file - (defgroup coq-mode () "Major mode to edit Coq code." :group 'programming)