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

Add a command-line option --porcelain for machine-readable output #15

Merged
merged 5 commits into from
Dec 13, 2024

Conversation

Witiko
Copy link
Owner

@Witiko Witiko commented Dec 13, 2024

This PR makes the following changes:

  • Add a command-line option --porcelain for machine-readable output.

Demonstration

$ git clone https://github.com/witiko/expltools
$ git checkout feat/porcelain
$ cd expltools/explcheck/src
$ ./explcheck.lua ../testfiles/e102.tex
Checking 1 file

Checking ../testfiles/e102.tex                                  2 errors

    ../testfiles/e102.tex:11:1:          E102 expl3 control sequences in non-expl3 parts
    ../testfiles/e102.tex:12:3:          E102 expl3 control sequences in non-expl3 parts

Total: 2 errors, 0 warnings in 1 file
$ ./explcheck.lua ../testfiles/e102.tex --porcelain
../testfiles/e102.tex:11:1: E102 expl3 control sequences in non-expl3 parts
../testfiles/e102.tex:12:3: E102 expl3 control sequences in non-expl3 parts

This change was made after a discussion with @FrankMittelbach in #8 (comment) and below. It should enable better integration with text editors in the absence of language sever protocol (LSP) support in this early version of explcheck, as discussed in #8 (comment).

I will test this change with Vim and emacs later today and will post screenshots as an interim documentation of the feature. Please, let me know if this is what you had in mind, @FrankMittelbach.

This PR closes ticket #8, together with pull requests #14 and #16.

@Witiko
Copy link
Owner Author

Witiko commented Dec 13, 2024

Demonstation

[...]

I will test this change with Vim and emacs later today and will post screenshots as an interim documentation of the feature. Please, let me know if this is what you had in mind, @FrankMittelbach.

Emacs

In emacs, open a file such as testfiles/e102.tex from the example in #15 (comment) and execute the following commands, as previously discussed in #8 (comment):

M-x compile
explcheck --porcelain -- e102.tex

This will cause emacs to execute explcheck and let you navigate among the errors by clicking or using (previous-error) and (next-error) commands:

image

Lines in a different format such as file-wide warnings and errors are ignored by emacs, as expected. However, all issues are recognized as errors by emacs, whereas we would like it to recognize warnings.

Vim

In vim, open a file such as testfiles/e102.tex from the example in #15 (comment) and execute the following commands, as previously discussed in #8 (comment):

:set errorformat=%f:%l:%c:\ %m
:set makeprg=explcheck\ --porcelain\ --\ %
:make

This will cause vim to execute explcheck and let you navigate among the errors with commands :cprev and :cnext:

vim-01
vim-02
vim-03

Lines in a different format such as file-wide warnings and errors are ignored by vim, as expected.

@Witiko
Copy link
Owner Author

Witiko commented Dec 13, 2024

However, all issues are recognized as errors by emacs, whereas we would like it to recognize warnings.

Emacs seems to use a collection of different patterns compilation-error-regexp-alist-alist that cover a variety of common compilers and tools (like gcc, g++, make, javac, etc.). Our format is similar to that of g++:

^\\(.*\\):\\([0-9]+\\):\\([0-9]+:\\)? \\(error\\|warning\\|note\\): 

Adding error: or warning: to the machine-readable output of explcheck should do the trick.

@Witiko
Copy link
Owner Author

Witiko commented Dec 13, 2024

Adding error: or warning: to the machine-readable output of explcheck should do the trick.

I made this change in commit 0a4aa68 from this PR:

Demonstration

$ git clone https://github.com/witiko/expltools
$ git checkout feat/porcelain
$ cd expltools/explcheck/src
$ ./explcheck.lua ../testfiles/e102.tex
Checking 1 file

Checking ../testfiles/e102.tex                                  2 errors

    ../testfiles/e102.tex:11:1:          E102 expl3 control sequences in non-expl3 parts
    ../testfiles/e102.tex:12:3:          E102 expl3 control sequences in non-expl3 parts

Total: 2 errors, 0 warnings in 1 file
$ ./explcheck.lua ../testfiles/e102.tex --porcelain
../testfiles/e102.tex:11:1: error: E102 expl3 control sequences in non-expl3 parts
../testfiles/e102.tex:12:3: error: E102 expl3 control sequences in non-expl3 parts

Emacs

Warnings and errors are now correctly recognized by emacs:

image

@Witiko Witiko marked this pull request as ready for review December 13, 2024 21:57
@Witiko
Copy link
Owner Author

Witiko commented Dec 13, 2024

@FrankMittelbach: I believe that this should conclude this PR.

@Witiko Witiko merged commit 70ace27 into main Dec 13, 2024
5 checks passed
@Witiko Witiko deleted the feat/porcelain branch December 13, 2024 22:00
@FrankMittelbach
Copy link
Contributor

FrankMittelbach commented Dec 13, 2024 via email

@Witiko
Copy link
Owner Author

Witiko commented Dec 13, 2024

yes Vit, except for misspelling my name :-)

Sorry about that, should be all good now. 👍

@FrankMittelbach
Copy link
Contributor

yes Vit, except for misspelling my name :-)

Sorry about that, should be all good now. 👍

don't worry... with my track record of typos ... it is just that misspelling might result in not reaching me (it did, but that is because I already contributed to this issue I guess).

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

Successfully merging this pull request may close these issues.

2 participants