Flymake is a generic syntax checker for Emacs. Its combination with PyFlakes which is a syntax checker for python makes it a perfect setting for Python programming in Emacs. Here are the steps to make it to work:
- Install PyFlakes:
- If you have python setuptools installed, just try [sourcecode language=”text”]sudo easy_install pyflakes[/sourcecode]
- If you could not use the setuptools, you can also try using your distributions repositories. For Ubuntu/Debian you can try [sourcecode language=”text”]sudo apt-get install pyflakes[/sourcecode]
- Install Flymake:
- If you are using Emacs 23+, it is already included in your installation, follow to the next step.
- You can download it from here, and put it to your emacs directory under your home (usually, “~/.emacs.d” directory).
- Copy the following to your “init.el” file, which is again located under your Emacs folder (e.g. “~/.emacs.d/init.el”):
;; code checking via pyflakes+flymake
(when (load “flymake” t)
(defun flymake-pyflakes-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
(list “pyflakes” (list local-file))))
(add-hook ‘find-file-hook ‘flymake-find-file-hook)
If everything works as planned, when you open a Python file, you should see the “Flymake” minor mode displayed, and it should report if you have syntax errors, or any warnings regarding your code.