help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Flycheck reports are never satisfying!?


From: Sebastian Wiesner
Subject: Re: Flycheck reports are never satisfying!?
Date: Thu, 28 Aug 2014 17:45:24 +0200

Am 28.08.2014 um 17:39 schrieb Sebastien Vauban <sva-news@mygooglest.com>:

> Hello Sebastian,
> 
> Sebastian Wiesner wrote:
>> Am 28.08.2014 um 14:05 schrieb Sebastien Vauban <sva-news@mygooglest.com>:
>> 
>>> Trying to use, since short, Flycheck on all my prog modes; hence, on my
>>> Emacs configuration file as well.
>>> 
>>> Though, as you can see on http://screencast.com/t/gfzLGy2h6fH, it never
>>> is satisfying: there are always reports of errors or warnings, while my
>>> code is completely clean (IMO).
>> 
>> It’s not.  Flycheck runs the byte compiler on your init.el, and…
>> 
>>> Two ECM follow, showing what happens for all packages which I load and
>>> customize.
>>> 
>>>   Note that, here, I took an extract from Flycheck's configuration
>>>   itself, but the problem is the same with every third party
>>>   package...
>>> 
>>> 1. With an explicit package require:
>>> 
>>> --8<---------------cut here---------------start------------->8---
>>> ;;; .emacs-minimal.el --- Test file
>>> 
>>> ;;; Commentary:
>>> 
>>> ;;; Code:
>>> 
>>> (add-to-list 'load-path "~/.emacs.d/elpa/flycheck-20140824.731/„)
>> 
>> …this expression is **not** evaluated by the byte compiler, so…
> 
> Anything to do about this?

eval-and-compile

> 
>> (in an unrelated note, this is a *very strange thing to do*.  The path 
>> suggests
>> that you are using package.el to install Flycheck, but in that case you 
>> should
>> *not* set up the load-path manual.  Instead call "(package-initialize)")
> 
> I know package, and I'm using it.
> 
> Here, in an ECM ("Minimal Working Example", in French), I've added that
> line to my .emacs to really show that the path was correctly set up.

I found that confusing.
> 
>> Top-level "require"s are a special case.  The byte compiler evaluates these 
>> to
>> load dependencies and macros, but it will **not** generally evaluated other
>> expressions.
> 
> And many parts of my .emacs are in macros such as RunningWindows,
> GNUEmacs, RunningCygwinVersion, etc.
> 
>>> ;; modern on-the-fly syntax checking
>>> (when (try-require 'flycheck)
>>> 
>>> ;; indicate errors and warnings via icons in the left fringe
>>> (setq flycheck-indication-mode 'left-fringe)
>>> 
>>> ;; enable Flycheck mode in all buffers
>>> (add-hook 'after-init-hook 'global-flycheck-mode))
>>> 
>>> (provide '.emacs-minimal)
>>> 
>>> ;;; .emacs-minimal.el ends here
>>> --8<---------------cut here---------------end--------------->8---
>>> 
>>> Flycheck reports one ERROR:
>>> 
>>> --8<---------------cut here---------------start------------->8---
>>>   9   1 error    Cannot open load file: no such file or directory, flycheck 
>>> (emacs-lisp)
>>> --8<---------------cut here---------------end--------------->8---
>>> 
>>> 2. With an implicit package require (call to function `try-require'):
>>> 
>>> --8<---------------cut here---------------start------------->8---
>>> ;;; .emacs-minimal2.el --- Test file
>>> 
>>> ;;; Commentary:
>>> 
>>> ;;; Internal function:
>>> 
>>> (defun try-require (feature)
>>> "Attempt to load a FEATURE (or library).
>>> Return true if the library given as argument is successfully loaded.  If
>>> not, just print a message."
>>> (condition-case err
>>>     (progn (if (stringp feature)
>>>                (load-library feature)
>>>              (require feature)) t)
>>>   (file-error (message "Missing package `%s'!" feature) nil)))
>>> 
>>> ;;; Code:
>>> 
>>> (add-to-list 'load-path "~/.emacs.d/elpa/flycheck-20140824.731/")
>>> 
>>> ;; modern on-the-fly syntax checking
>>> (when (try-require ‚flycheck)
>> 
>> As said above, the byte compiler doesn’t evaluate arbitrary expressions, and 
>> it
>> doesn’t evaluate this call either.  Hence, it never attempts to actually load
>> Flycheck, so there’s no error, but since Flycheck isn’t loaded, you get the
>> warnings about free variables.
>> 
>>> ;; indicate errors and warnings via icons in the left fringe
>>> (setq flycheck-indication-mode 'left-fringe)
>>> 
>>> ;; enable Flycheck mode in all buffers
>>> (add-hook 'after-init-hook 'global-flycheck-mode))
>>> 
>>> (provide '.emacs-minimal2)
>>> 
>>> ;;; .emacs-minimal2.el ends here
>>> --8<---------------cut here---------------end--------------->8---
>>> 
>>> Flycheck reports one warning:
>>> 
>>> --8<---------------cut here---------------start------------->8---
>>>  25   9 warning  assignment to free variable `flycheck-indication-mode' 
>>> (emacs-lisp)
>>> --8<---------------cut here---------------end--------------->8---
>>> 
>>> How am I supposed to do, if Flycheck reports things that shouldn't be
>>> reported?
>> 
>> Generally, you should set the corresponding options of the "emacs-lisp" 
>> syntax
>> checker [1] to set the "load-path" for Flycheck, or enable "package.el" for
>> Flycheck.
>> 
>> However, as far as "init.el" is concerned, Flycheck should automatically 
>> enable
>> package.el for syntax checking.  This doesn't seem to work in your case, and
>> indicates that there is something unusual about your setup, so please open an
>> issue in Flycheck's issue tracker at 
>> https://github.com/flycheck/flycheck/issues
> 
> In my case, in fact, my init.el is just a stub with my really really
> personal settings. It calls another file with more general settings,
> which I share with colleagues. All my problems are in this last file,
> which is of course much bigger.
> 
> This particularity can explain that package is not enabled, right?

I presume that this “shared” file is not in "~/.emacs.d/", is it?  In that 
case, Flycheck can't know that it's part of your Emacs configuration, and 
treats it as if it were any random Emacs Lisp file, which means that packages 
aren't enabled.

Add "flycheck-emacs-lisp-initialize-packages" to the file-local variables of 
that file, with a value of t.  This forces Flycheck to enable packages when 
checking the file.

> 
>> [1]: 
>> http://flycheck.readthedocs.org/en/latest/guide/languages.html#el.flycheck-checker.emacs-lisp
> 
> Best regards,
>  Seb
> 
> -- 
> Sebastien Vauban




reply via email to

[Prev in Thread] Current Thread [Next in Thread]