views:

1838

answers:

2

There is any complete tutorial how to configure emacs for using with Django (1.1) (on Mac)? Im thinking about switch from TextMate to Emacs to have multiplatform editor for django. I have my fav. theme from textmate and I want to convert this to emacs (maybe is "converter" for this?). Switching from Textmate is a good idea ?

+3  A: 

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.

docgnome
+14  A: 

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.

Benjamin Pollack
I'd also recommend Emacs Starter Kit for anyone coming from a Mac background. It's a very sane set of defaults.
Singletoned