Mercurial > urweb
comparison src/elisp/urweb-mode.el @ 2142:3288e3c9948b
Fix XML indentation in Emacs mode
The return value of MATCH-STRING is a string. At least on Emacs 25,
the comparisons between string and character with EQUAL could never
succeed, and so the cases for matching braces were never triggered.
GET-TEXT-PROPERTY may return a list rather than an atom (for example,
on long lines with whitespace-mode turned on), and this broke the
heuristic of looking for the tag face in previous text.
author | Julian Squires <julian@cipht.net> |
---|---|
date | Mon, 04 May 2015 14:35:07 -0400 |
parents | 2b0f6b7ebf4f |
children | 3ffef52d549c |
comparison
equal
deleted
inserted
replaced
2141:53f91b67006c | 2142:3288e3c9948b |
---|---|
177 (re-search-backward "\\(\\([-{}]\\)\\|<\\(/?xml\\)?\\)" | 177 (re-search-backward "\\(\\([-{}]\\)\\|<\\(/?xml\\)?\\)" |
178 bound t)) | 178 bound t)) |
179 (let ((xml-tag (length (or (match-string 3) ""))) | 179 (let ((xml-tag (length (or (match-string 3) ""))) |
180 (ch (match-string 2))) | 180 (ch (match-string 2))) |
181 (cond | 181 (cond |
182 ((equal ch ?\{) | 182 ((equal ch "{") |
183 (if (> depth 0) | 183 (if (> depth 0) |
184 (decf depth) | 184 (decf depth) |
185 (setq finished t))) | 185 (setq finished t))) |
186 ((equal ch ?\}) | 186 ((equal ch "}") |
187 (incf depth)) | 187 (incf depth)) |
188 ((= xml-tag 3) | 188 ((= xml-tag 3) |
189 (if (> depth 0) | 189 (if (> depth 0) |
190 (decf depth) | 190 (decf depth) |
191 (progn | 191 (progn |
192 (setq answer t) | 192 (setq answer t) |
193 (setq finished t)))) | 193 (setq finished t)))) |
194 ((= xml-tag 4) | 194 ((= xml-tag 4) |
195 (incf depth)) | 195 (incf depth)) |
196 | 196 |
197 ((equal ch ?-) | 197 ((equal ch "-") |
198 (if (looking-at "->") | 198 (if (looking-at "->") |
199 (setq finished (= depth 0)))) | 199 (setq finished (= depth 0)))) |
200 | 200 |
201 ((and (= depth 0) | 201 ((and (= depth 0) |
202 (not (looking-at "<xml")) ;; ignore <xml/> | 202 (not (looking-at "<xml")) ;; ignore <xml/> |
203 (eq font-lock-tag-face | 203 (let ((face (get-text-property (point) 'face))) |
204 (get-text-property (point) 'face))) | 204 (funcall (if (listp face) #'member #'equal) 'font-lock-tag-face face))) |
205 ;; previous code was highlighted as tag, seems we are in xml | 205 ;; previous code was highlighted as tag, seems we are in xml |
206 (progn | 206 (progn |
207 (setq answer t) | 207 (setq answer t) |
208 (setq finished t))) | 208 (setq finished t))) |
209 | 209 |