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

Need a version of flycheck-define-checker and flycheck-define-command-checker that doesn't have to have the checker executable be hard-coded to a string but rather looked up dynamically #2045

Open
nordlow opened this issue Nov 21, 2023 · 1 comment

Comments

@nordlow
Copy link
Contributor

nordlow commented Nov 21, 2023

I want a version of

flycheck-define-checker and flycheck-define-command-checker

that doesn't have to have the checker executable be hard-coded to a string.

This is needed for source files for the D programming language (.d .di) that have the prefix

#!/usr/bin/env dub

at the top of its contents. Such a .d FILE is called as a script via dub --single FILE.d instead of the D compiler typically being dmd.

I guess I can use flycheck-define-generic-checker but that API is so different from flycheck-define-command-checker.

So instead of my current

(flycheck-define-checker d-dmd-all
  "A D syntax checker using the DMD (or LDC) compiler."
  :command ("dmd"
            (eval (flycheck-d-compiler-args default-directory "dmd"))
            source) ;(source ".d") makes ‘flycheck-compile’ output refer to temporary files which is worthless
  :error-patterns   ;TODO merge with ‘d-dmd-compilation-error-rx’
  ((error line-start (file-name) "(" line "," column "): Error: " (message) line-end)
   (warning line-start (file-name) "(" line "," column "): "
            (or "Warning" "Deprecation") ": " (message) line-end) ;TODO `compilation-deprecation-face'
   (info line-start (file-name) "(" line "," column "): "
         (or "Info" "Debug") ": " (message) line-end) ;TODO `compilation-debug-face'
   (info line-start (file-name) "(" line "," column "):" space (message) line-end) ;unclassified
   (info line-start
         (file-name) "(" line "," column "): " (or "Info" "Remark" "vgc" "vtemplate") ": " (message) ;TODO `compilation-info-face'
         line-end))
  :modes (d-mode d-ts-mode)
  ;; currently no way of seeing the resource requirements for individual checkers in the mode-line:
  ;; :next-checkers ((warning . d-dscanner-style))
  )

I would like to be able to write

(flycheck-define-checker d-dmd-or-dub-all
  :command (eval (flycheck-d-compiler-command default-directory))
  ;; ...
  )

. I can of course duplicate the checker but that needs to copy all the :error-patterns and use two passing of :predicate one to d-dmd-all and the inversion to d-dub-all which is not adhere to the DRY-pattern. Can't you just relax the requirement that the first element of the :command property must be known at evaluation time to be a string?

@nordlow nordlow changed the title Need a version of flycheck-define-checker and flycheck-define-command-checker doesn't have to have the checker executable be hard-coded to a string. Need a version of flycheck-define-checker and flycheck-define-command-checker that doesn't have to have the checker executable be hard-coded to a string. Nov 21, 2023
@nordlow nordlow changed the title Need a version of flycheck-define-checker and flycheck-define-command-checker that doesn't have to have the checker executable be hard-coded to a string. Need a version of flycheck-define-checker and flycheck-define-command-checker that doesn't have to have the checker executable be hard-coded to a string Nov 21, 2023
@nordlow nordlow changed the title Need a version of flycheck-define-checker and flycheck-define-command-checker that doesn't have to have the checker executable be hard-coded to a string Need a version of flycheck-define-checker and flycheck-define-command-checker that doesn't have to have the checker executable be hard-coded to a string but rather looked up dynamically Nov 21, 2023
@bbatsov
Copy link
Contributor

bbatsov commented Feb 28, 2024

I'll have to think about this, as your use-case is quite peculiar and I don't recall anyone else asking for something similar.

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

No branches or pull requests

2 participants