Created
March 5, 2009 05:47
-
-
Save nex3/74218 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun haml-mumamo-chunk (pos min max) | |
(mumamo-find-possible-chunk pos min max | |
'haml-mumamo-bw-exc-start-fun | |
'haml-mumamo-bw-exc-end-fun | |
'haml-mumamo-fw-exc-start-fun | |
'haml-mumamo-fw-exc-end-fun)) | |
(defun* haml-mumamo-exc-start-fun (pos lim max dir) | |
(if (or (null lim) (null max) (null pos)) (return)) | |
(flet ((check-lim () (when (> (point) max) (return)))) | |
(let ((search-fn (intern (format "re-search-%s" | |
(if (eq dir 'fw) 'forward 'backward))))) | |
(goto-char pos) | |
(while (progn (unless (funcall search-fn "^[ \t]*" lim t) (return)) | |
(check-lim) | |
(looking-at "\\(?:[%.#]\\(?:\\w\\|[:-]\\)+\\)+")) | |
(goto-char (match-end 0)) | |
(check-lim) | |
(when (looking-at "[<>&!]+") | |
(goto-char (match-end 0)) | |
(check-lim)) | |
(when (memq (char-after) '(?= ?- ?~)) | |
(cons (+ 1 (point)) 'ruby-mode)))))) | |
(defun haml-mumamo-bw-exc-start-fun (pos min) | |
(haml-mumamo-exc-start-fun pos min pos 'bw)) | |
(defun haml-mumamo-bw-exc-end-fun (pos min) | |
(mumamo-chunk-start-bw-re pos min "$")) | |
(defun haml-mumamo-fw-exc-start-fun (pos max) | |
(car (haml-mumamo-exc-start-fun pos max max 'fw))) | |
(defun haml-mumamo-fw-exc-end-fun (pos max) | |
(mumamo-chunk-start-fw-re pos max "$")) | |
(define-mumamo-multi-major-mode haml-mumamo-mode | |
"Use `ruby-mode' for Ruby code in Haml documents." | |
("Haml Ruby family" haml-mode | |
(haml-mumamo-chunk))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment