@@ -341,26 +341,30 @@ Any terminating `>' or `/' is not matched.")
341
341
(defvar sgml-font-lock-keywords sgml-font-lock-keywords-1
342
342
" Rules for highlighting SGML code. See also `sgml-tag-face-alist' ." )
343
343
344
+ (eval-and-compile
345
+ (defconst sgml-syntax-propertize-rules
346
+ (syntax-propertize-precompile-rules
347
+ ; ; Use the `b' style of comments to avoid interference with the -- ... --
348
+ ; ; comments recognized when `sgml-specials' includes ?-.
349
+ ; ; FIXME: beware of <!--> blabla <!--> !!
350
+ (" \\ (<\\ )!--" (1 " < b" ))
351
+ (" --[ \t\n ]*\\ (>\\ )" (1 " > b" ))
352
+ (" \\ (<\\ )[?!]" (1 (prog1 " |>"
353
+ (sgml-syntax-propertize-inside end))))
354
+ ; ; Double quotes outside of tags should not introduce strings.
355
+ ; ; Be careful to call `syntax-ppss' on a position before the one we're
356
+ ; ; going to change, so as not to need to flush the data we just computed.
357
+ (" \" " (0 (if (prog1 (zerop (car (syntax-ppss (match-beginning 0 ))))
358
+ (goto-char (match-end 0 )))
359
+ (string-to-syntax " ." )))))))
360
+
344
361
(defun sgml-syntax-propertize (start end )
345
362
" Syntactic keywords for `sgml-mode' ."
346
363
(goto-char start)
347
364
(sgml-syntax-propertize-inside end)
348
365
(funcall
349
- (syntax-propertize-rules
350
- ; ; Use the `b' style of comments to avoid interference with the -- ... --
351
- ; ; comments recognized when `sgml-specials' includes ?-.
352
- ; ; FIXME: beware of <!--> blabla <!--> !!
353
- (" \\ (<\\ )!--" (1 " < b" ))
354
- (" --[ \t\n ]*\\ (>\\ )" (1 " > b" ))
355
- (" \\ (<\\ )[?!]" (1 (prog1 " |>"
356
- (sgml-syntax-propertize-inside end))))
357
- ; ; Double quotes outside of tags should not introduce strings.
358
- ; ; Be careful to call `syntax-ppss' on a position before the one we're
359
- ; ; going to change, so as not to need to flush the data we just computed.
360
- (" \" " (0 (if (prog1 (zerop (car (syntax-ppss (match-beginning 0 ))))
361
- (goto-char (match-end 0 )))
362
- (string-to-syntax " ." )))))
363
- start end))
366
+ (syntax-propertize-rules sgml-syntax-propertize-rules)
367
+ start end))
364
368
365
369
(defun sgml-syntax-propertize-inside (end )
366
370
(let ((ppss (syntax-ppss )))
@@ -1304,13 +1308,24 @@ really isn't a tag after all."
1304
1308
(let ((pps (parse-partial-sexp start end 2 )))
1305
1309
(and (= (nth 0 pps) 0 ))))))
1306
1310
1311
+ (defun sgml--find-<>-backward (limit )
1312
+ " Search backward for a '<' or '>' character.
1313
+ The character must have open or close syntax.
1314
+ Returns t if found, nil otherwise."
1315
+ (catch 'found
1316
+ (while (re-search-backward " [<>]" limit 'move )
1317
+ ; ; If this character has "open" or "close" syntax, then we've
1318
+ ; ; found the one we want.
1319
+ (when (memq (syntax-class (syntax-after (point ))) '(4 5 ))
1320
+ (throw 'found t )))))
1321
+
1307
1322
(defun sgml-parse-tag-backward (&optional limit )
1308
1323
" Parse an SGML tag backward, and return information about the tag.
1309
1324
Assume that parsing starts from within a textual context.
1310
1325
Leave point at the beginning of the tag."
1311
1326
(catch 'found
1312
1327
(let (tag-type tag-start tag-end name)
1313
- (or (re-search-backward " [<>] " limit 'move )
1328
+ (or (sgml--find-<>-backward limit)
1314
1329
(error " No tag found " ))
1315
1330
(when (eq (char-after ) ?< )
1316
1331
; ; Oops!! Looks like we were not in a textual context after all!.
0 commit comments