comparison src/elisp/urweb-mode.el @ 1525:a479947efbcd

Improve detection of XML in urweb-mode; small tutorial improvement
author Adam Chlipala <adam@chlipala.net>
date Tue, 02 Aug 2011 17:28:37 -0400
parents 3c0803c1acd7
children 9c7b79214cae
comparison
equal deleted inserted replaced
1524:a71223513c77 1525:a479947efbcd
168 (let ( 168 (let (
169 (depth 0) 169 (depth 0)
170 (finished nil) 170 (finished nil)
171 (answer nil) 171 (answer nil)
172 ) 172 )
173 (while (and (not finished) (re-search-backward "[<>{}]" nil t)) 173 (while (and (not finished) (re-search-backward "[<{}]" nil t))
174 (cond 174 (cond
175 ((looking-at "{") 175 ((looking-at "{")
176 (if (> depth 0) 176 (if (> depth 0)
177 (decf depth) 177 (decf depth)
178 (setq finished t))) 178 (setq finished t)))
179 ((looking-at "}") 179 ((looking-at "}")
180 (incf depth)) 180 (incf depth))
181 ((save-excursion (backward-char 1) (or (looking-at "=>") 181 ((looking-at "<xml>")
182 (looking-at "->") 182 (if (> depth 0)
183 (looking-at "<>"))) 183 (decf depth)
184 nil) 184 (progn
185 ((or (looking-at "< ") (looking-at "<=")) 185 (setq answer t)
186 nil) 186 (setq finished t))))
187 ((looking-at "<") 187 ((looking-at "</xml>")
188 (setq finished t)) 188 (incf depth))))
189 ((save-excursion (backward-char 1) (looking-at " >"))
190 nil)
191 ((looking-at ">")
192 (cond
193 ((> depth 0)
194 (if (not (re-search-backward "<" nil t))
195 (setq finished t)))
196 ((save-excursion (backward-char 1) (looking-at " "))
197 (setq finished t))
198 (t
199 (progn (backward-char 4)
200 (setq answer (not (or
201 (looking-at "/xml")
202 (looking-at "xml/"))))
203 (setq finished t)))))))
204 answer))) 189 answer)))
205 190
206 (defun amAttribute (face) 191 (defun amAttribute (face)
207 (if (ignore-errors (save-excursion (backward-word 2) (backward-char 1) (looking-at "<"))) 192 (if (ignore-errors (save-excursion (backward-word 2) (backward-char 1) (looking-at "<")))
208 nil 193 nil