PyFlakes-Flymake for Python Programming in Emacs

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:

1) Install PyFlakes:

  • If you have python setuptools installed, just try
    sudo easy_install pyflakes
  • If you could not use the setuptools, you can also try using your distributions repositories. For Ubuntu/Debian you can try
    sudo apt-get install pyflakes

2) 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).

3) Copy the following to your “init.el” file, which is again located under your Emacs folder (e.g. “~/.emacs.d/init.el”):

;;===== PyFlakes
;; code checking via pyflakes+flymake
(when (load "flymake" t)
 (defun flymake-pyflakes-init ()
 (let* ((temp-file (flymake-init-create-temp-buffer-copy
 (local-file (file-relative-name
 (file-name-directory buffer-file-name))))
 (list "pyflakes" (list local-file))))

 (add-to-list 'flymake-allowed-file-name-masks
 '("\\.py\\'" flymake-pyflakes-init)))

(add-hook 'find-file-hook 'flymake-find-file-hook)

Continue reading PyFlakes-Flymake for Python Programming in Emacs