Mercurial > urweb
comparison src/elisp/urweb-mode.el @ 2115:3dc020fb2aa1
An Emacs urweb-mode optimization contributed by John Wiegley
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Wed, 11 Feb 2015 13:12:59 -0500 |
parents | 403f0cc65b9c |
children | 2b0f6b7ebf4f |
comparison
equal
deleted
inserted
replaced
2114:dca8d91b4170 | 2115:3dc020fb2aa1 |
---|---|
169 (save-excursion | 169 (save-excursion |
170 (let ( | 170 (let ( |
171 (depth 0) | 171 (depth 0) |
172 (finished nil) | 172 (finished nil) |
173 (answer nil) | 173 (answer nil) |
174 (bound (max 0 (- (point) 1024))) | |
174 ) | 175 ) |
175 (while (and (not finished) (re-search-backward "[-<{}]" nil t)) | 176 (while (and (not finished) |
176 (cond | 177 (re-search-backward "\\(\\([-{}]\\)\\|<\\(/?xml\\)?\\)" |
177 ((looking-at "{") | 178 bound t)) |
178 (if (> depth 0) | 179 (let ((xml-tag (length (or (match-string 3) ""))) |
179 (decf depth) | 180 (ch (match-string 2))) |
180 (setq finished t))) | 181 (cond |
181 ((looking-at "}") | 182 ((equal ch ?\{) |
182 (incf depth)) | 183 (if (> depth 0) |
183 ((looking-at "<xml>") | 184 (decf depth) |
184 (if (> depth 0) | 185 (setq finished t))) |
185 (decf depth) | 186 ((equal ch ?\}) |
186 (progn | 187 (incf depth)) |
187 (setq answer t) | 188 ((= xml-tag 3) |
188 (setq finished t)))) | 189 (if (> depth 0) |
189 ((looking-at "</xml>") | 190 (decf depth) |
190 (incf depth)) | 191 (progn |
191 | 192 (setq answer t) |
192 ((looking-at "-") | 193 (setq finished t)))) |
193 (if (looking-at "->") | 194 ((= xml-tag 4) |
194 (setq finished (= depth 0)))) | 195 (incf depth)) |
195 | 196 |
196 ((and (= depth 0) | 197 ((equal ch ?-) |
197 (not (looking-at "<xml")) ;; ignore <xml/> | 198 (if (looking-at "->") |
198 (eq font-lock-tag-face | 199 (setq finished (= depth 0)))) |
199 (get-text-property (point) 'face))) | 200 |
200 ;; previous code was highlighted as tag, seems we are in xml | 201 ((and (= depth 0) |
201 (progn | 202 (not (looking-at "<xml")) ;; ignore <xml/> |
202 (setq answer t) | 203 (eq font-lock-tag-face |
203 (setq finished t))) | 204 (get-text-property (point) 'face))) |
204 | 205 ;; previous code was highlighted as tag, seems we are in xml |
205 ((= depth 0) | 206 (progn |
206 ;; previous thing was a tag like, but not tag | 207 (setq answer t) |
207 ;; seems we are in usual code or comment | 208 (setq finished t))) |
208 (setq finished t)) | 209 |
209 )) | 210 ((= depth 0) |
211 ;; previous thing was a tag like, but not tag | |
212 ;; seems we are in usual code or comment | |
213 (setq finished t)) | |
214 ))) | |
210 answer))) | 215 answer))) |
211 | 216 |
212 (defun amAttribute (face) | 217 (defun amAttribute (face) |
213 (if (ignore-errors (save-excursion (backward-word 2) (backward-char 1) (looking-at "<"))) | 218 (if (ignore-errors (save-excursion (backward-word 2) (backward-char 1) (looking-at "<"))) |
214 nil | 219 nil |