From 83d05a8edf859a59d9e9c41e170c9686cef9206f Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Sun, 29 Dec 2024 10:18:37 -0500 Subject: [PATCH] (font-lock-set-defaults): Try and fix bug#74281 * lisp/font-lock.el (font-lock-set-defaults): Set `font-lock--syntax-table-affects-ppss` more carefully, and include ' among the "safe" syntaxes. (cherry picked from commit c85d2e3519bf93837cead012a8281ee9bb4be9a8) --- lisp/font-lock.el | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/lisp/font-lock.el b/lisp/font-lock.el index dd33c2382fc..fbd2f9da83a 100644 --- a/lisp/font-lock.el +++ b/lisp/font-lock.el @@ -1940,14 +1940,18 @@ Sets various variables using `font-lock-defaults' and (dolist (char (if (numberp (car selem)) (list (car selem)) (mapcar #'identity (car selem)))) - (unless (memq (car (aref font-lock-syntax-table char)) - '(1 2 3)) ;"." "w" "_" - (setq font-lock--syntax-table-affects-ppss t)) - (modify-syntax-entry char syntax font-lock-syntax-table) - (unless (memq (car (aref font-lock-syntax-table char)) - '(1 2 3)) ;"." "w" "_" - (setq font-lock--syntax-table-affects-ppss t)) - )))) + (let ((old-syntax (aref font-lock-syntax-table char))) + (modify-syntax-entry char syntax font-lock-syntax-table) + (let ((new-syntax (aref font-lock-syntax-table char))) + (unless (and (equal (cdr old-syntax) (cdr new-syntax)) + ;; Changes within the w/_/./' subset don't + ;; affect `syntax-ppss'. + (memq (logand (car old-syntax) 255) '(1 2 3 6)) + (memq (logand (car new-syntax) 255) '(1 2 3 6)) + ;; Check changes to the syntax flags. + (equal (ash (car old-syntax) -8) + (ash (car new-syntax) -8))) + (setq font-lock--syntax-table-affects-ppss t)))))))) ;; (nth 4 defaults) used to hold `font-lock-beginning-of-syntax-function', ;; but that was removed in 25.1, so if it's a cons cell, we assume that ;; it's part of the variable alist. -- 2.39.5