Subject: bug#1534: Font lock decoration levels mismatch?

From: Glenn Morris <[email-masked]>
Date: Fri, 12 Dec 2008 15:34:33 -0500

Derick Eddington wrote:

>> > when I customize the level for a specific mode (one I'm still
>> > developing) the number given to Customize is 0-based not 1-based;
>> > i.e., my `font-lock-defaults' `KEYWORDS' member is like `(level-1
>> > level-2 level-3 level-4)' and, e.g., to make Customize use
>> > level-3 I have to tell it the number 2.
[...]
> I'm customizing `font-lock-maximum-decoration'.  It's documentation says:
[...]
>          ((c-mode . t) (c++-mode . 2) (t . 1))
>         means use the maximum decoration available for buffers in C
>         mode, level 2 decoration for buffers in C++ mode, and level 1
>         decoration otherwise.
[...]
> When I start customizing it from its default state and activate the
> "Value Menu" with "mode specific", I get:
>
> INS DEL Instance:
>             Mode:
>             (*) all
>             ( ) name: nil
>             Decoration:
>             ( ) default
>             (*) maximum
>             ( ) level: 1

OK. So where's the part where you have to say 2 in order to get 3?

If I use customize to say:

mode: all : maximum
mode: name : f90-mode : level 2

Then I get level 2 highlighting in F90 buffers.

Oh, perhaps I see the problem. You said:

  my `font-lock-defaults' `KEYWORDS' member is like `(level-1 level-2
  level-3 level-4)'

There should be a separate element at the start giving the default
highlighting for the mode. See for example f90-mode:

  (set (make-local-variable 'font-lock-defaults)
       '((f90-font-lock-keywords f90-font-lock-keywords-1
                                 f90-font-lock-keywords-2
                                 f90-font-lock-keywords-3
                                 f90-font-lock-keywords-4)
         nil t))

(or grep for "keywords-1" in the lisp sources)

That does indeed look like a documentation bug in the manual...