diff options
| author | Karoly Lorentey | 2005-04-11 12:40:15 +0000 |
|---|---|---|
| committer | Karoly Lorentey | 2005-04-11 12:40:15 +0000 |
| commit | 221d5c8772dc29f854292ec7cb423fce925daecf (patch) | |
| tree | 5fe05145ce31ffcc9d1a621c027410151e4a2106 /lispref | |
| parent | 1b9ab2508610fea57aa777956de14ee84d66862f (diff) | |
| parent | 9552bee8c6e7c5ee16ca60cddebaebdf5d238e05 (diff) | |
| download | emacs-221d5c8772dc29f854292ec7cb423fce925daecf.tar.gz emacs-221d5c8772dc29f854292ec7cb423fce925daecf.zip | |
Merged from miles@gnu.org--gnu-2005 (patch 59, 240-245)
Patches applied:
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-240
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-241
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-242
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-243
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-244
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-245
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-59
Update from CVS
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-326
Diffstat (limited to 'lispref')
| -rw-r--r-- | lispref/ChangeLog | 7 | ||||
| -rw-r--r-- | lispref/modes.texi | 167 |
2 files changed, 94 insertions, 80 deletions
diff --git a/lispref/ChangeLog b/lispref/ChangeLog index 1f5c324bdd1..2d3bd39ccca 100644 --- a/lispref/ChangeLog +++ b/lispref/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2005-04-08 Lute Kamstra <lute@gnu.org> | ||
| 2 | |||
| 3 | * modes.texi (Search-based Fontification): Fix cross references. | ||
| 4 | Use consistent terminology. Document anchored highlighting. | ||
| 5 | |||
| 1 | 2005-04-05 Lute Kamstra <lute@gnu.org> | 6 | 2005-04-05 Lute Kamstra <lute@gnu.org> |
| 2 | 7 | ||
| 3 | * modes.texi (Defining Minor Modes): Document :group keyword | 8 | * modes.texi (Defining Minor Modes): Document :group keyword |
| @@ -2348,7 +2353,7 @@ | |||
| 2348 | 2353 | ||
| 2349 | * files.texi (Changing Files): copy-file allows dir as NEWNAME. | 2354 | * files.texi (Changing Files): copy-file allows dir as NEWNAME. |
| 2350 | (Magic File Names): Specify precedence order of handlers. | 2355 | (Magic File Names): Specify precedence order of handlers. |
| 2351 | o | 2356 | |
| 2352 | * commands.texi (Command Overview): Emacs server runs pre-command-hook | 2357 | * commands.texi (Command Overview): Emacs server runs pre-command-hook |
| 2353 | and post-command-hook. | 2358 | and post-command-hook. |
| 2354 | (Waiting): New calling convention for sit-for. | 2359 | (Waiting): New calling convention for sit-for. |
diff --git a/lispref/modes.texi b/lispref/modes.texi index ecbe39dbb31..b43b22275cc 100644 --- a/lispref/modes.texi +++ b/lispref/modes.texi | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | @c -*-texinfo-*- | 1 | @c -*-texinfo-*- |
| 2 | @c This is part of the GNU Emacs Lisp Reference Manual. | 2 | @c This is part of the GNU Emacs Lisp Reference Manual. |
| 3 | @c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1998, 1999, | 3 | @c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1998, 1999, |
| 4 | @c 2003, 2004, 2005 Free Software Foundation, Inc. | 4 | @c 2003, 2004, 2005 Free Software Foundation, Inc. |
| 5 | @c See the file elisp.texi for copying conditions. | 5 | @c See the file elisp.texi for copying conditions. |
| 6 | @setfilename ../info/modes | 6 | @setfilename ../info/modes |
| @@ -2111,7 +2111,7 @@ processes the elements of @code{font-lock-keywords} one by one, and for | |||
| 2111 | each element, it finds and handles all matches. Ordinarily, once | 2111 | each element, it finds and handles all matches. Ordinarily, once |
| 2112 | part of the text has been fontified already, this cannot be overridden | 2112 | part of the text has been fontified already, this cannot be overridden |
| 2113 | by a subsequent match in the same text; but you can specify different | 2113 | by a subsequent match in the same text; but you can specify different |
| 2114 | behavior using the @var{override} element of a @var{highlighter}. | 2114 | behavior using the @var{override} element of a @var{subexp-highlighter}. |
| 2115 | 2115 | ||
| 2116 | Each element of @code{font-lock-keywords} should have one of these | 2116 | Each element of @code{font-lock-keywords} should have one of these |
| 2117 | forms: | 2117 | forms: |
| @@ -2122,14 +2122,14 @@ Highlight all matches for @var{regexp} using | |||
| 2122 | @code{font-lock-keyword-face}. For example, | 2122 | @code{font-lock-keyword-face}. For example, |
| 2123 | 2123 | ||
| 2124 | @example | 2124 | @example |
| 2125 | ;; @r{Highlight discrete occurrences of @samp{foo}} | 2125 | ;; @r{Highlight occurrences of the word @samp{foo}} |
| 2126 | ;; @r{using @code{font-lock-keyword-face}.} | 2126 | ;; @r{using @code{font-lock-keyword-face}.} |
| 2127 | "\\<foo\\>" | 2127 | "\\<foo\\>" |
| 2128 | @end example | 2128 | @end example |
| 2129 | 2129 | ||
| 2130 | The function @code{regexp-opt} (@pxref{Syntax of Regexps}) is useful for | 2130 | The function @code{regexp-opt} (@pxref{Regexp Functions}) is useful |
| 2131 | calculating optimal regular expressions to match a number of different | 2131 | for calculating optimal regular expressions to match a number of |
| 2132 | keywords. | 2132 | different keywords. |
| 2133 | 2133 | ||
| 2134 | @item @var{function} | 2134 | @item @var{function} |
| 2135 | Find text by calling @var{function}, and highlight the matches | 2135 | Find text by calling @var{function}, and highlight the matches |
| @@ -2146,10 +2146,10 @@ and with point where the previous invocation left it, until | |||
| 2146 | @var{function} fails. On failure, @var{function} need not reset point | 2146 | @var{function} fails. On failure, @var{function} need not reset point |
| 2147 | in any particular way. | 2147 | in any particular way. |
| 2148 | 2148 | ||
| 2149 | @item (@var{matcher} . @var{match}) | 2149 | @item (@var{matcher} . @var{subexp}) |
| 2150 | In this kind of element, @var{matcher} is either a regular | 2150 | In this kind of element, @var{matcher} is either a regular |
| 2151 | expression or a function, as described above. The @sc{cdr}, | 2151 | expression or a function, as described above. The @sc{cdr}, |
| 2152 | @var{match}, specifies which subexpression of @var{matcher} should be | 2152 | @var{subexp}, specifies which subexpression of @var{matcher} should be |
| 2153 | highlighted (instead of the entire text that @var{matcher} matched). | 2153 | highlighted (instead of the entire text that @var{matcher} matched). |
| 2154 | 2154 | ||
| 2155 | @example | 2155 | @example |
| @@ -2159,8 +2159,8 @@ highlighted (instead of the entire text that @var{matcher} matched). | |||
| 2159 | @end example | 2159 | @end example |
| 2160 | 2160 | ||
| 2161 | If you use @code{regexp-opt} to produce the regular expression | 2161 | If you use @code{regexp-opt} to produce the regular expression |
| 2162 | @var{matcher}, then you can use @code{regexp-opt-depth} (@pxref{Syntax | 2162 | @var{matcher}, then you can use @code{regexp-opt-depth} (@pxref{Regexp |
| 2163 | of Regexps}) to calculate the value for @var{match}. | 2163 | Functions}) to calculate the value for @var{subexp}. |
| 2164 | 2164 | ||
| 2165 | @item (@var{matcher} . @var{facespec}) | 2165 | @item (@var{matcher} . @var{facespec}) |
| 2166 | In this kind of element, @var{facespec} is an object which specifies | 2166 | In this kind of element, @var{facespec} is an object which specifies |
| @@ -2173,37 +2173,39 @@ is a Lisp variable (a symbol), whose value should be a face name. | |||
| 2173 | ("fubar" . fubar-face) | 2173 | ("fubar" . fubar-face) |
| 2174 | @end example | 2174 | @end example |
| 2175 | 2175 | ||
| 2176 | However, @var{facespec} can also be a list of the form | 2176 | However, @var{facespec} can also be a list of the form: |
| 2177 | 2177 | ||
| 2178 | @example | 2178 | @example |
| 2179 | (face @var{face} @var{prop1} @var{val1} @var{prop2} @var{val2}@dots{}) | 2179 | (face @var{face} @var{prop1} @var{val1} @var{prop2} @var{val2}@dots{}) |
| 2180 | @end example | 2180 | @end example |
| 2181 | 2181 | ||
| 2182 | to specify various text properties to put on the text that matches. | 2182 | to specify the face @var{face} and various additional text properties |
| 2183 | If you do this, be sure to add the other text property names that you | 2183 | to put on the text that matches. If you do this, be sure to add the |
| 2184 | set in this way to the value of @code{font-lock-extra-managed-props} | 2184 | other text property names that you set in this way to the value of |
| 2185 | so that the properties will also be cleared out when they are no longer | 2185 | @code{font-lock-extra-managed-props} so that the properties will also |
| 2186 | appropriate. | 2186 | be cleared out when they are no longer appropriate. Alternatively, |
| 2187 | you can set the variable @code{font-lock-unfontify-region-function} to | ||
| 2188 | a function that clears these properties. | ||
| 2187 | 2189 | ||
| 2188 | @item (@var{matcher} . @var{highlighter}) | 2190 | @item (@var{matcher} . @var{subexp-highlighter}) |
| 2189 | In this kind of element, @var{highlighter} is a list | 2191 | In this kind of element, @var{subexp-highlighter} is a list |
| 2190 | which specifies how to highlight matches found by @var{matcher}. | 2192 | which specifies how to highlight matches found by @var{matcher}. |
| 2191 | It has the form | 2193 | It has the form: |
| 2192 | 2194 | ||
| 2193 | @example | 2195 | @example |
| 2194 | (@var{subexp} @var{facespec} @var{override} @var{laxmatch}) | 2196 | (@var{subexp} @var{facespec} [[@var{override} [@var{laxmatch}]]) |
| 2195 | @end example | 2197 | @end example |
| 2196 | 2198 | ||
| 2197 | The @sc{car}, @var{subexp}, is an integer specifying which subexpression | 2199 | The @sc{car}, @var{subexp}, is an integer specifying which subexpression |
| 2198 | of the match to fontify (0 means the entire matching text). The second | 2200 | of the match to fontify (0 means the entire matching text). The second |
| 2199 | subelement, @var{facespec}, specifies the face, as described above. | 2201 | subelement, @var{facespec}, specifies the face, as described above. |
| 2200 | 2202 | ||
| 2201 | The last two values in @var{highlighter}, @var{override} and | 2203 | The last two values in @var{subexp-highlighter}, @var{override} and |
| 2202 | @var{laxmatch}, are flags. If @var{override} is @code{t}, this | 2204 | @var{laxmatch}, are optional flags. If @var{override} is @code{t}, |
| 2203 | element can override existing fontification made by previous elements | 2205 | this element can override existing fontification made by previous |
| 2204 | of @code{font-lock-keywords}. If it is @code{keep}, then each | 2206 | elements of @code{font-lock-keywords}. If it is @code{keep}, then |
| 2205 | character is fontified if it has not been fontified already by some | 2207 | each character is fontified if it has not been fontified already by |
| 2206 | other element. If it is @code{prepend}, the face specified by | 2208 | some other element. If it is @code{prepend}, the face specified by |
| 2207 | @var{facespec} is added to the beginning of the @code{font-lock-face} | 2209 | @var{facespec} is added to the beginning of the @code{font-lock-face} |
| 2208 | property. If it is @code{append}, the face is added to the end of the | 2210 | property. If it is @code{append}, the face is added to the end of the |
| 2209 | @code{font-lock-face} property. | 2211 | @code{font-lock-face} property. |
| @@ -2219,8 +2221,8 @@ terminates search-based fontification. | |||
| 2219 | Here are some examples of elements of this kind, and what they do: | 2221 | Here are some examples of elements of this kind, and what they do: |
| 2220 | 2222 | ||
| 2221 | @smallexample | 2223 | @smallexample |
| 2222 | ;; @r{Highlight occurrences of either @samp{foo} or @samp{bar},} | 2224 | ;; @r{Highlight occurrences of either @samp{foo} or @samp{bar}, using} |
| 2223 | ;; @r{using @code{foo-bar-face}, even if they have already been highlighted.} | 2225 | ;; @r{@code{foo-bar-face}, even if they have already been highlighted.} |
| 2224 | ;; @r{@code{foo-bar-face} should be a variable whose value is a face.} | 2226 | ;; @r{@code{foo-bar-face} should be a variable whose value is a face.} |
| 2225 | ("foo\\|bar" 0 foo-bar-face t) | 2227 | ("foo\\|bar" 0 foo-bar-face t) |
| 2226 | 2228 | ||
| @@ -2230,64 +2232,71 @@ Here are some examples of elements of this kind, and what they do: | |||
| 2230 | (fubar-match 1 fubar-face) | 2232 | (fubar-match 1 fubar-face) |
| 2231 | @end smallexample | 2233 | @end smallexample |
| 2232 | 2234 | ||
| 2233 | @item (@var{matcher} @var{highlighters}@dots{}) | 2235 | @item (@var{matcher} . @var{anchored-highlighter}) |
| 2234 | This sort of element specifies several @var{highlighter} lists for a | 2236 | In this kind of element, @var{anchored-highlighter} specifies how to |
| 2235 | single @var{matcher}. In order for this to be useful, each | 2237 | highlight text that follows a match found by @var{matcher}. So a |
| 2236 | @var{highlighter} should have a different value of @var{subexp}; that is, | 2238 | match found by @var{matcher} acts as the anchor for further searches |
| 2237 | each one should apply to a different subexpression of @var{matcher}. | 2239 | specified by @var{anchored-highlighter}. @var{anchored-highlighter} |
| 2240 | is a list of the following form: | ||
| 2238 | 2241 | ||
| 2239 | @ignore | 2242 | @example |
| 2240 | @item (@var{matcher} . @var{anchored}) | 2243 | (@var{anchored-matcher} @var{pre-form} @var{post-form} |
| 2241 | In this kind of element, @var{anchored} acts much like a | 2244 | @var{subexp-highlighters}@dots{}) |
| 2242 | @var{highlighter}, but it is more complex and can specify multiple | 2245 | @end example |
| 2243 | successive searches. | ||
| 2244 | 2246 | ||
| 2245 | For highlighting single items, typically only @var{highlighter} is | 2247 | Here, @var{anchored-matcher}, like @var{matcher}, is either a regular |
| 2246 | required. However, if an item or (typically) items are to be | 2248 | expression or a function. After a match of @var{matcher} is found, |
| 2247 | highlighted following the instance of another item (the anchor) then | 2249 | point is at the end of the match. Now, Font Lock evaluates the form |
| 2248 | @var{anchored} may be required. | 2250 | @var{pre-form}. Then it searches for matches of |
| 2251 | @var{anchored-matcher} and uses @var{subexp-highlighters} to highlight | ||
| 2252 | these. A @var{subexp-highlighter} is as described above. Finally, | ||
| 2253 | Font Lock evaluates @var{post-form}. | ||
| 2254 | |||
| 2255 | The forms @var{pre-form} and @var{post-form} can be used to initialize | ||
| 2256 | before, and cleanup after, @var{anchored-matcher} is used. Typically, | ||
| 2257 | @var{pre-form} is used to move point to some position relative to the | ||
| 2258 | match of @var{matcher}, before starting with @var{anchored-matcher}. | ||
| 2259 | @var{post-form} might be used to move back, before resuming with | ||
| 2260 | @var{matcher}. | ||
| 2261 | |||
| 2262 | After Font Lock evaluates @var{pre-form}, it does not search for | ||
| 2263 | @var{anchored-matcher} beyond the end of the line. However, if | ||
| 2264 | @var{pre-form} returns a buffer position that is greater than the | ||
| 2265 | position of point after @var{pre-form} is evaluated, then the position | ||
| 2266 | returned by @var{pre-form} is used as the limit of the search instead. | ||
| 2267 | It is generally a bad idea to return a position greater than the end | ||
| 2268 | of the line; in other words, the @var{anchored-matcher} search should | ||
| 2269 | not span lines. | ||
| 2249 | 2270 | ||
| 2250 | It has this format: | 2271 | For example, |
| 2251 | 2272 | ||
| 2252 | @example | 2273 | @smallexample |
| 2253 | (@var{submatcher} @var{pre-match-form} @var{post-match-form} @var{highlighters}@dots{}) | 2274 | ;; @r{Highlight occurrences of the word @samp{item} following} |
| 2254 | @end example | 2275 | ;; @r{an occurrence of the word @samp{anchor} (on the same line)} |
| 2276 | ;; @r{in the value of @code{item-face}.} | ||
| 2277 | ("\\<anchor\\>" "\\<item\\>" nil nil (0 item-face)) | ||
| 2278 | @end smallexample | ||
| 2255 | 2279 | ||
| 2256 | @c I can't parse this text -- rms | 2280 | Here, @var{pre-form} and @var{post-form} are @code{nil}. Therefore |
| 2257 | where @var{submatcher} is much like @var{matcher}, with one | 2281 | searching for @samp{item} starts at the end of the match of |
| 2258 | exception---see below. @var{pre-match-form} and @var{post-match-form} | 2282 | @samp{anchor}, and searching for subsequent instances of @samp{anchor} |
| 2259 | are evaluated before the first, and after the last, instance | 2283 | resumes from where searching for @samp{item} concluded. |
| 2260 | @var{anchored}'s @var{submatcher} is used. Therefore they can be used | ||
| 2261 | to initialize before, and cleanup after, @var{submatcher} is used. | ||
| 2262 | Typically, @var{pre-match-form} is used to move to some position | ||
| 2263 | relative to the original @var{submatcher}, before starting with | ||
| 2264 | @var{anchored}'s @var{submatcher}. @var{post-match-form} might be used | ||
| 2265 | to move, before resuming with @var{anchored}'s parent's @var{matcher}. | ||
| 2266 | 2284 | ||
| 2267 | For example, an element of the form highlights (if not already highlighted): | 2285 | @item (@var{matcher} @var{highlighters}@dots{}) |
| 2286 | This sort of element specifies several @var{highlighter} lists for a | ||
| 2287 | single @var{matcher}. A @var{highlighter} list can be of the type | ||
| 2288 | @var{subexp-highlighter} or @var{anchored-highlighter} as described | ||
| 2289 | above. | ||
| 2268 | 2290 | ||
| 2269 | @example | 2291 | For example, |
| 2270 | ("\\<anchor\\>" (0 anchor-face) ("\\<item\\>" nil nil (0 item-face))) | ||
| 2271 | @end example | ||
| 2272 | 2292 | ||
| 2273 | Discrete occurrences of @samp{anchor} in the value of | 2293 | @smallexample |
| 2274 | @code{anchor-face}, and subsequent discrete occurrences of @samp{item} | 2294 | ;; @r{Highlight occurrences of the word @samp{anchor} in the value} |
| 2275 | (on the same line) in the value of @code{item-face}. (Here | 2295 | ;; @r{of @code{anchor-face}, and subsequent occurrences of the word} |
| 2276 | @var{pre-match-form} and @var{post-match-form} are @code{nil}. | 2296 | ;; @r{@samp{item} (on the same line) in the value of @code{item-face}.} |
| 2277 | Therefore @samp{item} is initially searched for starting from the end of | 2297 | ("\\<anchor\\>" (0 anchor-face) |
| 2278 | the match of @samp{anchor}, and searching for subsequent instance of | 2298 | ("\\<item\\>" nil nil (0 item-face))) |
| 2279 | @samp{anchor} resumes from where searching for @samp{item} concluded.) | 2299 | @end smallexample |
| 2280 | |||
| 2281 | The above-mentioned exception is as follows. The limit of the | ||
| 2282 | @var{submatcher} search defaults to the end of the line after | ||
| 2283 | @var{pre-match-form} is evaluated. However, if @var{pre-match-form} | ||
| 2284 | returns a position greater than the position after @var{pre-match-form} | ||
| 2285 | is evaluated, that position is used as the limit of the search. It is | ||
| 2286 | generally a bad idea to return a position greater than the end of the | ||
| 2287 | line; in other words, the @var{submatcher} search should not span lines. | ||
| 2288 | |||
| 2289 | @item (@var{matcher} @var{highlighters-or-anchoreds} ...) | ||
| 2290 | @end ignore | ||
| 2291 | 2300 | ||
| 2292 | @item (eval . @var{form}) | 2301 | @item (eval . @var{form}) |
| 2293 | Here @var{form} is an expression to be evaluated the first time | 2302 | Here @var{form} is an expression to be evaluated the first time |
| @@ -2301,7 +2310,7 @@ to match text which spans lines; this does not work reliably. While | |||
| 2301 | updating when you edit the buffer does not, since it considers text one | 2310 | updating when you edit the buffer does not, since it considers text one |
| 2302 | line at a time. If you have patterns that typically only span one | 2311 | line at a time. If you have patterns that typically only span one |
| 2303 | line but can occasionally span two or three, such as | 2312 | line but can occasionally span two or three, such as |
| 2304 | @samp{<title>...</title>}, you can ask font-lock to be more careful by | 2313 | @samp{<title>...</title>}, you can ask Font Lock to be more careful by |
| 2305 | setting @code{font-lock-multiline} to @code{t}. But it still will not | 2314 | setting @code{font-lock-multiline} to @code{t}. But it still will not |
| 2306 | work in all cases. | 2315 | work in all cases. |
| 2307 | 2316 | ||