aboutsummaryrefslogtreecommitdiffstats
path: root/lispref
diff options
context:
space:
mode:
Diffstat (limited to 'lispref')
-rw-r--r--lispref/ChangeLog36
-rw-r--r--lispref/intro.texi13
-rw-r--r--lispref/modes.texi171
-rw-r--r--lispref/objects.texi6
-rw-r--r--lispref/variables.texi14
5 files changed, 167 insertions, 73 deletions
diff --git a/lispref/ChangeLog b/lispref/ChangeLog
index ac6bd07a175..020e667ec16 100644
--- a/lispref/ChangeLog
+++ b/lispref/ChangeLog
@@ -1,3 +1,31 @@
12006-05-01 Richard Stallman <rms@gnu.org>
2
3 * intro.texi (nil and t): Clarify.
4
5 * variables.texi (File Local Variables): Suggest using booleanp.
6
72006-05-01 Juanma Barranquero <lekktu@gmail.com>
8
9 * objects.texi (Type Predicates): Fix typos.
10
112006-05-01 Stefan Monnier <monnier@iro.umontreal.ca>
12
13 * intro.texi (nil and t): Add booleanp.
14
15 * objects.texi (Type Predicates): Add links for booleanp and
16 string-or-null-p.
17
182006-04-29 Richard Stallman <rms@gnu.org>
19
20 * modes.texi (Multiline Font Lock): Rename from
21 Multi line Font Lock Elements. Much clarification.
22 (Font Lock Multiline, Region to Fontify): Much clarification.
23
242006-04-29 Stefan Monnier <monnier@iro.umontreal.ca>
25
26 * variables.texi (File Local Variables): Remove the special case t for
27 safe-local-variable.
28
12006-04-26 Richard Stallman <rms@gnu.org> 292006-04-26 Richard Stallman <rms@gnu.org>
2 30
3 * syntax.texi (Parsing Expressions): Minor cleanup. 31 * syntax.texi (Parsing Expressions): Minor cleanup.
@@ -64,7 +92,7 @@
64 92
652006-03-25 Karl Berry <karl@gnu.org> 932006-03-25 Karl Berry <karl@gnu.org>
66 94
67 * elisp.texi: use @copyright{} instead of (C), and do not indent 95 * elisp.texi: Use @copyright{} instead of (C), and do not indent
68 the year list. 96 the year list.
69 97
702006-03-21 Nick Roberts <nickrob@snap.net.nz> 982006-03-21 Nick Roberts <nickrob@snap.net.nz>
@@ -98,7 +126,7 @@
98 126
99 * display.texi (Defining Images): Fix example in 127 * display.texi (Defining Images): Fix example in
100 image-load-path-for-library by not recommending that one binds 128 image-load-path-for-library by not recommending that one binds
101 image-load-path. Just defvar it to placate compiler and only use 129 image-load-path. Just defvar it to placate compiler and only use
102 it if previously defined. 130 it if previously defined.
103 131
1042006-03-14 Bill Wohler <wohler@newt.com> 1322006-03-14 Bill Wohler <wohler@newt.com>
@@ -570,11 +598,11 @@
570 598
5712005-09-26 Chong Yidong <cyd@stupidchicken.com> 5992005-09-26 Chong Yidong <cyd@stupidchicken.com>
572 600
573 * errors.texi (Standard Errors): Corrected xrefs. 601 * errors.texi (Standard Errors): Correct xrefs.
574 602
5752005-09-18 Chong Yidong <cyd@stupidchicken.com> 6032005-09-18 Chong Yidong <cyd@stupidchicken.com>
576 604
577 * display.texi (Defining Images): Updated documentation for 605 * display.texi (Defining Images): Update documentation for
578 `image-load-path'. 606 `image-load-path'.
579 607
5802005-09-17 Richard M. Stallman <rms@gnu.org> 6082005-09-17 Richard M. Stallman <rms@gnu.org>
diff --git a/lispref/intro.texi b/lispref/intro.texi
index b2294be4c2d..7e1b6155b35 100644
--- a/lispref/intro.texi
+++ b/lispref/intro.texi
@@ -163,7 +163,7 @@ person reading this manual, are thought of as ``the programmer'' and are
163addressed as ``you''. ``The user'' is the person who uses Lisp 163addressed as ``you''. ``The user'' is the person who uses Lisp
164programs, including those you write. 164programs, including those you write.
165 165
166@cindex fonts 166@cindex fonts in this manual
167 Examples of Lisp code are formatted like this: @code{(list 1 2 3)}. 167 Examples of Lisp code are formatted like this: @code{(list 1 2 3)}.
168Names that represent metasyntactic variables, or arguments to a function 168Names that represent metasyntactic variables, or arguments to a function
169being described, are formatted like this: @var{first-number}. 169being described, are formatted like this: @var{first-number}.
@@ -187,14 +187,14 @@ readers. After the Lisp reader has read either @samp{()} or @samp{nil},
187there is no way to determine which representation was actually written 187there is no way to determine which representation was actually written
188by the programmer. 188by the programmer.
189 189
190 In this manual, we use @code{()} when we wish to emphasize that it 190 In this manual, we write @code{()} when we wish to emphasize that it
191means the empty list, and we use @code{nil} when we wish to emphasize 191means the empty list, and we write @code{nil} when we wish to emphasize
192that it means the truth value @var{false}. That is a good convention to use 192that it means the truth value @var{false}. That is a good convention to use
193in Lisp programs also. 193in Lisp programs also.
194 194
195@example 195@example
196(cons 'foo ()) ; @r{Emphasize the empty list} 196(cons 'foo ()) ; @r{Emphasize the empty list}
197(not nil) ; @r{Emphasize the truth value @var{false}} 197(setq foo-flag nil) ; @r{Emphasize the truth value @var{false}}
198@end example 198@end example
199 199
200@cindex @code{t}, uses of 200@cindex @code{t}, uses of
@@ -212,6 +212,11 @@ to use them as constants in a program. An attempt to change their
212values results in a @code{setting-constant} error. @xref{Constant 212values results in a @code{setting-constant} error. @xref{Constant
213Variables}. 213Variables}.
214 214
215@defun booleanp object
216Return non-nil iff @var{object} is one of the two canonical boolean
217values: @code{t} or @code{nil}.
218@end defun
219
215@node Evaluation Notation 220@node Evaluation Notation
216@subsection Evaluation Notation 221@subsection Evaluation Notation
217@cindex evaluation notation 222@cindex evaluation notation
diff --git a/lispref/modes.texi b/lispref/modes.texi
index 3f56179231c..9e55ca847fc 100644
--- a/lispref/modes.texi
+++ b/lispref/modes.texi
@@ -2345,8 +2345,8 @@ Search-based fontification happens second.
2345* Syntactic Font Lock:: Fontification based on syntax tables. 2345* Syntactic Font Lock:: Fontification based on syntax tables.
2346* Setting Syntax Properties:: Defining character syntax based on context 2346* Setting Syntax Properties:: Defining character syntax based on context
2347 using the Font Lock mechanism. 2347 using the Font Lock mechanism.
2348* Multi line Font Lock Elements:: How to coerce Font Lock into properly 2348* Multiline Font Lock:: How to coerce Font Lock into properly
2349 highlighting multiline elements. 2349 highlighting multiline constructs.
2350@end menu 2350@end menu
2351 2351
2352@node Font Lock Basics 2352@node Font Lock Basics
@@ -2625,7 +2625,7 @@ Its value should have one of the forms described in this table.
2625 2625
2626@strong{Warning:} Do not design an element of @code{font-lock-keywords} 2626@strong{Warning:} Do not design an element of @code{font-lock-keywords}
2627to match text which spans lines; this does not work reliably. 2627to match text which spans lines; this does not work reliably.
2628For details, see @xref{Multi line Font Lock Elements}. 2628For details, see @xref{Multiline Font Lock}.
2629 2629
2630You can use @var{case-fold} in @code{font-lock-defaults} to specify 2630You can use @var{case-fold} in @code{font-lock-defaults} to specify
2631the value of @code{font-lock-keywords-case-fold-search} which says 2631the value of @code{font-lock-keywords-case-fold-search} which says
@@ -2944,8 +2944,8 @@ value returns @code{font-lock-comment-face} for comments and
2944 2944
2945This can be used to highlighting different kinds of strings or 2945This can be used to highlighting different kinds of strings or
2946comments differently. It is also sometimes abused together with 2946comments differently. It is also sometimes abused together with
2947@code{font-lock-syntactic-keywords} to highlight elements that span 2947@code{font-lock-syntactic-keywords} to highlight constructs that span
2948multiple lines, but this is too obscure to document in this manual. 2948multiple lines, but this is too esoteric to document here.
2949 2949
2950Specify this variable using @var{other-vars} in 2950Specify this variable using @var{other-vars} in
2951@code{font-lock-defaults}. 2951@code{font-lock-defaults}.
@@ -3015,21 +3015,61 @@ Major modes normally set this variable with @var{other-vars} in
3015@code{font-lock-defaults}. 3015@code{font-lock-defaults}.
3016@end defvar 3016@end defvar
3017 3017
3018@node Multi line Font Lock Elements 3018@node Multiline Font Lock
3019@subsection Multi line Font Lock Elements 3019@subsection Multiline Font Lock Constructs
3020@cindex multi line font lock 3020@cindex multiline font lock
3021
3022 Normally, elements of @code{font-lock-keywords} should not match
3023across multiple lines; that doesn't work reliably, because Font Lock
3024usually scans just part of the buffer, and it can miss a multi-line
3025construct that crosses the line boundary where the scan starts. (The
3026scan normally starts at the beginning of a line.)
3027
3028 Making elements that match multiline constructs work properly has
3029two aspects: correct @emph{identification} and correct
3030@emph{rehighlighting}. The first means that Font Lock finds all
3031multiline constructs. The second means that Font Lock will correctly
3032rehighlight all the relevant text when a multiline construct is
3033changed---for example, if some of the text that was previously part of
3034a multiline construct ceases to be part of it. The two aspects are
3035closely related, and often getting one of them to work will appear to
3036make the other also work. However, for reliable results you must
3037attend explicitly to both aspects.
3038
3039 There are two ways to ensure correct identification of multiline
3040constructs:
3041
3042@itemize
3043@item
3044Place a @code{font-lock-multiline} or @code{jit-lock-defer-multiline}
3045property on the construct when it is added to the buffer.
3046@item
3047Use @code{font-lock-fontify-region-function} hook to extend the scan
3048so that the scanned text never starts or ends in the middle of a
3049multiline construct.
3050@end itemize
3021 3051
3022Normally, Font Lock elements specified via @code{font-lock-keywords} 3052 There are three ways to do rehighlighting of multiline constructs:
3023should not match across multiple lines. If they do, Font Lock may
3024fail to highlight them properly. This is fundamentally due to the
3025fact that Font Lock does not always look at the whole buffer at
3026a time, for obvious performance reasons, and instead only looks
3027at a small chunk at a time. In order for the highlight to be correct,
3028a chunk should not straddle an element matched by
3029@code{font-lock-keywords}. The default heuristic used for this is to
3030start and end chunks at the beginning resp. end of a line.
3031 3053
3032To work around this limitations, a few tools are provided. 3054@itemize
3055@item
3056Place a @code{font-lock-multiline} property on the construct. This
3057will rehighlight the whole construct if any part of it is changed. In
3058some cases you can do this automatically by setting the
3059@code{font-lock-multiline} variable.
3060@item
3061Use @code{jit-lock-contextually}. This will only rehighlight the part
3062of the construct that follows the actual change, and will do it after
3063a short delay. This only works if the highlighting of the various
3064parts of your multiline construct never depends on text in subsequent
3065lines. Since @code{jit-lock-contextually} is activated by default,
3066this can be an attractive solution.
3067@item
3068Place a @code{jit-lock-defer-multiline} property on the construct.
3069This works only if @code{jit-lock-contextually} is used, but it can
3070handle the case where highlighting depends on subsequent lines.
3071@item
3072@end itemize
3033 3073
3034@menu 3074@menu
3035* Font Lock Multiline:: Marking multiline chunks with a text property 3075* Font Lock Multiline:: Marking multiline chunks with a text property
@@ -3040,60 +3080,75 @@ To work around this limitations, a few tools are provided.
3040@node Font Lock Multiline 3080@node Font Lock Multiline
3041@subsubsection Font Lock Multiline 3081@subsubsection Font Lock Multiline
3042 3082
3043In order to make it possible to properly highlight elements that span 3083 One way to ensure reliable rehighlighting of multiline Font Lock
3044multiple lines, Font Lock obeys a special text property 3084constructs is to put on the text property @code{font-lock-multiline}.
3045@code{font-lock-multiline} which if non-@code{nil} indicates that this 3085It should be present and non-@code{nil} for text that is part of a
3046piece of text is part of a multiline construct. So when Font Lock is 3086multiline construct.
3047asked to highlight a region, it first verifies the two boundaries and 3087
3048extends them as needed so they do not fall in the middle of a piece of 3088 When Font Lock is about to highlight a range of text, it first
3049text marked with the @code{font-lock-multiline} property. 3089extends the boundaries of the range as necessary so that they do not
3050Immediately after that, it also erases all @code{font-lock-multiline} 3090fall within text marked with the @code{font-lock-multiline} property.
3051properties from the region it is about to highlight, so it is the 3091Then it removes any @code{font-lock-multiline} properties from the
3052responsability of the highlighting specification (mostly 3092range, and highlights it. The highlighting specification (mostly
3053@code{font-lock-keywords}) to make sure that this property is re-added 3093@code{font-lock-keywords}) must reinstall this property each time,
3054where needed so as to inform the next round of Font Locking of the 3094whenever it is appropriate.
3055presence of a multiline construct. 3095
3056 3096 @strong{Warning:} don't use the @code{font-lock-multiline} property
3057It is important to understand that the @code{font-lock-multiline} 3097on large ranges of text, because that will make rehighlighting slow.
3058property should preferably only be used on Font Lock elements of
3059moderate size: every time that text is modified within the multiline
3060elements (or nearby), the whole multiline element will be completely
3061re-highlighted, so if its size is large, the time to font-lock may
3062render editing painfully slow.
3063 3098
3064@defvar font-lock-multiline 3099@defvar font-lock-multiline
3065If the @code{font-lock-multiline} variable is set to @code{t}, Font 3100If the @code{font-lock-multiline} variable is set to @code{t}, Font
3066Lock will try to automatically add the @code{font-lock-multiline} 3101Lock will try to add the @code{font-lock-multiline} property
3067property on the keywords that span several lines. This is no silver 3102automatically on multiline constructs. This is not a universal
3068bullet however since it slows down Font Lock somewhat, and still does 3103solution, however, since it slows down Font Lock somewhat. It can
3069not always find all multiline constructs, especially when used with 3104miss some multiline constructs, or make the property larger or smaller
3070Jit Lock, which is enabled by default. 3105than necessary.
3106
3107For elements whose @var{matcher} is a function, the function should
3108ensure that submatch 0 covers the whole relevant multiline construct,
3109even if only a small subpart will be highlighted. It is often just as
3110easy to add the @code{font-lock-multiline} property by hand.
3071@end defvar 3111@end defvar
3072 3112
3113 The @code{font-lock-multiline} property is meant to ensure proper
3114refontification; it does not automatically identify new multiline
3115constructs. Identifying the requires that Font-Lock operate on large
3116enough chunks at a time. This will happen by accident on many cases,
3117which may give the impression that multiline constructs magically work.
3118If you set the @code{font-lock-multiline} variable non-@code{nil},
3119this impression will be even stronger, since the highlighting of those
3120constructs which are found will be properly updated from then on.
3121But that does not work reliably.
3122
3123 To find multiline constructs reliably, you must either manually
3124place the @code{font-lock-multiline} property on the text before
3125Font-Lock looks at it, or use
3126@code{font-lock-fontify-region-function}.
3127
3073@node Region to Fontify 3128@node Region to Fontify
3074@subsubsection Region to Fontify after a Buffer Change 3129@subsubsection Region to Fontify after a Buffer Change
3075 3130
3076 When a buffer is changed, the region that Font Lock refontifies is by 3131 When a buffer is changed, the region that Font Lock refontifies is
3077default the smallest sequence of whole lines that spans the change. 3132by default the smallest sequence of whole lines that spans the change.
3078While this works well most of the time, sometimes it doesn't---for 3133While this works well most of the time, sometimes it doesn't---for
3079example, when a buffer change has changed the syntactic meaning of text 3134example, when a change alters the syntactic meaning of text on an
3080on an earlier line. 3135earlier line.
3081 3136
3082You can enlarge (or even reduce) the region to fontify by setting @c either of 3137 You can enlarge (or even reduce) the region to fontify by setting
3083the following variables: 3138one the following variables:
3084 3139
3085@defvar font-lock-extend-region-function 3140@defvar font-lock-extend-region-function
3086This buffer-local variable is either @code{nil} or is a function that 3141This buffer-local variable is either @code{nil} or a function for
3087determines the region to fontify, which Emacs then calls after each 3142Font-Lock to call to determine the region to scan and fontify.
3088buffer change.
3089 3143
3090The function is given three parameters, the standard @var{beg}, 3144The function is given three parameters, the standard @var{beg},
3091@var{end}, and @var{old-len} from after-change-functions (@pxref{Change 3145@var{end}, and @var{old-len} from after-change-functions
3092Hooks}). It should return either a cons of the beginning and end buffer 3146(@pxref{Change Hooks}). It should return either a cons of the
3093positions (in that order) of the region to fontify, or @code{nil} (which 3147beginning and end buffer positions (in that order) of the region to
3094directs the caller to fontify the default region). This function needs 3148fontify, or @code{nil} (which means choose the region in the standard
3095to preserve point, the match-data, and the current restriction. 3149way). This function needs to preserve point, the match-data, and the
3096The region it returns may start or end in the middle of a line. 3150current restriction. The region it returns may start or end in the
3151middle of a line.
3097 3152
3098Since this function is called after every buffer change, it should be 3153Since this function is called after every buffer change, it should be
3099reasonably fast. 3154reasonably fast.
diff --git a/lispref/objects.texi b/lispref/objects.texi
index 93848cffe09..5665e5beee6 100644
--- a/lispref/objects.texi
+++ b/lispref/objects.texi
@@ -1779,6 +1779,12 @@ with references to further information.
1779 1779
1780@item windowp 1780@item windowp
1781@xref{Basic Windows, windowp}. 1781@xref{Basic Windows, windowp}.
1782
1783@item booleanp
1784@xref{nil and t, booleanp}.
1785
1786@item string-or-null-p
1787@xref{Predicates for Strings, string-or-null-p}.
1782@end table 1788@end table
1783 1789
1784 The most general way to check the type of an object is to call the 1790 The most general way to check the type of an object is to call the
diff --git a/lispref/variables.texi b/lispref/variables.texi
index d97848549c0..5b4b779448e 100644
--- a/lispref/variables.texi
+++ b/lispref/variables.texi
@@ -1778,13 +1778,13 @@ measures to prevent this.
1778 1778
1779@cindex safe local variable 1779@cindex safe local variable
1780 You can specify safe values for a variable with a 1780 You can specify safe values for a variable with a
1781@code{safe-local-variable} property. If the property is @code{t}, 1781@code{safe-local-variable} property. The property has to be
1782setting that variable in a file is always considered safe, regardless 1782a function of one argument; any value is safe if the function
1783of the value used. If the property is a function of one argument, 1783returns non-@code{nil} given that value. Many commonly encountered
1784then any value is safe if the function returns non-@code{nil} given 1784file variables standardly have @code{safe-local-variable} properties,
1785that value. Many commonly encountered file variables standardly have 1785including @code{fill-column}, @code{fill-prefix}, and
1786@code{safe-local-variable} properties, including @code{fill-column}, 1786@code{indent-tabs-mode}. For boolean-valued variables that are safe,
1787@code{fill-prefix}, and @code{indent-tabs-mode}. 1787use @code{booleanp} as the property value.
1788 1788
1789@defopt safe-local-variable-values 1789@defopt safe-local-variable-values
1790This variable provides another way to mark some variable values as 1790This variable provides another way to mark some variable values as