Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django + Emacs (as TextMate replacement)

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 ?

like image 554
Andrzej Śliwa Avatar asked Aug 10 '09 21:08

Andrzej Śliwa


2 Answers

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.

like image 87
Benjamin Pollack Avatar answered Nov 08 '22 06:11

Benjamin Pollack


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.

like image 4
baudtack Avatar answered Nov 08 '22 07:11

baudtack