summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2008-10-16 13:30:40 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2008-10-16 13:30:40 -0400
commit0608a7abedf738215560865e43d50909c1652c18 (patch)
tree302c9cf9d9eb49b3cd90978b8ff1b18393d0c2e3 /src
parent98c2a658375be784ec9afaa80146e5dff3514e5c (diff)
Improving indentation of XML after antiquote
Diffstat (limited to 'src')
-rw-r--r--src/elisp/urweb-mode.el21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/elisp/urweb-mode.el b/src/elisp/urweb-mode.el
index c8186182..308bd1af 100644
--- a/src/elisp/urweb-mode.el
+++ b/src/elisp/urweb-mode.el
@@ -478,6 +478,25 @@ If anyone has a good algorithm for this..."
(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 @@ If anyone has a good algorithm for this..."
(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