User-defined `coq-prog-args` gets reset to `("-emacs")` on every `proof-shell-start`
Hi,
Problem description: As per title.
Steps to reproduce:
- Simply set
coq-prog-argsto some values. E.g.(setq coq-prog-args '("-set" "Printing Parentheses")). - In a Coq file, run
M-x proof-shell-start, orC-c C-sbound toproof-toggle-active-scripting. - Then, you can see that
coq-prog-argsis now set to("-emacs").
Problem diagnosis:
-
Function
coq-prog-argsis run right before everyproof-shell-start. https://github.com/ProofGeneral/PG/blob/ec4f9bad18f6c8336e53910d3ea941d5ceb52f52/coq/coq-system.el#L659-L667 -
In
coq-prog-args, the functioncoq-load-project-filefails to detectcoq-load-argsfromfile-local-variables-alist. https://github.com/ProofGeneral/PG/blob/ec4f9bad18f6c8336e53910d3ea941d5ceb52f52/coq/coq-system.el#L626-L627 -
Indeed, in any newly opened Coq file, the
file-local-variables-alistisnil.
So, now, if I M-x eval-expression, then (push (cons 'coq-prog-args coq-prog-args) file-local-variables-alist) and starts the proof-shell. Everything works as expected.
But then now the variable coq-prog-args is modified to custom value specified for the current file and Coq project. And if I stop and start the proof-shell again, the same file-specific arguments will be appended to coq-prog-args again and again.
I haven't found out which function does that. But maybe it should work on the file-local coq-prog-args value and not the user-defined one...
Summary: There are two things gone wrong here:
- PG needs a way to detect whether a user has defined a custom
coq-prog-args, but it fails. - PG needs a way to compute a file-/project-specific arguments to Coq, but it modifies the custom variable
coq-prog-argsinstead. This is surprising to the user, because custom variable should only be modifiable by the user. Perhaps storing the computed arguments ascoq-computed-argsinto thefile-local-variables-alistwould solve the problem(?).
Thanks!
Environment:
Using Coq v8.15.1
Melpa version: proof-general-20220610.705.
Variable value of proof-general-version: "Proof General Version 4.5-git."
Good point. IMHO the idea is either you have a _CoqProject file either you set coq-prog-args because implicitly coq-prog-args is mainly for setting the load-path.
For user options you should probably use coq-user-init-cmd for user preferences like this.
If we stick to this policy we should probably document it.
Hmmm, but coq-user-init-cmd is defined as a constant, not a custom variable... That's why I'm not aware of it in the M-x customize-group options.
Indeed it is a bit rough at the edges. We need to make this easier to set up. Especially because dune is also coming in the game and we probably will have more use case like yours.
Okay, not sure how is that relevant to my issue.
Anyways, my workaround solution is to place user-wide configuration into ~/.coqrc.
As for this issue, I'll leave it open since it's unsolved. Thanks!
Agreed, this needs a proper and documented solution.