extra/haml-mode.el in haml-edge-2.1.12 vs extra/haml-mode.el in haml-edge-2.1.13

- old
+ new

@@ -140,15 +140,15 @@ (haml-limited-forward-sexp eol) (haml-fontify-region-as-ruby beg (point)))) ;; Highlight attr hashes (when (eq (char-after) ?\{) - (let ((beg (+ 1 (point)))) + (let ((beg (point))) (haml-limited-forward-sexp eol) ;; Check for multiline - (while (and (eolp) (eq (char-before) ?,)) + (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 (>= (car (parse-partial-sexp (point) eol)) 0) @@ -156,11 +156,11 @@ ;; 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 beg (point)))) + (haml-fontify-region-as-ruby (+ 1 beg) (point)))) ;; Move past end chars (when (looking-at "[<>&!]+") (goto-char (match-end 0))) ;; Highlight script (if (looking-at "\\([=~]\\) \\(.*\\)$") @@ -227,11 +227,11 @@ (end-of-line) ;; Move through multiline attrs (when (eq (char-before) ?,) (save-excursion - (while (progn (end-of-line) (eq (char-before) ?,)) + (while (progn (end-of-line) (eq (char-before) ?,) (not (eobp))) (forward-line)) (forward-line -1) (end-of-line) (setq multiline-end (point)))) @@ -443,11 +443,11 @@ (when attr-props (end-of-line) (return-from haml-indent-p (if (eq (char-before) ?,) (cdr (assq 'hash-indent attr-props)) (beginning-of-line) - (+ (cdr (assq 'indent attr-props)) haml-indent-offset))))) + (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 () @@ -481,17 +481,18 @@ (defun haml-compute-indentation () "Calculate the maximum sensible indentation for the current line." (save-excursion (beginning-of-line) - (if (bobp) 0 + (if (bobp) (list 0 nil) (haml-forward-through-whitespace t) (let ((indent (funcall haml-indent-function))) (cond - ((integerp indent) indent) - (indent (+ (current-indentation) haml-indent-offset)) - (t (current-indentation))))))) + ((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) "Indent each nonblank line in the region. This is done by indenting the first line based on `haml-compute-indentation' and preserving the relative @@ -505,11 +506,11 @@ (goto-char start) (let (this-line-column current-column (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 (< (point) end) (setq this-line-column next-line-column current-column (current-indentation)) ;; Delete whitespace chars at beginning of line (delete-horizontal-space) @@ -530,19 +531,19 @@ 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." (interactive "*") (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 (< (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 (< (current-column) (current-indentation)) + (forward-to-indentation 0)))) (defun haml-reindent-region-by (n) "Add N spaces to the beginning of each line in the region. If N is negative, will remove the spaces instead. Assumes all lines in the region have indentation >= that of the first line."