]> git.eshelyaron.com Git - emacs.git/commitdiff
Make `font-lock-add-keywords' work in derived modes
authorLars Ingebrigtsen <larsi@gnus.org>
Mon, 24 Jan 2022 10:55:57 +0000 (11:55 +0100)
committerLars Ingebrigtsen <larsi@gnus.org>
Mon, 24 Jan 2022 10:56:35 +0000 (11:56 +0100)
* lisp/font-lock.el (font-lock-set-defaults): Make
`font-lock-add-keywords' work in derived modes (bug#24176).

lisp/font-lock.el

index 083bfb8626b7a83501419687c5c087b21ca6eab5..d8a1fe399b69d007fd2162e69c71c4bc66b854f2 100644 (file)
@@ -1906,8 +1906,9 @@ preserve `hi-lock-mode' highlighting patterns."
 Sets various variables using `font-lock-defaults' and
 `font-lock-maximum-decoration'."
   ;; Set fontification defaults if not previously set for correct major mode.
-  (unless (and font-lock-set-defaults
-              (eq font-lock-major-mode major-mode))
+  (when (or (not font-lock-set-defaults)
+           (not font-lock-major-mode)
+            (not (derived-mode-p font-lock-major-mode)))
     (setq font-lock-major-mode major-mode)
     (setq font-lock-set-defaults t)
     (let* ((defaults font-lock-defaults)