Closed husainaloos closed 10 years ago
First:
I do not provide flycheck-google-cpplint-command
option in flycheck version. That means, you have need to add /usr/local/bin
to PATH
environment. (see also: EmacsWiki: Exec Path)
Second:
If you not use cppcheck
. You have need to change flycheck-add-next-checker
.
(flycheck-add-next-checker 'c/c++-clang
'(warnings-only . c/c++-googlelint))
Please try above two points.
@senda-akiha flycheck-google-cpplint-command
is automatically declared by Flycheck. Changing this variable is sufficient to make Flycheck find cpplint
.
Besides, the error message indicates that Flycheck actually runs cpplint, but is unable to parse it's output.
@husainaloos Can you try M-x flycheck-select-checker RET c/c++-googlelint
and then C-c ! C-c
in a C++ buffer? Flycheck should pop up a buffer which shows the entire output of googlelint. Can you paste that here?
@lunaryorn This is what I get
-*- mode: compilation; default-directory: "~/" -*-
Compilation started at Sun Mar 23 12:14:00
cpplint.py --verbose\=3 --filter\=-whitespace\,\+whitespace/braces --root\=project/src --linelength\=120 /home/husainaloos/test.cpp
Compilation exited abnormally with code 1 at Sun Mar 23 12:14:00
@husainaloos Do you get the same result when your run this command on the terminal?
@lunaryorn Yes I do.
Hmm. I tried to update PATH, change the path in flycheck-google-cpplint.el file, change my configurations, but with no success. Cppcheck works fine, but google-cpplint doesn't :/ I am still puzzled what's going on.
Update:
(1) I noticed that cpplint.py does not work. When I do cpplint.py test.cpp
I do get nothing. So I downloaded cpplint from the repository directly instead. Now cpplint test.cpp
outputs the error in test.cpp
.
(2) I changed my .emacs
and instead I added this:
(flycheck-mode 1)
(eval-after-load 'flycheck
'(progn
(require 'flycheck-google-cpplint)
(flycheck-add-next-checker 'c/c++-cppcheck
'c/c++-googlelint 'append)))
Which is what I found in my flycheck-google-cpplint.el
file. I changed the cpplint.py
to cpplint
in my flycheck-google-cpplint.el
as well.
Now when I run flycheck on test.cpp
file I get the following error:
Error: (user-error "Configured syntax checker c/c++-googlelint cannot be used")
Not sure where to go now...
@husainaloos The value of flycheck-c/c++-cpplint-executable
? Use C-h v
to find out.
(custom-set-variables
'(flycheck-c/c++-googlelint-executable "/usr/local/bin/cpplint.py"))
I did not know it would be able this. I will add it to README.
@senda-akiha @lunaryorn Finally works! It seems that the value was set to nil
for some reason.
Thanks!
Q: cpplint is applied to the .cpp file only when I save (it does not update the errors unless I save). is there a way to change that, to make it work as I type just like it does in flymake?
@husainaloos Flycheck will automatically check the buffer after changes, i.e. work like Flymake. If it doesn't in your case, you've disabled it. Check the value of flycheck-check-syntax-automatically
.
@lunaryorn The value is (save idle-change new-line mode-enabled)
, so that is fine.
cppcheck checks fine. It updates the errors and warning while editing the buffer. cpplint doesn't; i have to save the buffer in order for it to update. :/
@husainaloos Indeed, this syntax checker uses source-original
.
@senda-akiha Is there a reason why you use source-original
instead of source
or source-inplace
in this syntax checker?
@lunaryorn
Reason that I use a source-original
, because depends on the location of the file.
Examples: Assuing that src/.git exists, the header guard CPP variables for src/chrome/browser/ui/browser.h are:
No flag => CHROME_BROWSER_UI_BROWSER_H_ --root=chrome => BROWSER_UI_BROWSER_H_ --root=chrome/browser => UI_BROWSER_H_
In this case there's no other way, but you should use a predicate checking buffer-modified-p
.
@lunaryorn @senda-akiha Thank you both for help! Keep it up!
I am assuming that there is no clean fix for this. I will keep using flymake for cpplint and flycheck for cppcheck :)
@senda-akiha Your Flymake version of this works on a tempfile, though, so wouldn't it work source-inplace
instead?
Wondering if it is still can be solved.
I'm having a similar problem. Actually when I do M-x flycheck-select-checker RET c/c++-googlelint
but it's not working by default. Any ideas??
This is the important part of my configuration
(eval-after-load 'flycheck
'(progn
(require 'flycheck-google-cpplint)
(flycheck-add-next-checker 'c/c++-clang
'(warnings-only . c/c++-googlelint))))
(custom-set-variables
'(flycheck-c/c++-googlelint-executable "cpplint")
)
@silgon I think you need to change the last part to:
(custom-set-variables
'(flycheck-c/c++-googlelint-executable "/usr/local/bin/cpplint"))
or depending on where you installed the cpplint.
the excecutable is ok I think, because when I use M-x flycheck-select-checker RET c/c++-googlelint
it's working fine. But it's just not the default checker I think
@silgon then that means that is is probably not initualized when the c/c++ mode starts. Are you sure that your hook works fine?
sorry for the late response @husainaloos , i'm not sure then that the hook is working fine. I'm still using the code I told you before.
(eval-after-load 'flycheck
'(progn
(require 'flycheck-google-cpplint)
(flycheck-add-next-checker 'c/c++-clang
'(warnings-only . c/c++-googlelint))))
(custom-set-variables
'(flycheck-c/c++-googlelint-executable "cpplint")
)
How can I check it???
Any news about this? just checked again and flycheck is not picking by default c/c++-googlelint
. Thanks ;)
Hi, I tried to install the package, and I added the python file in /usr/local/bin/. I added the following in my .emacs
and hooked it with my c++-mode-hook. All I get when I activate flycheck-mode is this:
Any idea what's going on?