@@ -328,6 +328,24 @@ Any terminating `>' or `/' is not matched.")
328
328
(defvar sgml-font-lock-keywords sgml-font-lock-keywords-1
329
329
" Rules for highlighting SGML code. See also `sgml-tag-face-alist' ." )
330
330
331
+ (defvar-local sgml--syntax-propertize-ppss nil )
332
+
333
+ (defun sgml--syntax-propertize-ppss (pos )
334
+ " Return PPSS at POS, fixing the syntax of any lone `>' along the way."
335
+ (cl-assert (>= pos (car sgml--syntax-propertize-ppss)))
336
+ (let ((ppss (parse-partial-sexp (car sgml--syntax-propertize-ppss) pos -1
337
+ nil (cdr sgml--syntax-propertize-ppss))))
338
+ (while (eq -1 (car ppss))
339
+ (put-text-property (1- (point )) (point )
340
+ 'syntax-table (string-to-syntax " ." ))
341
+ ; ; Hack attack: rather than recompute the ppss from
342
+ ; ; (car sgml--syntax-propertize-ppss), we manually "fix it".
343
+ (setcar ppss 0 )
344
+ (setq ppss (parse-partial-sexp (point ) pos -1 nil ppss)))
345
+ (setcdr sgml--syntax-propertize-ppss ppss)
346
+ (setcar sgml--syntax-propertize-ppss pos)
347
+ ppss))
348
+
331
349
(eval-and-compile
332
350
(defconst sgml-syntax-propertize-rules
333
351
(syntax-propertize-precompile-rules
@@ -344,23 +362,28 @@ Any terminating `>' or `/' is not matched.")
344
362
; ; the resulting number of calls to syntax-ppss made it too slow
345
363
; ; (bug#33887), so we're now careful to leave alone any pair
346
364
; ; of quotes that doesn't hold a < or > char, which is the vast majority.
347
- (" \\ (?:\\ (?1:\" \\ )[^\" <>]*[<>\" ]\\ |\\ (?1:'\\ )[^'<>]*[<>']\\ )"
348
- (1 (unless (memq (char-before ) '(?\' ?\" ))
365
+ (" \\ (?:\\ (?1:\" \\ )[^\" <>]*\\ |\\ (?1:'\\ )[^'\" <>]*\\ )"
366
+ (1 (if (eq (char-after ) (char-after (match-beginning 0 )))
367
+ (forward-char 1 )
349
368
; ; Be careful to call `syntax-ppss' on a position before the one
350
369
; ; we're going to change, so as not to need to flush the data we
351
370
; ; just computed.
352
- (if (prog1 (zerop (car (syntax-ppss (match-beginning 0 ))))
353
- (goto-char (1- (match-end 0 ))))
371
+ (if (zerop (save-excursion
372
+ (car (sgml--syntax-propertize-ppss
373
+ (match-beginning 0 )))))
354
374
(string-to-syntax " ." )))))
355
375
)))
356
376
357
377
(defun sgml-syntax-propertize (start end )
358
378
" Syntactic keywords for `sgml-mode' ."
359
- (goto-char start)
379
+ (setq sgml--syntax-propertize-ppss (cons start (syntax-ppss start)))
380
+ (cl-assert (>= (cadr sgml--syntax-propertize-ppss) 0 ))
360
381
(sgml-syntax-propertize-inside end)
361
382
(funcall
362
383
(syntax-propertize-rules sgml-syntax-propertize-rules)
363
- start end))
384
+ start end)
385
+ ; ; Catch any '>' after the last quote.
386
+ (sgml--syntax-propertize-ppss end))
364
387
365
388
(defun sgml-syntax-propertize-inside (end )
366
389
(let ((ppss (syntax-ppss )))
0 commit comments