[Top][All Lists]

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

Re: kill ring menu

From: Colin Walters
Subject: Re: kill ring menu
Date: 08 May 2002 02:05:14 -0400

On Tue, 2002-05-07 at 20:20, Miles Bader wrote:

> There could be a `font-lock-refontify-function' variable that such modes
> set, which `font-lock-mode' would call if necessary to refontify the
> buffer.

Ok, That might be one way to optimize things, if it turns out to be

> Then the interface will seem to work consistently for users, but special
> modes can avoid the overhead of the font-lock engine if they desire.

OK.  I have thought about this issue a lot more carefully.  

Richard: I have changed my mind with regards to your proposal.  I first
actually wrote a patch which implemented things the way you suggested. 
But from a user perspective, things still wouldn't be consistent,
because typing 'M-x font-lock-mode' wouldn't always do the Right Thing
in special buffers. So we might as well have kept the status quo.  

I believe your original objection to my approach was that loading
font-lock.el was a lot of overhead.  I have addressed this in the
attached patch, by creating a "font-core.el".

Miles: You objected to putting special text properties on the buffer
text, and then fontifying on them later, correct?  Unfortunately this is
the only way I can think of to implement fontification for special
buffers, such that typing M-x font-lock-mode will always do the Right
Thing.  I believe I can optimize this such that the mode's
`font-lock-fontify-region' function is only called *once*.  This should
minimize the overhead.  I don't think this will actually be very slow at
all, anyways.  Text properties are quite fast.  Or we could solve this
issue the way you suggest above.  So this should not be a problem.

One other issue that came up was that special modes wouldn't be
fontified by default.  I have solved this in a simple way; we add
`font-lock-mode' to the default value of the mode's hooks.  This allows
a user to customize fontification in a clean way.  If a user *doesn't*
want those modes fontified, they can

(remove-hook 'foo-mode-hook 'font-lock-mode)

Let me restate things in terms of advantages and disadvantages:

* From a user perspective, the attached patch doesn't change anything at
all, except that typing M-x font-lock-mode will now suddenly work in
special modes like Occur; if we decide to put this patch in, then I will
change Info and all the other modes to support it.
* The memory impact should be quite small, since we only load
font-core.el for special modes.

* Fontification of special buffers may take a bit longer.  I personally
don't believe the difference will be noticeable.  If it is (and I
haven't noticed any slowdown), I will work on making it faster.

In this patch, most of the changes are moved functions.  See the entries
for font-core.el to see what (little) code was actually changed.

2002-05-08  Colin Walters  <address@hidden>

        * font-lock.el (font-lock)
        (font-lock-highlighting-faces, font-lock-extra-types)
        (fast-lock, lazy-lock, jit-lock, font-lock-maximum-size)
        (font-lock-maximum-decoration, font-lock-verbose)
        (font-lock-defaults, font-lock-fontify-buffer-function)
        (font-lock-inhibit-thing-lock, font-lock-multiline)
        (font-lock-fontified, save-buffer-state)
        (font-lock-face-attributes, font-lock-mode)
        (turn-on-font-lock, global-font-lock-mode)
        (font-lock-global-modes, font-lock-support-mode)
        (fast-lock-mode, lazy-lock-mode, jit-lock-mode)
        (font-lock-turn-on-thing-lock, font-lock-turn-off-thing-lock)
        (font-lock-after-fontify-buffer, font-lock-after-unfontify-buffer)
        (font-lock-fontify-buffer, font-lock-unfontify-buffer)
        (font-lock-fontify-region, font-lock-unfontify-region)
        Moved to font-core.el.
        (font-lock-set-defaults): Renamed to `font-lock-set-defaults-1';
        partially moved to font-core.el.

        * font-core.el: New file, with functions broken out from
        (font-lock-core-only): New variable.
        (font-lock-mode): If `font-lock-core-only' is non-nil, fontify the
        whole buffer immediately; don't enable a font-lock support mode.
        (font-lock-set-defaults): Partially moved here from font-lock.el.
        We try to only load all of font-lock.el if the mode doesn't set

        * replace.el (occur-mode-hooks): New variable.
        (occur-mode): Set `font-lock-core-only'.  Run `occur-mode-hooks'

Attachment: font-lock.patch
Description: Text document

reply via email to

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