3 ms·
Ask HN: How do I customize code coloring in emacs?
I program Django/Python in emacs, and I would like things like {% comment %} FOO {% endcomment %} to turn orange.
How can I set up some colors for important Django template tags?
If you can give me a bit of example code, that would be great. A link to an example of this would be great too.
- travisjeffery 17y agohttp://lmgtfy.com/?q=django+emacs http://lmgtfy.com/?q=django+emacs To change the color of a specific face in emacs, go to the face and do M-x set-face-foreground Return and put the color you want.
- pookleblinky 17y agodownvoted because he probably expected suggestions about which mode is best, etc. rather than snark
- realrbman 17y agoEmacs Django mode http://code.djangoproject.com/wiki/Emacs http://code.djangoproject.com/wiki/Emacs
- spydez 17y agoDownload color-theme. http://www.emacswiki.org/cgi-bin/wiki?ColorTheme http://www.emacswiki.org/cgi-bin/wiki?ColorTheme Choose one of the included themes that you like the most, and start customizing. Personally, I like zenburn. http://www.brockman.se/software/zenburn/zenburn.el http://www.brockman.se/software/zenburn/zenburn.el But that might be a bit heavy to start off with. Or, the shortcut way, define some stuff in custom-set-faces. e.g.: (custom-set-faces ;; custom-set-faces was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. '(paren-face-match-light ((t (:background "#5f5f5f" :foreground "#e37170" :weight ultra-bold)))) '(paren-face-match ((t (:background "#5f5f5f" :foreground "#e37170" :weight ultra-bold)))) '(paren-face-mismatch ((((class color)) (:background "#332323" :foreground "#e37170")))) '(paren-face-no-match ((((class color)) (:background "#332323" :foreground "#e37170")))) '(linum ((t (:foreground "#5f5f5f"))))) Of course, this all requires that your Django/Python mode has a face for the {% ... %} stuff. I've never done any Django work, so I'm not sure if it does. If it doesn't, you'll have to hack at the Django/Python mode some to define that face so you can color it.
- daleharvey 17y ago(color-theme-midnight) is my preference
- andrewljohnson 17y agoThanks for the note. I use nice faces for my JS, Python, HTML, and CSS. I just wasn't sure how to go about customizing. I got this snippet, and I think I can take it from here: (defun django-highlight-comments () (interactive "p") (highlight-regexp "{%.*?%}" 'hi-orange)) (add-hook 'html-mode-hook 'django-highlight-comments)
- jaaron 17y agoI like the Tango Theme: http://www.emacswiki.org/emacs/color-theme-tango.el http://www.emacswiki.org/emacs/color-theme-tango.el
- capablanca 17y agoinstead of using a hack like highlight-regexp, perhaps it'd be better to place a bug or hack the mode itself :)