I've just started to use Flycheck to improve the quality of my code, and I am grateful that it is helping me to do that by pointing out assignments to free variables, and by identifying possibly undefined functions on the last line of the error display. (Actually, these two are Warnings, not errors.)
I would like to see no warnings in my error display, of course.
So is there a way for me to tell Flycheck about the global variables that I use on my project, and that I reference in multiple files? I have the appropriate defvar statements in one file, but not in all files. And I don't want to put defvar statements in every file that references them (I think, unless that's really the proper Emacs Lisp way...)
And is there a way for me to tell Flycheck about all the functions (which are defined in other files) that I reference in many files? That way only the truly undefined functions will show up in the last line of the Flycheck output. (I have so many that I don't usually want to flog through the long list of functions that I already know are defined, just to find ones that are possibly not defined.
I looked at the Flycheck manual on the home website, but it said nothing about this sort of thing. Neither could I see any sort of config variables for Lisp "include" or "prefix" files where I could point Flycheck to the file containing all my defvar statements...
defvar
once, that silences it for that variable for any subsequent compilations (in that session). So if you byte-compile several files, it is enough to put the vacuousdefvar
in the first that you compile. Likewise, for function declarations. You can put all of them in the same file, which you byte-compile first. – Drew Jun 27 '16 at 15:55defvar
,(declare...
, and(declare-function ..
, but the only times they help Flycheck is when the declarations appear in the file explicitly. That means I would need to maintain a pile of them in every Lisp file that I use. Instead, I put a job on my TODO list to write some functions to insert a pile of such declarations into each buffer on thefind-file-hook
and to remove them on thebefore-save-hook
. Maybe that approach will accomplish my goals (low maintenance) while keeping Flycheck happy. – Kevin Jun 27 '16 at 16:37require
the files with the definitions. – npostavs Jun 27 '16 at 16:41(require 'my-other-file-1)
,(require 'file2)
, etc in each of my source files, and that would make Flycheck pick them up? I could try that. I get the sense that these suggestions are for the byte compiler more than Flycheck, but if Flycheck just calls the byte compiler (it might well do that, I don't know), then I should start to focus my thinking on the byte compiler, and not on Flycheck. I know that Flycheck calls external syntax checkers, but didn't connect that with the byte compiler until just now. – Kevin Jun 27 '16 at 18:16defvar
anddeclare-function
sexps that are needed. – Drew Jun 27 '16 at 19:07(require 'dcls (concat default-directory "dcls.el"))
does the job. Thank you everyone. – Kevin Jun 27 '16 at 21:25load-path
instead of passing path torequire
. – npostavs Jun 27 '16 at 22:36(require 'my-dcls)
, even though the declaration files are on the load-path. I amended the original post above to show the issue, rather than start up a new question. – Kevin Jun 28 '16 at 14:00(require 'my-dcls)
, so I posted another question here http://emacs.stackexchange.com/questions/24261/flycheck-variable-warnings-despite-flycheck-load-path, and have entered a bug report on Github for Flycheck here https://github.com/flycheck/flycheck/issues/1002. Hopefully I will eventually find a solution. – Kevin Jun 30 '16 at 14:52