]> git.eshelyaron.com Git - emacs.git/commitdiff
(font-lock-set-defaults): Try and fix bug#74281
authorStefan Monnier <monnier@iro.umontreal.ca>
Sun, 29 Dec 2024 15:18:37 +0000 (10:18 -0500)
committerEshel Yaron <me@eshelyaron.com>
Sat, 4 Jan 2025 20:24:21 +0000 (21:24 +0100)
* 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

index dd33c2382fcd7c1662825b1cab9dc28ed040bb9c..fbd2f9da83a97ba0443aca586341b21ca20f9153 100644 (file)
@@ -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.