emacs-devel
[Top][All Lists]
Advanced

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

Fontifying outside of region passed to registered JIT lock function


From: Barry OReilly
Subject: Fontifying outside of region passed to registered JIT lock function
Date: Fri, 15 Nov 2013 10:47:46 -0500

Background:

I'm writing a color-parens minor mode that will fontify parens if they
are inconsistent with indentation. For example:

   (if region
       (setq beg (min jit-lock-start (car region))
       end (max jit-lock-end (cdr region))))

Indentation implies the close paren of (setq ...) would be at the end
of the same line, but it's really on the next line, so the minor mode
fontifies that. The goal is to give the user clues when indentation
lies about where close parens are.

Problem:

I am passing my color-parens-propertize-region function to
jit-lock-register and it processes the regions passed to it. However,
the regions need expansion because it's possible parent lists' parens
outside the region need fontification too.

I found the Elisp manual's section on Multiline Font Lock Constructs
and tried adding a hook to font-lock-extend-region-functions to expand
the region. I discovered that doesn't work because
font-lock-fontify-region-function and
font-lock-extend-region-functions are used under
font-lock-fontify-region, which is another registered JIT lock
function. Those region expansions don't apply to the other registered
jit-lock-functions.

Obviously I could disregard the region inputs and fontify minimally
outside of it, but my concerns are:

   • Maybe the JIT lock infrastructure expects jit-lock-functions to
     fontify only within the region?

   • It might be needlessly inefficient to fontify outside the region
     without JIT lock knowing, then it calls the jit-lock-functions
     again for those regions.

I found the jit-lock-after-change-extend-region-functions, but those
hooks aren't called for the initial fontifications.

What is the recommended way to expand the JIT region or otherwise
fontify outside of the regions passed to a registered JIT lock
function?



reply via email to

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