[Fixed]-Django + Emacs (as TextMate replacement)

29👍

I second @docgnome’s suggestion of Django mode and yasnippet, but the real kicker that will make you never want to go back to TextMate is to integrate PyFlakes into your development environment, at which point Emacs will provide you on-the-fly notification of errors in your Python code. These go far beyond the typo-level error detection you get for free merely by having syntax highlighting; you’ll be notified of errors such as variable before assignment, unused imports, and bad indentation, among other things.

Installing PyFlakes in Emacs is relatively straightforward: just download and install PyFlakes, and then add the following to your ~/.emacs or ~/.emacs.d/init.el, as appropriate:

(when (load "flymake" t) 
  (defun flymake-pyflakes-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 "pyflakes" (list local-file)))) 
  (add-to-list 'flymake-allowed-file-name-masks 
               '("\\.py\\'" flymake-pyflakes-init)))
(add-hook 'python-mode-hook 'flymake-mode)

That’s it. You should now notice that, whenever you’re editing Python, errors are highlighted in red. Mouse over to see a full explanation of what’s wrong with the provided line.

As far as theming like TextMate: theming can be a bit annoying Emacs; unless you truly want the exact theme you have in TextMate, I’d grab Color Theme for Emacs and find one that suits your fancy. You can almost certainly find one very close to your current TextMate one, and won’t have to deal with manually configuring faces.

4👍

You might check out Django mode for emacs. What specific functionality were you looking for? For snippets, I recommend yasnippet which is inspired by the TextMate snippet system.

Leave a comment