[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: problem with mh-e and 2002-08-20 change to font-core.el

From: Stefan Monnier
Subject: Re: problem with mh-e and 2002-08-20 change to font-core.el
Date: Fri, 30 Aug 2002 09:42:49 -0400

>     > font-lock-face properties go in mode-specific places.
>     But do the properties belong to the text or to the mode.
> I am not sure that question makes real sense, but the
> font-lock-face property is not specific to any one mode.
> The right font-lock-face properties for one mode are wrong
> for some others.
>     I have the impression that most of those font-lock-face properties
>     are added together with the corresponding text and that they can't
>     be recovered just from the text.  I.e. erasing them might not
>     be the right thing to do since it loses information.
> For Occur mode, this is correct.  Info mode automatically applies
> the properties to the text.
> With the current code, changing from Occur mode to Fundamental mode
> and back to Occur mode would lose the font-lock-face properties.
> That is a bug.
> With the change you propose, changing from Occur mode to Fundamental
> mode and then to Info mode would leave you with font-lock-face
> properties left over from Occur mode.  That would be a bug.

I'm not sure how important this is, really.

> Is there any way to make both cases work right?

I think we can't make it work "automatically", but instead we need
to change `info.el' such that (font-lock-mode 1) or (font-lock-mode 0)
in info-mode begins by clearing the font-lock-face property.

We can maybe do it with something like

  (add-hook 'font-lock-mode
            (lambda ()
              (remove-face-properties (point-min) (point-max)

but that might be run too late.  So maybe we should add some
support in font-core.el to make it easier for a mode to tell
"erase font-lock-face property when font-lock-mode is changed".

Of course, another alternative is to make info.el use font-lock-keywords
(and the `face' property) rather than do all the looping&matching by hand.
That seems much better.

>     The "erase the font-lock-face property when changing-mode" hook you
>     added is only added when you turn on font-lock-mode, so the
>     font-lock-face property will stay if you don't turn on font-lock-mode
>     before changing major-mode.
> Now I understand.  Is there a method that fixes this too?

First, I think that the change-major-mode-hook should
run (font-lock-mode -1) and that if it doesn't do the right thing,
then we should fix (font-lock-mode -1) rather than change
the change-major-mode-hook.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]