Repository navigation
Conversation
These warnings are displayed to users by asynchronous native compilation (Emacs 30 reports this kind of warning by default). - coq-indent.el: require proof-syntax for proof-inside-comment, which was void when coq-mode was loaded without the rest of Proof General. - easycrypt.el: remove unused easycrypt-redisplay-hook, which called the nonexistent function easycrypt-redisplay. - coq-diffs.el: require span for span-make. - Add declare-function for functions from files with circular dependencies, optional libraries (yasnippet, package, unicode-chars), and in the simple tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
* 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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
|
@hendriktews I know you basically have no time to chheck. I will have a special look at proof-tree before merging. |
|
For the record proof-tree seems to work OK. |
|
I think it is worth explaining the problems encountered with the switch to lexical binding. It allows:
Note: this is a text generated by the llm (claude) that helped me during the switch. Pitfalls of the switch to lexical binding1. Variables shared with hook functions
These are short, unprefixed names that are easy to miss. Find them by reading what the functions of each hook read or modify. 2. An argument with the same name as a dynamic variableThis was the trickiest bug. In
Fixes:
Important Test both interpreted and byte-compiled. The bug above only shows up in interpreted code. 3. Binding a variable of a library that is not loaded yetIf
4.
|
|
@cpitclaudel you might want to test company-coq against this branch. I don't know how much you rely on dynamic variables. It seems to work ok. |
|
`proof-shell.el` binds some variables, runs a hook, then reads the variables
back. The hook functions read or modify them. With lexical binding, a `let`
is not visible from the hook functions. These variables must therefore stay
dynamic, with a file-level `defvar` (499c249):
- `string`, `action` and `scriptspan` for `proof-shell-insert-hook`;
- `queueitems` for `proof-shell-extend-queue-hook`;
- `prover-was-busy` for `proof-shell-signal-interrupt-hook`.
These are short, unprefixed names that are easy to miss. Find them by
reading what the functions of each hook read or modify.
BTW, while the immediate solution is to (defvar VAR) somewhere before
the var is let-bound, in the longer term, we should rename those vars to
have an appropriate namespace prefix.
### 4. `setq` of a buffer-local variable named like an argument
In `pg-pgip-process-newfile`, `(setq proverid proverid)` was meant to set
the buffer-local variable. With lexical binding, it sets the argument to
itself and does nothing. Fixed with `(set (make-local-variable 'proverid)
proverid)` (917a845).
Same here, except that the need for a namespace prefix is more urgent
for buffer-local variable.
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
b955e91 to
7c3aa40
Compare
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 <noreply@anthropic.com>
This PR is currently based on another one: #893.
Switch all Elisp files to lexical binding.
Currently depends on #893 (its commits appear here until it is merged).
lexical-binding: tto the remaining files and fix the places that relied on dynamic binding (package-menu-async, warning-minimum-level, proverid).Tested locally with Emacs 30.1 and rocq-9.2, rocq-9.0 and coq-8.20, without and with .elc: simple-tests, compile-tests, test-indent, make tests, qrhl-all, doc magic.