Skip to content

Option to disable reading subfiles #200

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

Closed
real-or-random opened this issue Jan 24, 2022 · 4 comments
Closed

Option to disable reading subfiles #200

real-or-random opened this issue Jan 24, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@real-or-random
Copy link
Contributor

real-or-random commented Jan 24, 2022

Related to #131 but I think it's different.

When using this as a linter in an IDE (e.g., using the emacs/flycheck integration), depending on the IDE, all I want is to have the output for the single file I'm currently editing, because this is where warnings can be displayed.

That is, if I'm currently looking at main.tex, I want only main.tex to be checked and not all of its subfiles. I can have them checked when I open them. Currently in emacs/flycheck, all files will be checked, which is then just a waste of time because only all warnings in the other files will be discarded anyway.

I think a simple option such as --one-file will do the trick already.

@real-or-random
Copy link
Contributor Author

Hm for flycheck, this can be worked around easily by using source instead of source-inplace. I'll try to work on a few more improvements for the flycheck integration and open a PR. Maybe we can then even submit it to flycheck. A quick question: Do you think it's okay to add the error type (e.g., [lt:...]) to the singleline output?

Leaving this open because I still think a command-line option will be useful. Feel free to close the issue if you disagree.

@sylvainhalle
Copy link
Owner

I agree. It would be easy to add a --one-file switch and I'll do it in the next release. As for the single line output, again it would be no problem adding the error type, but I think some people use this output elsewhere, so I am not sure if changing the output format would break their pipelines.

@sylvainhalle sylvainhalle added the enhancement New feature or request label Jan 25, 2022
@real-or-random
Copy link
Contributor Author

Here's an improved version of the README snippet which I've been using for a while. It works pretty well for me.

(flycheck-define-checker tex-textidote
  "A LaTeX grammar/spelling checker using textidote.

  See https://github.com/sylvainhalle/textidote"
  :modes (latex-mode plain-tex-mode)
  :command ("java" "-jar" (eval (expand-file-name "/usr/share/java/textidote.jar"))
            "--read-all"
            "--output" "singleline"
            "--no-color"
            "--check"   (eval (if ispell-current-dictionary (substring ispell-current-dictionary 0 2) "en"))
            ;; Try to honor local aspell dictionary and replacements if they exist
            "--dict"    (eval (expand-file-name "~/.aspell.en.pws"))
            "--replace" (eval (expand-file-name "~/.aspell.en.prepl"))
            ;; Using source ensures that a single temporary file in a different dir is created
            ;; such that textidote won't process other files. This serves as a hacky workaround for
            ;; https://github.com/sylvainhalle/textidote/issues/200.
            source)
  :error-patterns ((warning line-start (file-name)
                            "(L" line "C" column "-" (or (seq "L" end-line "C" end-column) "?") "): "
                            (message (one-or-more (not "\""))) (one-or-more not-newline) line-end)))
(add-to-list 'flycheck-checkers 'tex-textidote)

Caveats:

  • This suffers from a tiny bug in textidote in the "singleline" output. There are always two "." before "Suggestions", e.g., "Possible spelling mistake found.. Suggestions:"
  • It may be useful to add the error type. (There could also be another option different from "singleline".)
  • It would be nice to parse the "Suggestions" and present them to the user but apparently flycheck cannot do this at all at the moment: Error fixers flycheck/flycheck#530

An entirely different approach would be parse the JSON, and then maybe feed it to https://github.com/PillFall/Emacs-LanguageTool.el .

@sylvainhalle
Copy link
Owner

PR #223 fixes the two "." before "Suggestions"

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

No branches or pull requests

2 participants