Mercurial > urweb
diff src/elisp/urweb-mode.el @ 367:28d3d7210687
Improving indentation of XML after antiquote
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Thu, 16 Oct 2008 13:30:40 -0400 |
parents | 3004f8843e36 |
children | b6be16792584 |
line wrap: on
line diff
--- a/src/elisp/urweb-mode.el Thu Oct 16 13:17:09 2008 -0400 +++ b/src/elisp/urweb-mode.el Thu Oct 16 13:30:40 2008 -0400 @@ -478,6 +478,25 @@ (setq done t)))) (and (not done) (> depth 0))))) +(defun skip-matching-braces () + "Skip backwards past matching brace pairs, to calculate XML indentation after quoted Ur code" + (beginning-of-line) + (let ((start-pos (point)) + (depth 0)) + (end-of-line) + (while (re-search-backward "[{}]" start-pos t) + (cond + ((looking-at "}") + (incf depth)) + ((looking-at "{") + (decf depth)))) + (while (and (> depth 0) (re-search-backward "[{}]" nil t) + (cond + ((looking-at "}") + (incf depth)) + ((looking-at "{") + (decf depth))))))) + (defun urweb-tag-matching-indent () "Seek back to a matching opener tag and get its line's indent" (save-excursion @@ -520,7 +539,7 @@ (and (urweb-in-xml) (let ((prev-indent (save-excursion (previous-line 1) - (end-of-line 1) + (skip-matching-braces) (re-search-backward "^[^\n]" nil t) (current-indentation)))) (cond