Changes between Version 17 and Version 18 of Emacs


Ignore:
Timestamp:
09/02/10 20:58:35 (5 years ago)
Author:
rogerhu
Comment:

See http://hustoknow.blogspot.com/2010/09/django-emacs-wiki.html

Legend:

Unmodified
Added
Removed
Modified
  • Emacs

    v17 v18  
    33This page lists some helpers to edit django templates with the Emacs editor.
    44
     5 * [http://code.djangoproject.com/wiki/Emacs#django-html-mumamo-mode nXhtml and django-html-mumamo-mode]
    56 * [http://code.djangoproject.com/wiki/Emacs#django-mode django-mode]
    67 * [http://code.djangoproject.com/wiki/Emacs#django-html-mode django-html-mode]
    7    * [http://code.djangoproject.com/wiki/Emacs#Improvedversion Improved version]
    8  * [http://code.djangoproject.com/wiki/Emacs#django-html-mumamo-mode nXhtml and django-html-mumamo-mode]
     8 * [http://code.djangoproject.com/wiki/Emacs#Improvedversion Improved version]
    99
    10 == django-mode ==
    11 
    12 [http://cavedoni.com/ I]’ve started hacking on an editing mode for Django templates in Emacs. (Please note that this is the first time I ever do Emacs Lisp, and that what I currently have is nothing more than a start. If you can come up with fixes or improvements, these are much appreciated).
    13 
    14 The most obvious benefit that it provides at the moment is syntax highlighting of  variables and blocks.
    15 
    16 It knows about the Django default tag names and uses a different coloring for comments. At the moment it is configured to automatically kick-in for files with extension `.djhtml` (I made it up that way, in order not to clash with other defaults one may have with .html files). Of course you can invoke it with `M-x django-mode` in any buffer.
    17 
    18 You can get it here: http://unicoders.org/code/hacks/trunk/django-mode.el
    19 
    20 Put it somewhere where Emacs can find it then add this line to your `.emacs` file:
    21 
    22 {{{
    23 (load "django-mode.el")
    24 }}}
    25 
    26 This is a sample screenshot of the results with the “Charcoal Black” [http://www.emacswiki.org/cgi-bin/wiki?ColorTheme color theme]:
    27 
    28 {{{
    29 #!html
    30 <img src="http://code.djangoproject.com/attachment/wiki/Emacs/emacs-django-template.png?format=raw" alt="Screenshot of Django template in GNU Emacs, Mac OS X">
    31 }}}
    32 
    33 == django-html-mode ==
    34 
    35 There is another emacs django templete mode. It is derived mode from html(sgml).
    36 
    37  * Elisp Code(.html)
    38    [http://tsgates.cafe24.com/wp-content/uploads/2007/01/django-html-mode1.html]
    39  * Download(.el)
    40    [http://tsgates.cafe24.com/elisp/django-html-mode.el]
    41  * Example(.html)
    42    [http://tsgates.cafe24.com/wp-content/uploads/2007/01/django-html-mode-ex.html]
    43 
    44 {{{
    45 #!html
    46 <img src="http://tsgates.cafe24.com/elisp/404.JPG" alt="Screenshot of Django template in GNU Emacs, Windows">
    47 }}}
    48 
    49 === Improved version ===
    50 
    51 There is an updated and improved version of this mode on: [https://code.edge.launchpad.net/~eopadoan/+junk/django-html-mode]
    52  * '''Updated the supported tags''' to current (django 1.0b3).
    53  * Added '''auto-close''' command ( {{{C-c ]}}} ).
    54 
    55 To get, run on a shell:
    56 {{{
    57 bzr branch lp:~eopadoan/+junk/django-html-mode
    58 }}}
    59 
    60 == django-html-mumamo-mode ==
     10== django-html-mumamo-mode == (works well)
    6111
    6212MUltiple MAjor MOde is an extension for Emacs that allows one buffer to use multiple modes for different stretches of text. It's bundled with [http://ourcomments.org/Emacs/nXhtml/doc/nxhtml.html nXhtml], and now includes a django-html-mumamo-mode for Django templates.
     
    7020
    7121
    72 To get nXhtml (includes django-html-mumamo-mode), run on a shell:
     22To get nXHTML (includes django-html-mumamo-mode), download the nxHTML package release directly from the web site at: http://ourcomments.org/Emacs/DL/elisp/nxhtml/zip/nxhtml-2.08-100425.zip
     23
     24Downloading it from the Launchpad branch site will give you the latest snapshot, but there may be issues with the latest build so it is not recommend.
     25
     26And append:
    7327{{{
    74 bzr branch lp:nxhtml
     28(load "~/.emacs.d/nxhtml/autostart.el")
     29(setq mumamo-background-colors nil)
     30(add-to-list 'auto-mode-alist '("\\.html$" . django-html-mumamo-mode))
    7531}}}
    76 And append something like that:
    77 {{{
    78 (load "~/.emacs.d/vendor/nxhtml/autostart.el")
    79 }}}
    80 to your .emacs.
     32to your .emacs.  See the issue reported at http://stackoverflow.com/questions/1146701/turning-off-chunk-coloring-in-emacs-nxhtml-mode to understand why the setq statement is needed.  The add-to-list line is used to force any HTML file loaded into django-html-mumamo-mode.
    8133
    8234To use django-html-mumamo-mode run:
     
    9951To get, run on a shell:
    10052{{{
     53cd /tmp
     54mkdir ~/.emacs/plugins
     55
     56bzr branch lp:python-mode
    10157bzr branch lp:django-mode
     58
     59mv /tmp/python-mode/python-mode.el ~/.emacs.d
     60mv /tmp/django-mode/*.el ~/.emacs.d
     61mv /tmp/django-mode/snippets ~/.emacs.d/plugins
    10262}}}
    103 And append something like that:
     63And append something like:
    10464{{{
    105 (load "~/Dropbox/django-mode/django-mode.el")
    106 (yas/load-directory "~/Dropbox/django-mode/snippets")
     65(add-to-list 'load-path "~/.emacs.d/plugins/yasnippet-0.6.1c")
     66(require 'yasnippet)
     67(yas/initialize)
     68(yas/load-directory "~/.emacs.d/plugins/yasnippet-0.6.1c/snippets")
     69(require 'django-html-mode)
     70(require 'django-mode)
     71(yas/load-directory "~/.emacs.d/plugins/django-mode/snippets")
    10772}}}
    10873to your .emacs.
     74
     75The django-mode yasnippets code depend on python-mode.el, so it also has to be downloaded.  Note: there is a difference between python.el (which comes with the native Emacs distribution) and python-mode.el, which has to be downloaded separately.
     76
     77Also, if you use django-html-mumamo-mode, you should not use Ysnippet since the automatic template tag indenting will not function correctly with the Ysnippet django-html-mode and django-mode code loaded.
     78
     79== django-mode == (OLD -- download link does not work)
     80
     81[http://cavedoni.com/ I]’ve started hacking on an editing mode for Django templates in Emacs. (Please note that this is the first time I ever do Emacs Lisp, and that what I currently have is nothing more than a start. If you can come up with fixes or improvements, these are much appreciated).
     82
     83The most obvious benefit that it provides at the moment is syntax highlighting of variables and blocks.
     84
     85It knows about the Django default tag names and uses a different coloring for comments. At the moment it is configured to automatically kick-in for files with extension `.djhtml` (I made it up that way, in order not to clash with other defaults one may have with .html files). Of course you can invoke it with `M-x django-mode` in any buffer.
     86
     87You can get it here: http://unicoders.org/code/hacks/trunk/django-mode.el (link dead)
     88
     89Put it somewhere where Emacs can find it then add this line to your `.emacs` file:
     90
     91{{{
     92(load "django-mode.el")
     93}}}
     94
     95This is a sample screenshot of the results with the “Charcoal Black” [http://www.emacswiki.org/cgi-bin/wiki?ColorTheme color theme]:
     96
     97{{{
     98#!html
     99<img src="http://code.djangoproject.com/attachment/wiki/Emacs/emacs-django-template.png?format=raw" alt="Screenshot of Django template in GNU Emacs, Mac OS X">
     100}}}
     101
     102== django-html-mode ==
     103
     104There is another emacs django templete mode. It is derived mode from html(sgml).
     105
     106=== Improved version ===
     107
     108There is an updated and improved version of this mode on: [https://code.edge.launchpad.net/~eopadoan/+junk/django-html-mode]
     109 * '''Updated the supported tags''' to current (django 1.0b3).
     110 * Added '''auto-close''' command ( {{{C-c ]}}} ).
     111
     112To get, run on a shell:
     113{{{
     114bzr branch lp:~eopadoan/+junk/django-html-mode
     115}}}
     116
     117Note: The django-html-mode code does not appear to support template tag indentation.
Back to Top