diff options
| author | Alan Mackenzie | 2006-03-14 18:30:48 +0000 |
|---|---|---|
| committer | Alan Mackenzie | 2006-03-14 18:30:48 +0000 |
| commit | 2fb936912f91199e39fca38cdcb914bf883641e8 (patch) | |
| tree | 5c7ba3de55f573151aba31f384a1ba0e41bd592a | |
| parent | ef0083218d1bb912de6e7a156e5b56607ac4997b (diff) | |
| download | emacs-2fb936912f91199e39fca38cdcb914bf883641e8.tar.gz emacs-2fb936912f91199e39fca38cdcb914bf883641e8.zip | |
* 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".
| -rw-r--r-- | lispref/modes.texi | 50 |
1 files changed, 42 insertions, 8 deletions
diff --git a/lispref/modes.texi b/lispref/modes.texi index b9eb33dcb88..e15392ac85a 100644 --- a/lispref/modes.texi +++ b/lispref/modes.texi | |||
| @@ -2337,6 +2337,8 @@ Search-based fontification happens second. | |||
| 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. |
| @@ -2717,6 +2719,46 @@ C mode @emph{and} all modes derived from it, do this instead: | |||
| 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 | ||
| @@ -2772,14 +2814,6 @@ 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. |