<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -23,6 +23,8 @@
 (autoload 'scala-mode &quot;scala-mode-auto&quot; nil t)
 (add-to-list 'auto-mode-alist '(&quot;\\.scala&quot; . scala-mode))
 
+(setq default-tab-width 2)
+
 (server-start)
 
 (add-to-list 'load-path (expand-file-name &quot;~/.emacs.d/cnixon/yasnippet&quot;))</diff>
      <filename>cnixon.el</filename>
    </modified>
    <modified>
      <diff>@@ -21,6 +21,7 @@
 ;;; Code:
 
 (eval-when-compile (require 'cl))
+(require 'ruby-mode)
 
 ;; User definable variables
 
@@ -54,13 +55,16 @@ line itself.&quot;
   :group 'haml)
 
 (defvar haml-indent-function 'haml-indent-p
-  &quot;This function should look at the current line and return true
-if the next line could be nested within this line.&quot;)
+  &quot;This function should look at the current line and return t
+if the next line could be nested within this line.
+
+The function can also return a positive integer to indicate
+a specific level to which the current line could be indented.&quot;)
 
 (defvar haml-block-openers
-  `(&quot;^ *\\([%\\.#][^ \t]*\\)\\(\\[.*\\]\\)?\\({.*}\\)?\\(\\[.*\\]\\)?[ \t]*$&quot;
-    &quot;^ *[-=].*do[ \t]*\\(|.*|[ \t]*\\)?$&quot;
-    ,(concat &quot;^ *-[ \t]*\\(&quot;
+  `(&quot;^ *\\([%\\.#][a-z0-9_:\\-]*\\)+\\({.*}\\)?\\(\\[.*\\]\\)?[&gt;&lt;]*[ \t]*$&quot;
+    &quot;^ *[&amp;!]?[-=~].*do[ \t]*\\(|.*|[ \t]*\\)?$&quot;
+    ,(concat &quot;^ *[&amp;!]?[-=~][ \t]*\\(&quot;
              (regexp-opt '(&quot;if&quot; &quot;unless&quot; &quot;while&quot; &quot;until&quot; &quot;else&quot;
                            &quot;begin&quot; &quot;elsif&quot; &quot;rescue&quot; &quot;ensure&quot; &quot;when&quot;))
              &quot;\\)&quot;)
@@ -73,40 +77,127 @@ text nested beneath them.&quot;)
 ;; Font lock
 
 (defun haml-nested-regexp (re)
-  (concat &quot;^\\( *\\)&quot; re &quot;\n\\(?:\\(?:\\1 .*\\| *\\)\n\\)*&quot;))
+  (concat &quot;^\\( *\\)&quot; re &quot;\\(\n\\(?:\\(?:\\1 .*\\| *\\)\n\\)*\\(?:\\1 .*\\| *\\)?\\)?&quot;))
 
 (defconst haml-font-lock-keywords
-  `((,(haml-nested-regexp &quot;-#.*&quot;)  0 font-lock-comment-face)
+  `((,(haml-nested-regexp &quot;\\(?:-#\\|/\\).*&quot;)  0 font-lock-comment-face)
     (,(haml-nested-regexp &quot;:\\w+&quot;) 0 font-lock-string-face)
-    (&quot;^ *\\(\t\\)&quot;               1 'haml-tab-face)
-    (&quot;^!!!.*&quot;                    0 font-lock-constant-face)
-    (&quot;\\('[^']*'\\)&quot;             1 font-lock-string-face append)
-    (&quot;\\(\&quot;[^\&quot;]*\&quot;\\)&quot;          1 font-lock-string-face append)
-    (&quot;@[a-z0-9_]+&quot;               0 font-lock-variable-name-face append)
-    (&quot;| *$&quot;                      0 font-lock-string-face)
-    (&quot;^[ \t]*\\(/.*\\)$&quot;         1 font-lock-comment-face append)
-    (&quot;^ *\\(#[a-z0-9_]+\/?\\)&quot;   1 font-lock-keyword-face)
-    (&quot;^ *\\(\\.[a-z0-9_]+\/?\\)&quot; 1 font-lock-type-face)
-    (&quot;^ *\\(%[a-z0-9_]+\/?\\)&quot;   1 font-lock-function-name-face)
-    (&quot;^ *\\(#[a-z0-9_]+\/?\\)&quot;   (1 font-lock-keyword-face)
-     (&quot;\\.[a-z0-9_]+&quot; nil nil    (0 font-lock-type-face)))
-    (&quot;^ *\\(\\.[a-z0-9_]+\/?\\)&quot; (1 font-lock-type-face)
-     (&quot;\\.[a-z0-9_]+&quot; nil nil    (0 font-lock-type-face)))
-    (&quot;^ *\\(\\.[a-z0-9_]+\/?\\)&quot; (1 font-lock-type-face)
-     (&quot;\\#[a-z0-9_]+&quot; nil nil    (0 font-lock-keyword-face)))
-    (&quot;^ *\\(%[a-z0-9_]+\/?\\)&quot;   (1 font-lock-function-name-face)
-     (&quot;\\.[a-z0-9_]+&quot; nil nil    (0 font-lock-type-face)))
-    (&quot;^ *\\(%[a-z0-9_]+\/?\\)&quot;   (1 font-lock-function-name-face)
-     (&quot;\\#[a-z0-9_]+&quot; nil nil    (0 font-lock-keyword-face)))
-    (&quot;^ *\\([~=-] .*\\)&quot;         1 font-lock-preprocessor-face prepend)
-    (&quot;^ *[\\.#%a-z0-9_]+\\([~=-] .*\\)&quot;     1 font-lock-preprocessor-face prepend)
-    (&quot;^ *[\\.#%a-z0-9_]+\\({[^}]+}\\)&quot;      1 font-lock-preprocessor-face prepend)
-    (&quot;^ *[\\.#%a-z0-9_]+\\(\\[[^]]+\\]\\)&quot;  1 font-lock-preprocessor-face prepend)))
-
-(defconst haml-filter-re &quot;^ *\\(:\\)\\w+&quot;)
-(defconst haml-comment-re &quot;^ *\\(-\\)\\#&quot;)
-
-(defun* haml-extend-region ()
+    (haml-highlight-interpolation  1 font-lock-variable-name-face prepend)
+    (haml-highlight-ruby-tag       1 font-lock-preprocessor-face)
+    (haml-highlight-ruby-script    1 font-lock-preprocessor-face)
+    (&quot;^ *\\(\t\\)&quot;                 1 'haml-tab-face)
+    (&quot;^!!!.*&quot;                      0 font-lock-constant-face)
+    (&quot;| *$&quot;                        0 font-lock-string-face)))
+
+(defconst haml-filter-re &quot;^ *:\\w+&quot;)
+(defconst haml-comment-re &quot;^ *\\(?:-\\#\\|/\\)&quot;)
+
+(defun haml-fontify-region-as-ruby (beg end)
+  &quot;Use Ruby's font-lock variables to fontify the region between BEG and END.&quot;
+  (save-excursion
+    (save-match-data
+      (let ((font-lock-keywords ruby-font-lock-keywords)
+            (font-lock-syntactic-keywords ruby-font-lock-syntactic-keywords)
+            font-lock-keywords-only
+            font-lock-extend-region-functions
+            font-lock-keywords-case-fold-search)
+        ;; font-lock-fontify-region apparently isn't inclusive,
+        ;; so we have to move the beginning back one char
+        (font-lock-fontify-region (- beg 1) end)))))
+
+(defun haml-highlight-ruby-script (limit)
+  &quot;Highlight a Ruby script expression (-, =, or ~).&quot;
+  (when (re-search-forward &quot;^ *\\(-\\|[&amp;!]?[=~]\\) \\(.*\\)$&quot; limit t)
+    (haml-fontify-region-as-ruby (match-beginning 2) (match-end 2))))
+
+(defun haml-highlight-ruby-tag (limit)
+  &quot;Highlight Ruby code within a Haml tag.
+
+This highlights the tag attributes and object refs of the tag,
+as well as the script expression (-, =, or ~) following the tag.
+
+For example, this will highlight all of the following:
+  %p{:foo =&gt; 'bar'}
+  %p[@bar]
+  %p= 'baz'
+  %p{:foo =&gt; 'bar'}[@bar]= 'baz'&quot;
+  (when (re-search-forward &quot;^ *[%.#]&quot; limit t)
+    (let ((eol (save-excursion (end-of-line) (point))))
+      (forward-char -1)
+
+      ;; Highlight tag, classes, and ids
+      (while (looking-at &quot;[.#%][a-z0-9_:\\-]*&quot;)
+        (put-text-property (match-beginning 0) (match-end 0) 'face
+                           (case (char-after)
+                             (?% font-lock-function-name-face)
+                             (?# font-lock-keyword-face)
+                             (?. font-lock-type-face)))
+        (goto-char (match-end 0)))
+
+      ;; Highlight obj refs
+      (when (eq (char-after) ?\[)
+        (let ((beg (point)))
+          (haml-limited-forward-sexp eol)
+          (haml-fontify-region-as-ruby beg (point))))
+
+      ;; Highlight attr hashes
+      (when (eq (char-after) ?\{)
+        (let ((beg (point)))
+          (haml-limited-forward-sexp eol)
+
+          ;; Check for multiline
+          (while (and (eolp) (eq (char-before) ?,) (not (eobp)))
+            (forward-line)
+            (let ((eol (save-excursion (end-of-line) (point))))
+              ;; If no sexps are closed,
+              ;; we're still continuing a  multiline hash
+              (if (&gt;= (car (parse-partial-sexp (point) eol)) 0)
+                  (end-of-line)
+                ;; If sexps have been closed,
+                ;; set the point at the end of the total sexp
+                (goto-char beg)
+                (haml-limited-forward-sexp eol))))
+
+          (haml-fontify-region-as-ruby (+ 1 beg) (point))))
+
+      ;; Move past end chars
+      (when (looking-at &quot;[&lt;&gt;&amp;!]+&quot;) (goto-char (match-end 0)))
+      ;; Highlight script
+      (if (looking-at &quot;\\([=~]\\) \\(.*\\)$&quot;)
+          (haml-fontify-region-as-ruby (match-beginning 2) (match-end 2))
+        ;; Give font-lock something to highlight
+        (forward-char -1)
+        (looking-at &quot;\\(\\)&quot;))
+      t)))
+
+(defun haml-highlight-interpolation (limit)
+  &quot;Highlight Ruby interpolation (#{foo}).&quot;
+  (when (re-search-forward &quot;\\(#{\\)&quot; limit t)
+    (save-match-data
+      (forward-char -1)
+      (let ((beg (point)))
+        (haml-limited-forward-sexp limit)
+        (haml-fontify-region-as-ruby (+ 1 beg) (point)))
+
+      (when (eq (char-before) ?})
+        (put-text-property (- (point) 1) (point)
+                           'face font-lock-variable-name-face))
+      t)))
+
+(defun haml-limited-forward-sexp (limit &amp;optional arg)
+  &quot;Move forward using `forward-sexp' or to limit,
+whichever comes first.&quot;
+  (let (forward-sexp-function)
+    (condition-case err
+        (save-restriction
+          (narrow-to-region (point) limit)
+          (forward-sexp arg))
+      (scan-error
+       (unless (equal (nth 1 err) &quot;Unbalanced parentheses&quot;)
+         (signal 'scan-error (cdr err)))
+       (goto-char limit)))))
+
+(defun* haml-extend-region-filters-comments ()
   &quot;Extend the font-lock region to encompass filters and comments.&quot;
   (let ((old-beg font-lock-beg)
         (old-end font-lock-end))
@@ -115,7 +206,7 @@ text nested beneath them.&quot;)
       (beginning-of-line)
       (unless (or (looking-at haml-filter-re)
                   (looking-at haml-comment-re))
-        (return-from haml-extend-region))
+        (return-from haml-extend-region-filters-comments))
       (setq font-lock-beg (point))
       (haml-forward-sexp)
       (beginning-of-line)
@@ -123,6 +214,38 @@ text nested beneath them.&quot;)
     (or (/= old-beg font-lock-beg)
         (/= old-end font-lock-end))))
 
+(defun* haml-extend-region-multiline-hashes ()
+  &quot;Extend the font-lock region to encompass multiline attribute hashes.&quot;
+  (let ((old-beg font-lock-beg)
+        (old-end font-lock-end))
+    (save-excursion
+      (goto-char font-lock-beg)
+      (let ((attr-props (haml-parse-multiline-attr-hash))
+            multiline-end)
+        (when attr-props
+          (setq font-lock-beg (cdr (assq 'point attr-props)))
+
+          (end-of-line)
+          ;; Move through multiline attrs
+          (when (eq (char-before) ?,)
+            (save-excursion
+              (while (progn (end-of-line) (eq (char-before) ?,) (not (eobp)))
+                (forward-line))
+
+              (forward-line -1)
+              (end-of-line)
+              (setq multiline-end (point))))
+
+          (goto-char (+ (cdr (assq 'point attr-props))
+                        (cdr (assq 'hash-indent attr-props))
+                        -1))
+          (haml-limited-forward-sexp
+           (or multiline-end
+               (save-excursion (end-of-line) (point))))
+          (setq font-lock-end (max font-lock-end (point))))))
+    (or (/= old-beg font-lock-beg)
+        (/= old-end font-lock-end))))
+
 
 ;; Mode setup
 
@@ -152,14 +275,15 @@ text nested beneath them.&quot;)
 
 \\{haml-mode-map}&quot;
   (set-syntax-table haml-mode-syntax-table)
-  (add-to-list 'font-lock-extend-region-functions 'haml-extend-region)
+  (add-to-list 'font-lock-extend-region-functions 'haml-extend-region-filters-comments)
+  (add-to-list 'font-lock-extend-region-functions 'haml-extend-region-multiline-hashes)
   (set (make-local-variable 'font-lock-multiline) t)
   (set (make-local-variable 'indent-line-function) 'haml-indent-line)
   (set (make-local-variable 'indent-region-function) 'haml-indent-region)
   (set (make-local-variable 'parse-sexp-lookup-properties) t)
   (setq comment-start &quot;-#&quot;)
   (setq indent-tabs-mode nil)
-  (setq font-lock-defaults '((haml-font-lock-keywords) nil t)))
+  (setq font-lock-defaults '((haml-font-lock-keywords) t t)))
 
 ;; Useful functions
 
@@ -313,21 +437,60 @@ character of the next line.&quot;
 
 ;; Indentation and electric keys
 
-(defun haml-indent-p ()
-  &quot;Returns true if the current line can have lines nested beneath it.&quot;
+(defun* haml-indent-p ()
+  &quot;Returns t if the current line can have lines nested beneath it.&quot;
+  (let ((attr-props (haml-parse-multiline-attr-hash)))
+    (when attr-props
+      (end-of-line)
+      (return-from haml-indent-p
+        (if (eq (char-before) ?,) (cdr (assq 'hash-indent attr-props))
+          (beginning-of-line)
+          (list (+ (cdr (assq 'indent attr-props)) haml-indent-offset) nil)))))
   (loop for opener in haml-block-openers
         if (looking-at opener) return t
         finally return nil))
 
+(defun* haml-parse-multiline-attr-hash ()
+  &quot;Parses a multiline attribute hash, and returns
+an alist with the following keys:
+
+INDENT is the indentation of the line beginning the hash.
+
+HASH-INDENT is the indentation of the first character
+within the attribute hash.
+
+POINT is the character position at the beginning of the line
+beginning the hash.&quot;
+  (save-excursion
+    (while t
+      (beginning-of-line)
+      (if (looking-at &quot;^ *\\(?:[.#%][a-z0-9_:\\-]+\\)+{&quot;)
+          (progn
+            (goto-char (- (match-end 0) 1))
+            (haml-limited-forward-sexp (save-excursion (end-of-line) (point)))
+            (return-from haml-parse-multiline-attr-hash
+              (if (eq (char-before) ?,)
+                  `((indent . ,(current-indentation))
+                    (hash-indent . ,(- (match-end 0) (match-beginning 0)))
+                    (point . ,(match-beginning 0)))
+                nil)))
+        (forward-line -1)
+        (end-of-line)
+        (when (not (eq (char-before) ?,))
+          (return-from haml-parse-multiline-attr-hash nil))))))
+
 (defun haml-compute-indentation ()
   &quot;Calculate the maximum sensible indentation for the current line.&quot;
   (save-excursion
     (beginning-of-line)
-    (if (bobp) 0
+    (if (bobp) (list 0 nil)
       (haml-forward-through-whitespace t)
-      (+ (current-indentation)
-         (if (funcall haml-indent-function) haml-indent-offset
-           0)))))
+      (let ((indent (funcall haml-indent-function)))
+        (cond
+         ((consp indent) indent)
+         ((integerp indent) (list indent t))
+         (indent (list (+ (current-indentation) haml-indent-offset) nil))
+         (t (list (current-indentation) nil)))))))
 
 (defun haml-indent-region (start end)
   &quot;Indent each nonblank line in the region.
@@ -345,7 +508,7 @@ between possible indentations.&quot;
           (next-line-column
            (if (and (equal last-command this-command) (/= (current-indentation) 0))
                (* (/ (- (current-indentation) 1) haml-indent-offset) haml-indent-offset)
-             (haml-compute-indentation))))
+             (car (haml-compute-indentation)))))
       (while (&lt; (point) end)
         (setq this-line-column next-line-column
               current-column (current-indentation))
@@ -368,20 +531,18 @@ The first time this command is used, the line will be indented to the
 maximum sensible indentation.  Each immediately subsequent usage will
 back-dent the line by `haml-indent-offset' spaces.  On reaching column
 0, it will cycle back to the maximum sensible indentation.&quot;
-  ;; TODO: pressing tab to bring the point to the first non-whitespace
-  ;; char marks the buffer as modified even though it doesn't change anything
   (interactive &quot;*&quot;)
   (let ((ci (current-indentation))
-        (cc (current-column))
-        (need (haml-compute-indentation)))
-    (save-excursion
-      (beginning-of-line)
-      (delete-horizontal-space)
-      (if (and (equal last-command this-command) (/= ci 0))
-          (indent-to (* (/ (- ci 1) haml-indent-offset) haml-indent-offset))
-        (indent-to need)))
-      (if (&lt; (current-column) (current-indentation))
-          (forward-to-indentation 0))))
+        (cc (current-column)))
+    (destructuring-bind (need strict) (haml-compute-indentation)
+      (save-excursion
+        (beginning-of-line)
+        (delete-horizontal-space)
+        (if (and (not strict) (equal last-command this-command) (/= ci 0))
+            (indent-to (* (/ (- ci 1) haml-indent-offset) haml-indent-offset))
+          (indent-to need))))
+    (when (&lt; (current-column) (current-indentation))
+      (forward-to-indentation 0))))
 
 (defun haml-reindent-region-by (n)
   &quot;Add N spaces to the beginning of each line in the region.</diff>
      <filename>elpa-to-submit/haml-mode.el</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>54a23a562df5058f94fbebb2c7d1acff93c674a8</id>
    </parent>
  </parents>
  <author>
    <name>Clinton R. Nixon</name>
    <email>crnixon@gmail.com</email>
  </author>
  <url>http://github.com/crnixon/emacs-starter-kit/commit/16508722d829f3481f231e7e45aed3e336ad4c39</url>
  <id>16508722d829f3481f231e7e45aed3e336ad4c39</id>
  <committed-date>2009-07-04T10:30:31-07:00</committed-date>
  <authored-date>2009-07-04T10:30:31-07:00</authored-date>
  <message>replaced haml-mode with new version</message>
  <tree>d538a39be3c59a408ac5478acd8b40d65e21de09</tree>
  <committer>
    <name>Clinton R. Nixon</name>
    <email>crnixon@gmail.com</email>
  </committer>
</commit>
