changeset 108:0d410d93d754

Merge.
author Augie Fackler <durin42@gmail.com>
date Thu, 11 Jun 2009 16:36:18 -0500
parents 16b57e1fc23d (diff) 9d09939f1100 (current diff)
children 8e04d9d41a55
files
diffstat 6 files changed, 199 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
new file mode 100644
--- /dev/null
+++ b/.elisp/django-html-mode.el
@@ -0,0 +1,155 @@
+;; This django-html-mode is mainly derived from html mode
+(require 'sgml-mode)
+
+(defvar django-html-mode-hook nil)
+
+(defvar django-html-mode-map
+  (let ((django-html-mode-map (make-keymap)))
+    (define-key django-html-mode-map "\C-j" 'newline-and-indent)
+    django-html-mode-map)
+  "Keymap for Django major mode")
+
+;; if : if, if not, if A or B, if not A or B, if not A and B
+;; for : for a in alist reversed
+  ;; forloop.counter    The current iteration of the loop (1-indexed)
+  ;; forloop.counter0   The current iteration of the loop (0-indexed)
+  ;; forloop.revcounter         The number of iterations from the end of the loop (1-indexed)
+  ;; forloop.revcounter0        The number of iterations from the end of the loop (0-indexed)
+  ;; forloop.first      True if this is the first time through the loop
+  ;; forloop.last       True if this is the last time through the loop
+  ;; forloop.parentloop         For nested loops, this is the loop "above" the current one
+
+;; ifequal : ifequal A B
+;; comment : {% This is comment %}
+;; filter : {{ name | lower }}
+
+;; keyword-end : if, for, ifequal, block, ifnotequal, spaceless
+;; keyword-3 : regroup
+;; keyword-2 : for, ifequal
+;; keyword-1 : if, block, extends, include, ifchanged, load, now, ssi, withratio
+;; keyword-0 : else, spaceless
+
+;; start and end keyword for block/comment/variable
+(defconst django-html-open-block     "{%")
+(defconst django-html-close-block    "%}")
+(defconst django-html-open-comment   "{#")
+(defconst django-html-close-comment  "#}")
+(defconst django-html-open-variable  "{{")
+(defconst django-html-close-variable "}}")
+
+(defconst django-html-font-lock-keywords-1
+  (append
+   ;; html-mode keyword
+   sgml-font-lock-keywords-1)
+
+  "First level keyword highlighting")
+
+(defconst django-html-font-lock-keywords-2
+  (append
+   django-html-font-lock-keywords-1
+   sgml-font-lock-keywords-2))
+
+(defconst django-html-font-lock-keywords-3
+  (append
+   django-html-font-lock-keywords-1
+   django-html-font-lock-keywords-2
+
+      `(;; comment
+     (,(rx (eval django-html-open-comment)
+           (1+ space)
+           (0+ (not (any "#")))
+           (1+ space)
+           (eval django-html-close-comment))
+      . font-lock-comment-face)
+
+     ;; variable font lock
+     (,(rx (eval django-html-open-variable)
+           (1+ space)
+           (group (0+ (not (any "}"))))
+           (1+ space)
+           (eval django-html-close-variable))
+      (1 font-lock-variable-name-face))
+
+     ;; start, end keyword font lock
+     (,(rx (group (or (eval django-html-open-block)
+                      (eval django-html-close-block)
+                      (eval django-html-open-comment)
+                      (eval django-html-close-comment)
+                      (eval django-html-open-variable)
+                      (eval django-html-close-variable))))
+      (1 font-lock-builtin-face))
+
+     ;; end prefix keyword font lock
+     (,(rx (eval django-html-open-block)
+           (1+ space)
+           (group (and "end"
+                        ;; end prefix keywords
+                       (or "if" "for" "ifequal" "block" "ifnotequal" "spaceless" "filter")))
+           (1+ space)
+           (eval django-html-close-block))
+      (1 font-lock-keyword-face))
+
+     ;; more words after keyword
+     (,(rx (eval django-html-open-block)
+           (1+ space)
+           (group (or "extends" "for" "cycle" "filter" "if not" "else"
+                      "firstof" "debug" "if" "ifchanged" "ifequal" "ifnotequal"
+                      "include" "load" "now" "regroup" "spaceless" "ssi"
+                      "templatetag" "widthratio" "block"))
+
+           ;; TODO: is there a more beautiful way?
+           (0+ (not (any "}")))
+
+           (1+ space)
+           (eval django-html-close-block))
+      (1 font-lock-keyword-face))
+
+     ;; TODO: if specific cases for supporting "or", "not", and "and"
+
+     ;; for sepcific cases for supporting in
+     (,(rx (eval django-html-open-block)
+           (1+ space)
+           "for"
+           (1+ space)
+
+           (group (1+ (or word ?_ ?.)))
+
+           (1+ space)
+           (group "in")
+           (1+ space)
+
+           (group (1+ (or word ?_ ?.)))
+
+           (group (? (1+ space) "reverse"))
+
+           (1+ space)
+           (eval django-html-close-block))
+      (1 font-lock-variable-name-face) (2 font-lock-keyword-face)
+      (3 font-lock-variable-name-face) (4 font-lock-keyword-face)))))
+
+(defvar django-html-font-lock-keywords
+  django-html-font-lock-keywords-1)
+
+(defvar django-html-mode-syntax-table
+  (let ((django-html-mode-syntax-table (make-syntax-table)))
+    django-html-mode-syntax-table)
+  "Syntax table for django-html-mode")
+
+;;;###autoload
+(define-derived-mode django-html-mode html-mode  "django-html"
+  "Major mode for editing django html files(.djhtml)"
+  :group 'django-html
+
+  ;; it mainly from sgml-mode font lock setting
+  (set (make-local-variable 'font-lock-defaults)
+       '((django-html-font-lock-keywords
+          django-html-font-lock-keywords-1
+          django-html-font-lock-keywords-2
+          django-html-font-lock-keywords-3)
+         nil t nil nil
+         (font-lock-syntactic-keywords
+          . sgml-font-lock-syntactic-keywords))))
+
+(add-to-list 'auto-mode-alist '("\\.djhtml$'" . django-html-mode))
+
+(provide 'django-html-mode)
--- a/.elisp/settings/40.modes.el
+++ b/.elisp/settings/40.modes.el
@@ -29,6 +29,10 @@ point."
                             (af-tab-fix)
                             (local-set-key "\C-m" 'newline-and-indent)))
 
+(require 'django-html-mode)
+;; I think I probably just always want it in django mode for now
+(add-to-list 'auto-mode-alist '("\\.html$'" . django-html-mode))
+
 (defun af-python-mode-hook ()
   ; highlight tabs in Python
   (make-variable-buffer-local 'font-lock-mode-hook)
@@ -46,14 +50,9 @@ point."
   (easy-menu-add-item nil '("Python") ["Debug One Test" nosetests-pdb-one t]
                       "Comment Out Region")
   (easy-menu-add-item nil '("Python") ["-" nil t] "Comment Out Region")
+  (local-set-key "\M-n" 'nosetests-module)
+  (local-set-key "\M-\C-n" 'nosetests-one)
 )
 (add-hook 'python-mode-hook 'af-python-mode-hook)
 
 (add-hook 'compilation-mode-hook '(lambda () (local-set-key "g" 'recompile)))
-
-
-; text-mode tries to use M-s for something other than my save shortcut.
-; That's evil. Stop it from doing that.
-(add-hook 'text-mode-hook '(lambda ()
-                             (define-key text-mode-map "\M-s"
-                               'save-buffer)))
--- a/.elisp/settings/50.preferences.el
+++ b/.elisp/settings/50.preferences.el
@@ -36,3 +36,16 @@
 
 ;; no toolbar
 (tool-bar-mode nil)
+
+;; Command is meta in OS X.
+(setq ns-command-modifier (quote meta))
+
+;; Don't popup new frames for opened files
+(setq ns-pop-up-frames nil)
+
+;; better uniquify from http://metapundit.net/sections/blog/emacs_and_django
+(require 'uniquify)
+(setq uniquify-buffer-name-style 'reverse)
+(setq uniquify-separator "/")
+(setq uniquify-after-kill-buffer-p t)
+(setq uniquify-ignore-buffers-re "^\\*")
--- a/.elisp/settings/90.keybindings.el
+++ b/.elisp/settings/90.keybindings.el
@@ -11,10 +11,32 @@
 (global-set-key "\C-h" 'backward-delete-char-untabify)
 ; M-t is what I want for the textmate file finding
 (global-set-key [(meta t)] 'textmate-goto-file)
-(global-set-key [(meta z)] 'textmate-find-in-project-type)
+(global-set-key [(meta control f)] 'textmate-find-in-project-type)
 (global-set-key [(meta m)] 'iconify-or-deiconify-frame)
 (global-set-key [(control backspace)] 'kill-word)
 
+;; M-j for jump to function definition
+(global-set-key [(meta j)] 'ido-imenu)
+
+;; commit emacs heresy?
+(global-set-key [(meta r)] 'execute-extended-command)
+
+;; Mac-like keybindings for undo/cut/copy/paste
+(global-set-key [(meta c)] 'kill-ring-save)
+(global-set-key [(meta x)] 'kill-region)
+(global-set-key [(meta z)] 'undo)
+(global-set-key [(meta v)] 'yank)
+(global-set-key [M-return] 'fullscreen)
+(global-set-key [(control v)] 'yank-pop)
+
+;; Fixup hooks for modes that like taking my keys back
+(add-hook 'text-mode-hook '(lambda ()
+                             (define-key text-mode-map "\M-s"
+                               'save-buffer)))
+(add-hook 'comint-mode-hook '(lambda ()
+                               (local-set-key "\M-r"
+                                              'execute-extended-command)))
+
 (defun server-save-buffer-and-finish ()
   (interactive)
   (save-buffer) (server-edit))
--- a/.hgignore
+++ b/.hgignore
@@ -1,5 +1,6 @@
 syntax:glob
 hgwebdir.conf
+.buildout
 *.pid
 *.pyc
 .*history
--- a/.python/startup.py
+++ b/.python/startup.py
@@ -31,5 +31,5 @@ try:
     import IPython
     def ipy():
         IPython.Shell.start().mainloop()
-except ImportError:
+except:
     pass