comparison lispref/modes.texi @ 69469:cc34fffac608

* modes.texi: New node, "Region to Fontify" (for Font Lock). This describes font-lock-extend-region-function. ("Other Font Lock Variables"): move "font-lock-lines-before" to the new node "Region to Fontify".
author Alan Mackenzie <acm@muc.de>
date Tue, 14 Mar 2006 18:30:48 +0000
parents d842e198bb96
children caf8f09897bc
comparison
equal deleted inserted replaced
69468:0c2790d73955 69469:cc34fffac608
2335 2335
2336 @menu 2336 @menu
2337 * Font Lock Basics:: Overview of customizing Font Lock. 2337 * Font Lock Basics:: Overview of customizing Font Lock.
2338 * Search-based Fontification:: Fontification based on regexps. 2338 * Search-based Fontification:: Fontification based on regexps.
2339 * Customizing Keywords:: Customizing search-based fontification. 2339 * Customizing Keywords:: Customizing search-based fontification.
2340 * Region to Fontify:: Controlling which region gets refontified
2341 after a buffer change.
2340 * Other Font Lock Variables:: Additional customization facilities. 2342 * Other Font Lock Variables:: Additional customization facilities.
2341 * Levels of Font Lock:: Each mode can define alternative levels 2343 * Levels of Font Lock:: Each mode can define alternative levels
2342 so that the user can select more or less. 2344 so that the user can select more or less.
2343 * Precalculated Fontification:: How Lisp programs that produce the buffer 2345 * Precalculated Fontification:: How Lisp programs that produce the buffer
2344 contents can also specify how to fontify it. 2346 contents can also specify how to fontify it.
2715 '(("\\<\\(FIXME\\):" 1 font-lock-warning-face prepend) 2717 '(("\\<\\(FIXME\\):" 1 font-lock-warning-face prepend)
2716 ("\\<\\(and\\|or\\|not\\)\\>" . 2718 ("\\<\\(and\\|or\\|not\\)\\>" .
2717 font-lock-keyword-face))))) 2719 font-lock-keyword-face)))))
2718 @end smallexample 2720 @end smallexample
2719 2721
2722 @node Region to Fontify
2723 @subsection Region to Fontify after a Buffer Change
2724
2725 When a buffer is changed, the region that Font Lock refontifies is by
2726 default the smallest sequence of whole lines that spans the change.
2727 While this works well most of the time, sometimes it doesn't---for
2728 example, when a buffer change has changed the syntactic meaning of text
2729 on an earlier line.
2730
2731 You can enlarge (or even reduce) the region to fontify by setting either
2732 of the following variables:
2733
2734 @defvar font-lock-lines-before
2735 This variable specifies the number of extra lines to consider when
2736 refontifying the buffer after each text change. Font lock begins
2737 refontifying from that number of lines before the changed region. The
2738 default is 0, but using a larger value can be useful for coping with
2739 multi-line patterns. This variable is ignored whenever
2740 @code{font-lock-extend-region-function} is set and returns a
2741 non-@code{nil} value.
2742 @end defvar
2743
2744 @defvar font-lock-extend-region-function
2745 This buffer-local variable is either @code{nil} or is a function that
2746 determines the region to fontify, which Emacs then calls after each
2747 buffer change.
2748
2749 The function is given three parameters, the standard @var{beg},
2750 @var{end}, and @var{old-len} from after-change-functions (@pxref{Change
2751 Hooks}). It should return either a cons of the beginning and end buffer
2752 positions (in that order) of the region to fontify, or @code{nil} (which
2753 directs the caller to fontify the default region). This function need
2754 not preserve point or the match-data, but must preserve the current
2755 restriction. The region it returns may start or end in the middle of a
2756 line.
2757
2758 Since this function is called after every buffer change, it should be
2759 reasonably fast.
2760 @end defvar
2761
2720 @node Other Font Lock Variables 2762 @node Other Font Lock Variables
2721 @subsection Other Font Lock Variables 2763 @subsection Other Font Lock Variables
2722 2764
2723 This section describes additional variables that a major mode can 2765 This section describes additional variables that a major mode can
2724 set by means of @var{other-vars} in @code{font-lock-defaults} 2766 set by means of @var{other-vars} in @code{font-lock-defaults}
2770 Function to use for unfontifying a region. It should take two 2812 Function to use for unfontifying a region. It should take two
2771 arguments, the beginning and end of the region. The default value is 2813 arguments, the beginning and end of the region. The default value is
2772 @code{font-lock-default-unfontify-region}. 2814 @code{font-lock-default-unfontify-region}.
2773 @end defvar 2815 @end defvar
2774 2816
2775 @defvar font-lock-lines-before
2776 This variable specifies the number of extra lines to consider when
2777 refontifying the buffer after each text change. Font lock begins
2778 refontifying from that number of lines before the changed region. The
2779 default is 0, but using a larger value can be useful for coping with
2780 multi-line patterns.
2781 @end defvar
2782
2783 @ignore 2817 @ignore
2784 @defvar font-lock-inhibit-thing-lock 2818 @defvar font-lock-inhibit-thing-lock
2785 List of Font Lock mode related modes that should not be turned on. 2819 List of Font Lock mode related modes that should not be turned on.
2786 Currently, valid mode names are @code{fast-lock-mode}, 2820 Currently, valid mode names are @code{fast-lock-mode},
2787 @code{jit-lock-mode} and @code{lazy-lock-mode}. 2821 @code{jit-lock-mode} and @code{lazy-lock-mode}.