When run from the command line ( emacs filename.py ), flymake and pylint work perfectly together. Errors are highlighted properly. (Although I can't get a hint to get error data, because it's text mode.)
When launched from the GUI (Carbon Emacs), Flymake returns immediately, and the first line in the file is highlighted with the error " in <module> ". The first line shows the error even in the "Hello World" script.) I would like it to work properly in graphical mode so that I can move with the mouse (I know, know) and use the tooltips to get information about the reported pylint errors .
I installed pylint with " easy_install pylint " and the pylint and epylint scripts are in " ~/py/scripts ". I added this directory to my PATH in my .bashrc:
export PATH=$PATH:~/py/scripts
(My .profile is a symbolic link to my .bashrc.)
I realized that Emacs-GUI does not load the path from my .bashrc, so I created the ~ / .MacOSX / environment.plist file, setting the PATH variable with the full PATH that I see in the terminal.
Now in Emacs-GUI " (getenv "PATH") " the output looks correct:
"/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/X11/bin:/Users/schof/py/scripts:/usr/X11R6/bin"
Similarly, the output of " Ch v exec-path " looks right:
("/usr/bin" "/bin" "/usr/sbin" "/sbin" "/usr/local/bin" "/usr/local/git/bin" "/usr/X11/bin" "/Users/schof/py/scripts" "/Applications/Emacs.app/Contents/MacOS/libexec" "/Applications/Emacs.app/Contents/MacOS/bin" "/usr/X11R6/bin")
This leaves me with no further ideas on how I should solve this. I am by no means an emacs guru, so maybe I missed something obvious here; Feel free to ask more details.
OS X 10.6.7; Carbon Emacs 22.3.1; pylint 0.23.0.
Flymake / Pylint code from .emacs:
(when (load "flymake" t) (defun flymake-pylint-init () (let* ((temp-file (flymake-init-create-temp-buffer-copy 'flymake-create-temp-inplace)) (local-file (file-relative-name temp-file (file-name-directory buffer-file-name)))) (list "epylint" (list local-file)))) (add-to-list 'flymake-allowed-file-name-masks '("\\.py\\'" flymake-pylint-init))) ;; Auto-start flymake-mode when you go into python-mode (add-hook 'python-mode-hook '(lambda () (setq python-indent 4) (flymake-mode)))
Update 2011-04-05 in response to @sanityinc answer:
The output of level 3 of the flymake dictionary in *messages* : (This does not make the source of the problem obvious to me.)
starting syntax check as new-line has been seen flymake is running: nil file /Users/schof/pytest.py, init=flymake-pylint-init [3 times] create-temp-inplace: file=/Users/schof/pytest.py temp=/Users/schof/pytest_flymake.py saved buffer pytest.py in file /Users/schof/pytest_flymake.py started process 3221, command=(epylint pytest_flymake.py), dir=/Users/schof/ received 704 byte(s) of output from process 3221 file /Users/schof/pytest.py, init=flymake-pylint-init parsed 'Traceback (most recent call last):', no line-err-info parse line: file-idx=2 line-idx=3 file=/Users/schof/py/scripts/epylint line=4 text=in <module> get-real-file-name: file-name=/Users/schof/py/scripts/epylint real-name=~/py/scripts/epylint parsed ' File "/Users/schof/py/scripts/epylint", line 4, in <module>', got line-err-info parsed ' import pkg_resources', no line-err-info parse line: file-idx=2 line-idx=3 file=/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py line=2556 text=in <module> get-real-file-name: file-name=/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py real-name=/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py parsed ' File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py", line 2556, in <module>', got line-err-info parsed ' working_set.require(__requires__)', no line-err-info parse line: file-idx=2 line-idx=3 file=/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py line=620 text=in require get-real-file-name: file-name=/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py real-name=/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py parsed ' File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py", line 620, in require', got line-err-info parsed ' needed = self.resolve(parse_requirements(requirements))', no line-err-info parse line: file-idx=2 line-idx=3 file=/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py line=518 text=in resolve get-real-file-name: file-name=/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py real-name=/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py parsed ' File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py", line 518, in resolve', got line-err-info parsed ' raise DistributionNotFound(req) # XXX put more info here', no line-err-info parsed 'pkg_resources.DistributionNotFound: pylint==0.23.0', no line-err-info file /Users/schof/pytest.py, init=flymake-pylint-init process 3221 exited with code 1 cleaning up using flymake-simple-cleanup deleted file /Users/schof/pytest_flymake.py created an overlay at (1-18) pytest.py: 4 error(s), 0 warning(s) in 0.47 second(s)
For comparison, here it is derived from the bulk of flymake 3 when starting text mode from emacs. The "hello world" file has passed all pylint tests.
starting syntax check as new-line has been seen flymake is running: nil file /Users/schof/pytest.py, init=flymake-pylint-init [3 times] create-temp-inplace: file=/Users/schof/pytest.py temp=/Users/schof/pytest_flymake.py saved buffer pytest.py in file /Users/schof/pytest_flymake.py started process 3395, command=(epylint pytest_flymake.py), dir=/Users/schof/ file /Users/schof/pytest.py, init=flymake-pylint-init process 3395 exited with code 0 cleaning up using flymake-simple-cleanup deleted file /Users/schof/pytest_flymake.py pytest.py: 0 error(s), 0 warning(s) in 0.30 second(s)