Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compilation issues and remove uses of old advice facility #670

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

monnier
Copy link
Contributor

@monnier monnier commented Sep 21, 2022

These patches fix some compilation problems (when compiling with the generic ELPA scripts rather than with our ad-hoc makefile), replace uses of the old advice facility with the corresponding new functions, and then fixes some (not all) compilation warnings and cosmetic issues found in the affected files.

Compilation typically failed because the files required some coq*.el
file when the `coq` subdir wasn't yet in `load-path`.
While at it, enable lexical-binding where still missing,
and fix some warnings.

* ci/simple-tests/test-prelude-correct.el:
* ci/simple-tests/test-coq-par-job-needs-compilation-quick.el:
* ci/compile-tests/cct-lib.el:
* ci/coq-tests.el: Eval `proof-ready-for-assistant` also during
compilation so that (require 'coq*) doesn't error out.

* ci/coq-tests.el (coq-fixture-on-file): Avoid `not-modified` which is
"interactive only".

* ci/init-tests.el: Don't fail compilation if `ert-async` is absent.

* ci/compile-tests/cct-lib.el: Fix compile warnings about quotes in docstrings.
Prefer #' to quote function names.

* ci/simple-tests/test-coq-par-job-needs-compilation-quick.el
(test-coq-par-test-data-invarint): Remove unused vars `test-id` and
`req-obj-result`.
Replace all uses of `defadvice` with `advice-add`.

* coq/coq.el: Remove coding cookie since .el files default to utf-8.
(coq--unset-double-hit-advice): New function extracted from advice.
(proof-electric-terminator-enable): Use `advice-add` instead of `defadvice`.

* generic/pg-autotest.el (proof--debug-to-log): New function extracted
from advice.
(proof-debug): Advice with `advice-add` rather than `defadvice`.

* generic/proof-syntax.el:
* lib/bufhist.el: Update comments to refer to `advice-add` rather than
`defadvice`.
Enable `lexical-binding` when missing in the files recently modified.
Fix compile warnings about quotes in docstrings.
Prefer #' to quote function names.

* coq/coq.el: Require `proof-syntax`, `proof-useropts`, and
`proof-utils` to silence some compiler warnings.
(action, string): Move dynbound declaration to a smaller scope in
`coq-preprocessing`.
(coq-set-state-infos, coq-grab-punctuation-left): Fit docstring within
80 columns.
(coq-diffs--setter, coq-diffs): Move `coq-diffs` var before first use.
(coq-shell-theorem-dependency-list-regexp)
(coq-dependency-menu-system-specific)
(coq-dependencies-system-specific): Move vars before their first use.
(coq-proof-tree-insert-evar-command): Simplify with `or`.
(coq-preprocessing): Declare `action` and `string` locally to be dynbound.
(coq-highlight-span-dependencies): Remove unused var `proof-pos`.
<trailer>: Remove second coding cookie since .el files default to utf-8.

* generic/pg-autotest.el: Use `lexical-binding`.
(pg-autotest-test-script-randomjumps): Remove unused var `random-edit`.
(pg-autotest-test-eval): Use lexical binding.

* generic/proof-script.el (proof-colour-locked, proof-setup-imenu)
(proof-colour-locked-span, proof-script-delete-spans)
(proof-goto-end-of-locked-on-error-if-pos-not-visible-in-window):
Fit docstring within 80 columns.

* generic/proof-syntax.el: Use `lexical-binding`.
(proof-replace-regexp-in-string, proof-re-search-forward)
(proof-re-search-backward, proof-re-search-forward-safe):
Fit docstring within 80 columns.
(proof-format): Use lexical binding.

* doc/PG-adapting.texi: (Auto)Update accordingly.
@monnier monnier force-pushed the scratch-defadvice-compilation branch from c93e58e to 6ee5a18 Compare September 21, 2022 03:28
@erikmd erikmd requested a review from a team November 15, 2022 22:22
@Matafou
Copy link
Contributor

Matafou commented Nov 16, 2022

LGTM. Thanks Stefan.

@@ -1,4 +1,4 @@
;; This file is part of Proof General.
;; This file is part of Proof General. -*- lexical-binding: t; -*-
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @monnier !

I am a aware that indeed, adding lexical-binding as soon as possible is a good rule-of-thumb if we can.

But just to name a potential issue, we had found some months ago when discussing in our regular PG telco that when you had enabled this mode everywhere in the code maintained by @hendriktews, the lexical-binding had broken some invariants :-/ (in some subtle cases I don't remember now)

And even I'm not fully savvy of all the implications of this mode, I just wanted to raise this point and say that maybe, it'd be wise not to add it blindly without some additional discussion…

So @monnier, could you try to summarize all the pros and cons of adding it?

Anyway, thanks for proposing this PR 👍

ci/init-tests.el Outdated
Comment on lines 10 to 12
;; FIXME: Merely loading a file should not have such side effects.
;; We should move all of that code into a function.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @monnier!
I was the main author of this file init-tests.el and coq-tests.el, and I'm totally aware that they raise unusual side effects at load time, but note that these two files are not intended at all to be required by users: the presence of these two files is just to make it possible (and easy) to load all the features, mocks, and so on, from the CI (without writing quoted-cluttered elisp code directly in the bash script) → see in particular the following line:

PG/ci/test.sh

Line 39 in 8e688a6

assert emacs --batch -l ert --eval "$form" -l init-tests.el -l proof-general.el -l coq-tests.el -f ert-run-tests-batch-and-exit

Are you fine with this layout?

or would you still request a refactoring of these two files?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Side question: would you recommend removing this line, perhaps? ↓

(provide 'coq-tests)

which has no equivalent at the end of init-tests.el, for example.

@erikmd
Copy link
Member

erikmd commented Nov 28, 2022

@monnier Hi again!, FYI we had a PG telco this morning, and just to recap:

  • @Matafou (the assignee of this PR) plans to merge this PR soon this week (not before Wednesday)
  • Meanwhile, @hendriktews and I will take a closer look at some specific files to help with the review
  • And also @monnier, feel free to comment if you have some hints regarding my previous questions

Thanks 👍👍

@monnier
Copy link
Contributor Author

monnier commented Nov 28, 2022 via email

@monnier
Copy link
Contributor Author

monnier commented Nov 28, 2022 via email

@monnier
Copy link
Contributor Author

monnier commented Nov 28, 2022 via email

@erikmd
Copy link
Member

erikmd commented Nov 28, 2022

Hi Stefan!

I was the main author of this file init-tests.el and coq-tests.el, and I'm totally aware that they raise unusual side effects at load time, but note that these two files are not intended at all to be required by users:
Problem is that they may get loaded anyway.

OK, but I don't see why "they may get loaded anyway" :)

To put things differently:

  • this ci/init-tests.el just acts as an adhoc init.el file (where the side-effects are desirable), loaded by the CI,
  • and likewise ci/coq-tests.el is either loaded by the CI, or by us to debug tests, see also e.g.:

https://github.com/ProofGeneral/PG/blob/master/ci/coq-tests.el#L8

Furthermore, note that the ci folder is NOT exported to MELPA, according to this recipe I had submitted:

https://github.com/melpa/melpa/blob/master/recipes/proof-general#L5-L8

But do you believe that the ci folder could be mistakenly exported to NonGNU ELPA? in which case, could you disable this?

Finally, even if I see your point of "better safe than sorry", I don't see any issue with these two files, which are not distributed to end users.

Still, I will push a small commit to remove the (provide 'coq-tests) line which seems unneeded, and replace (require 'ert-async nil t) with (require 'ert-async), because the init-tests.el's role is essentially to install ert-async, which is a package needed by (CI and locally-runnable) tests, so if (require 'ert-async) fails, it is valuable to know that it failed.

@monnier
Copy link
Contributor Author

monnier commented Nov 28, 2022 via email

@erikmd
Copy link
Member

erikmd commented Dec 1, 2022

Hi @monnier ! thanks.
Actually I don't disagree with what you propose… but in thise case, could you please push some commit in your PR that implements this suggestion of yours?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants