Subject: bug#24176: Confusing interaction between define-derived-mode and font-lock-add-keywords

From: Clément Pit--Claudel <[email-masked]>
Date: Sun, 7 Aug 2016 02:41:30 -0400

Hi bug-gnu-emacs,

Given the following mode definitions, I was expecting ~/a to have one keyword, ~/b to have two, and ~/c to have three:

(define-derived-mode ~/a fundamental-mode
  (font-lock-add-keywords nil `(("a" 0 'font-lock-keyword-face))))
(define-derived-mode ~/b ~/a
  (font-lock-add-keywords nil `(("b" 0 'font-lock-builtin-face))))
(define-derived-mode ~/c ~/b
  (font-lock-add-keywords nil `(("c" 0 'font-lock-constant-face))))

This assumption is wrong, as can be easily verified by opening a new buffer, inserting "abc", and switching between ~/a, ~/b, ~/c.

What's going on? Is this a font-lock bug, a doc bug, or a user-got-confused issue?

Clément.