Subject: Re: bug#3628: Python-Mode Ignores Global Font Lock

From: Lawrence Mitchell <[email-masked]>
Date: Mon, 22 Jun 2009 10:10:30 +0100

Sean B. Palmer wrote:
> In my .emacs file I turn off global font lock:

>    (global-font-lock-mode 0)

[...]

> In emacs 23.0.95.1 (build details below), this no longer works for
> Python files. That is to say, various *.py files that I've tested have
> syntax highlighting ON when I edit them in emacs with a normal
> command:

>    $ emacs example.py
>    $ emacs api.py

> Perl and C files have syntax highlighting OFF, on the other hand. When
> editing one of the Python files, syntax highlighting can be turned OFF
> by using the following procedure:

>    M-x eval-expression <RET>
>    (global-font-lock-mode 0) <RET>

> In other words, by evaluating the expression from my .emacs file
> manually. On repeating the expression, syntax highlighting remains
> OFF, so it is apparently not acting as a toggle.

(global-font-lock-mode 0) only turns /off/ font lock

| With prefix arg, turn Global-Font-Lock mode on if and only if
| arg is positive.

I.e., it's not acting as a toggle, but this is intended.

[...]

The overriding of user preference regarding font lock appears to
be a deliberate change.  A commit on Feb 21 2008 merges changes
from Dave Love's python.el.

| Author: Chong Yidong <[email-masked]>
| Date:   Thu Feb 21 17:03:47 2008 +0000

|     Merge from Dave Love's 2008-01-20 version.

These include:

|     (python-mode): Add python-pea-hook to pre-abbrev-expand-hook.  Use
|     symbol-completion-try-complete for hippie expansion.  Turn on font
|     lock unconditionally.

Font-lock is used unconditionally in python buffers, I think, so
that text properties marking strings and comments can be
maintained with greater ease than otherwise.  It appears to be a
design decision.

Cheers,
Lawrence
-- 
Lawrence Mitchell <[email-masked]>