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 'perl-module-list' option #1207
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great PR! Thank you for this contribution.
LGTM except the variable version number and a minor question in the tests.
flycheck.el
Outdated
string is a module to 'use' in Perl." | ||
:type '(repeat :tag "Module") | ||
:safe #'flycheck-string-list-p | ||
:package-version '(flycheck . "30.0")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The version would be "31" since "30" has already been released, and we dropped decimals since version 26.
test/flycheck-test.el
Outdated
'(4 nil error "Global symbol \"$dependency_b\" requires explicit package name (did you forget to declare \"my $dependency_b\"?)" | ||
:checker perl)) | ||
;; Including those modules should allow them to check | ||
(cl-letf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It did not occur to me we could call -should-syntax-check
multiple times in the same test. Is it just to regroup the checks under the same 'module' test? Or are there any other benefits? (Just curious; it's fine as is)
Why cl-letf
though? Wouldn't a simple let
would suffice to override the variable for the next call to -should-syntax-check
?
Oh and I guess the line in CHANGES.rst should be moved to |
Thanks; the code looks good (and thanks @fmdkdd for the review). I don't speak much Perl; can you explain the rationale for this change? In which cases would you set this variable (and what are the alternatives?) |
@fmdkdd Fixed the issues. @cpitclaudel |
@michaelblack Thanks; does that mean that when you run the script itself you also pass it these modules? The docs suggest that "use module" is the same as passing -Mmodule; can you clarify in which cases using I'm a bit worried about this kind of options, because they tend to be too specific to Flycheck. For example, can your script currently be run in cperl-mode? Should we really add this setting to Flycheck, or should we instead add it to e.g. cperl-mode? |
Yep. You would, and if you are expecting that to be the case, then you would have to do something awkward such as include it in the file for the purposes of flycheck then removing the line when actually running in order to avoid duplicate imports. This is especially true in the case where there are scripts wrapping perl to pass the -M option with no real way to change it. As for cases when you are running perl directly, in terms of best practices for passing
I can't speak to that as I haven't used other perl IDEs (and when looking around, the ones that do exist have sparse documentation). For what it's worth though, I have seen this option passed into syntax checkers rather commonly in vim, where arbitrary arguments to the executable are allowed.
Well cperl can't replace flycheck. If the flycheck executable is set to perl without the modules, it will still report invalid errors, such as invalid modules, variables, and subroutines (and potentially much more given perl's somewhat horrifying ability to modify syntax on module import). |
Hey @cpitclaudel Also on this
I realized I may have misunderstood. Were you talking about potentially adding a custom variable for those modes and introducing a dependency on that? |
Sorry for the delay. I think you make a valid case for this setting. Sorry for being unclear about the best location for this setting. I was wondering whether cperl or other modes or packages provided any feature that would require running perl, and would benefit from knowing which flags to run perl with. If not, then it makes sense to add the setting here. On the other hand, if that setting might be useful to another package as well, then it makes sense to add it to e.g. cperl-mode. Other than this, I'm happy with the implementation :) Thanks! |
@cpitclaudel So, does it looks good to you? I've re-read the discussion and I don't really understand what you mean by "adding it to another package". If the setting was available in @michaelblack In any case, could you rebase your branch on top of master? |
Yup
My point was that if the user wants to run Perl for Flycheck with a given flag, they probably want other instances of Perl started from Emacs on the same file to use that flag too. Given this, it'd make more sense to have the variable controlling that flag defined in, say, cperl-mode, and then using that variable from Flycheck. But that's minor; I'd rather see this merged than wait longer :) If cperl-mode gains a similar option, users can easily make the flycheck one an alias of the cperl one. |
@cpitclaudel Now I do get it. Thanks for taking the time to explain :) @michaelblack All good then, you just have to rebase and we'll happily merge! |
5f26a49
to
51b762c
Compare
51b762c
to
c3f4a5e
Compare
Rebased and merged :) |
This just adds the ability to specify perl modules to
use
via the-M
flag when syntax checking.I ran
make check unit specs LANGUAGE=perl integ
without errors.