diff options
| author | Chong Yidong | 2012-02-16 14:04:38 +0800 |
|---|---|---|
| committer | Chong Yidong | 2012-02-16 14:04:38 +0800 |
| commit | f700caa38bb4972bec481cca3af0778706b02498 (patch) | |
| tree | c4dfc10309448fadf463178334b9b3f984b746a3 | |
| parent | 60236b0dca0416202da5c3e39564b85b2ae3c9fa (diff) | |
| download | emacs-f700caa38bb4972bec481cca3af0778706b02498.tar.gz emacs-f700caa38bb4972bec481cca3af0778706b02498.zip | |
Updates to Font Lock docs in Lisp manual.
* doc/lispref/modes.texi (Minor Modes): Update how mode commands should treat
arguments now.
(Mode Line Basics): Clarify force-mode-line-update.
(Mode Line Top): Note that the example is not realistic.
(Mode Line Variables, Mode Line Data, %-Constructs, Header Lines)
(Emulating Mode Line): Use "mode line" instead of "mode-line", and
"mode line construct" instead of "mode line specification".
(Syntactic Font Lock): Remove mention of obsolete variable
font-lock-syntactic-keywords.
(Setting Syntax Properties): Node deleted.
(Font Lock Mode): Note that Font Lock mode is a minor mode.
(Font Lock Basics): Note that syntactic fontification falls back
on `syntax-table'.
(Search-based Fontification): Emphasize that font-lock-keywords
should not be set directly.
(Faces for Font Lock): Avoid some confusing terminology.
(Syntactic Font Lock): Minor clarifications.
| -rw-r--r-- | doc/lispref/ChangeLog | 24 | ||||
| -rw-r--r-- | doc/lispref/elisp.texi | 2 | ||||
| -rw-r--r-- | doc/lispref/modes.texi | 626 | ||||
| -rw-r--r-- | doc/lispref/syntax.texi | 4 | ||||
| -rw-r--r-- | doc/lispref/vol1.texi | 2 | ||||
| -rw-r--r-- | doc/lispref/vol2.texi | 2 |
6 files changed, 302 insertions, 358 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog index 1e369f3b627..fb58e04ac53 100644 --- a/doc/lispref/ChangeLog +++ b/doc/lispref/ChangeLog | |||
| @@ -1,3 +1,23 @@ | |||
| 1 | 2012-02-16 Chong Yidong <cyd@gnu.org> | ||
| 2 | |||
| 3 | * modes.texi (Minor Modes): Update how mode commands should treat | ||
| 4 | arguments now. | ||
| 5 | (Mode Line Basics): Clarify force-mode-line-update. | ||
| 6 | (Mode Line Top): Note that the example is not realistic. | ||
| 7 | (Mode Line Variables, Mode Line Data, %-Constructs, Header Lines) | ||
| 8 | (Emulating Mode Line): Use "mode line" instead of "mode-line", and | ||
| 9 | "mode line construct" instead of "mode line specification". | ||
| 10 | (Syntactic Font Lock): Remove mention of obsolete variable | ||
| 11 | font-lock-syntactic-keywords. | ||
| 12 | (Setting Syntax Properties): Node deleted. | ||
| 13 | (Font Lock Mode): Note that Font Lock mode is a minor mode. | ||
| 14 | (Font Lock Basics): Note that syntactic fontification falls back | ||
| 15 | on `syntax-table'. | ||
| 16 | (Search-based Fontification): Emphasize that font-lock-keywords | ||
| 17 | should not be set directly. | ||
| 18 | (Faces for Font Lock): Avoid some confusing terminology. | ||
| 19 | (Syntactic Font Lock): Minor clarifications. | ||
| 20 | |||
| 1 | 2012-02-15 Chong Yidong <cyd@gnu.org> | 21 | 2012-02-15 Chong Yidong <cyd@gnu.org> |
| 2 | 22 | ||
| 3 | * minibuf.texi (Basic Completion): Define "completion table". | 23 | * minibuf.texi (Basic Completion): Define "completion table". |
| @@ -9,6 +29,10 @@ | |||
| 9 | (Setting Hooks): Update minor mode usage example. | 29 | (Setting Hooks): Update minor mode usage example. |
| 10 | (Major Mode Conventions): Note that completion-at-point-functions | 30 | (Major Mode Conventions): Note that completion-at-point-functions |
| 11 | should be altered locally. Add xref to Completion in Buffers. | 31 | should be altered locally. Add xref to Completion in Buffers. |
| 32 | Remove duplicate tip about auto-mode-alist. | ||
| 33 | (Minor Modes): Rewrite introduction. | ||
| 34 | (Minor Mode Conventions): Copyedits. Don't recommend | ||
| 35 | variable-only minor modes since few minor modes are like that. | ||
| 12 | 36 | ||
| 13 | 2012-02-15 Glenn Morris <rgm@gnu.org> | 37 | 2012-02-15 Glenn Morris <rgm@gnu.org> |
| 14 | 38 | ||
diff --git a/doc/lispref/elisp.texi b/doc/lispref/elisp.texi index 5dd8994f439..2719a024ac6 100644 --- a/doc/lispref/elisp.texi +++ b/doc/lispref/elisp.texi | |||
| @@ -814,8 +814,6 @@ Font Lock Mode | |||
| 814 | contents can also specify how to fontify it. | 814 | contents can also specify how to fontify it. |
| 815 | * Faces for Font Lock:: Special faces specifically for Font Lock. | 815 | * Faces for Font Lock:: Special faces specifically for Font Lock. |
| 816 | * Syntactic Font Lock:: Fontification based on syntax tables. | 816 | * Syntactic Font Lock:: Fontification based on syntax tables. |
| 817 | * Setting Syntax Properties:: Defining character syntax based on context | ||
| 818 | using the Font Lock mechanism. | ||
| 819 | * Multiline Font Lock:: How to coerce Font Lock into properly | 817 | * Multiline Font Lock:: How to coerce Font Lock into properly |
| 820 | highlighting multiline constructs. | 818 | highlighting multiline constructs. |
| 821 | 819 | ||
diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi index 94ae767586b..c3356ef882a 100644 --- a/doc/lispref/modes.texi +++ b/doc/lispref/modes.texi | |||
| @@ -464,11 +464,6 @@ more buffer-local entries to the special hook | |||
| 464 | @code{completion-at-point-functions}. @xref{Completion in Buffers}. | 464 | @code{completion-at-point-functions}. @xref{Completion in Buffers}. |
| 465 | 465 | ||
| 466 | @item | 466 | @item |
| 467 | Use @code{defvar} or @code{defcustom} to set mode-related variables, so | ||
| 468 | that they are not reinitialized if they already have a value. (Such | ||
| 469 | reinitialization could discard customizations made by the user.) | ||
| 470 | |||
| 471 | @item | ||
| 472 | @cindex buffer-local variables in modes | 467 | @cindex buffer-local variables in modes |
| 473 | To make a buffer-local binding for an Emacs customization variable, use | 468 | To make a buffer-local binding for an Emacs customization variable, use |
| 474 | @code{make-local-variable} in the major mode command, not | 469 | @code{make-local-variable} in the major mode command, not |
| @@ -546,15 +541,13 @@ not autoload the mode command, it is sufficient to add the element in | |||
| 546 | the file that contains the mode definition. | 541 | the file that contains the mode definition. |
| 547 | 542 | ||
| 548 | @item | 543 | @item |
| 549 | In the comments that document the file, you should provide a sample | ||
| 550 | @code{autoload} form and an example of how to add to | ||
| 551 | @code{auto-mode-alist}, that users can include in their init files | ||
| 552 | (@pxref{Init File}). | ||
| 553 | |||
| 554 | @item | ||
| 555 | @cindex mode loading | 544 | @cindex mode loading |
| 556 | The top-level forms in the file defining the mode should be written so | 545 | The top-level forms in the file defining the mode should be written so |
| 557 | that they may be evaluated more than once without adverse consequences. | 546 | that they may be evaluated more than once without adverse consequences. |
| 547 | For instance, use @code{defvar} or @code{defcustom} to set mode-related | ||
| 548 | variables, so that they are not reinitialized if they already have a | ||
| 549 | value (@pxref{Defining Variables}). | ||
| 550 | |||
| 558 | @end itemize | 551 | @end itemize |
| 559 | 552 | ||
| 560 | @node Auto Major Mode | 553 | @node Auto Major Mode |
| @@ -1201,27 +1194,20 @@ if that value is non-nil." | |||
| 1201 | @section Minor Modes | 1194 | @section Minor Modes |
| 1202 | @cindex minor mode | 1195 | @cindex minor mode |
| 1203 | 1196 | ||
| 1204 | A @dfn{minor mode} provides features that users may enable or disable | 1197 | A @dfn{minor mode} provides optional features that users may enable or |
| 1205 | independently of the choice of major mode. Minor modes can be enabled | 1198 | disable independently of the choice of major mode. Minor modes can be |
| 1206 | individually or in combination. Minor modes would be better named | 1199 | enabled individually or in combination. |
| 1207 | ``generally available, optional feature modes,'' except that such a name | ||
| 1208 | would be unwieldy. | ||
| 1209 | |||
| 1210 | A minor mode is not usually meant as a variation of a single major mode. | ||
| 1211 | Usually they are general and can apply to many major modes. For | ||
| 1212 | example, Auto Fill mode works with any major mode that permits text | ||
| 1213 | insertion. To be general, a minor mode must be effectively independent | ||
| 1214 | of the things major modes do. | ||
| 1215 | 1200 | ||
| 1216 | A minor mode is often much more difficult to implement than a major | 1201 | Most minor modes implement features that are independent of the major |
| 1217 | mode. One reason is that you should be able to activate and deactivate | 1202 | mode, and can thus be used with most major modes. For example, Auto |
| 1218 | minor modes in any order. A minor mode should be able to have its | 1203 | Fill mode works with any major mode that permits text insertion. A few |
| 1219 | desired effect regardless of the major mode and regardless of the other | 1204 | minor modes, however, are specific to a particular major mode. For |
| 1220 | minor modes in effect. | 1205 | example, Diff Auto Refine mode is a minor mode that is intended to be |
| 1206 | used only with Diff mode. | ||
| 1221 | 1207 | ||
| 1222 | Often the biggest problem in implementing a minor mode is finding a | 1208 | Ideally, a minor mode should have its desired effect regardless of the |
| 1223 | way to insert the necessary hook into the rest of Emacs. Minor mode | 1209 | other minor modes in effect. It should be possible to activate and |
| 1224 | keymaps make this easier than it used to be. | 1210 | deactivate minor modes in any order. |
| 1225 | 1211 | ||
| 1226 | @defvar minor-mode-list | 1212 | @defvar minor-mode-list |
| 1227 | The value of this variable is a list of all minor mode commands. | 1213 | The value of this variable is a list of all minor mode commands. |
| @@ -1239,60 +1225,76 @@ The value of this variable is a list of all minor mode commands. | |||
| 1239 | @cindex conventions for writing minor modes | 1225 | @cindex conventions for writing minor modes |
| 1240 | 1226 | ||
| 1241 | There are conventions for writing minor modes just as there are for | 1227 | There are conventions for writing minor modes just as there are for |
| 1242 | major modes. Several of the major mode conventions apply to minor | 1228 | major modes. These conventions are described below. The easiest way to |
| 1243 | modes as well: those regarding the name of the mode initialization | 1229 | follow them is to use the macro @code{define-minor-mode}. |
| 1244 | function, the names of global symbols, the use of a hook at the end of | 1230 | @xref{Defining Minor Modes}. |
| 1245 | the initialization function, and the use of keymaps and other tables. | ||
| 1246 | |||
| 1247 | In addition, there are several conventions that are specific to | ||
| 1248 | minor modes. (The easiest way to follow all the conventions is to use | ||
| 1249 | the macro @code{define-minor-mode}; @ref{Defining Minor Modes}.) | ||
| 1250 | 1231 | ||
| 1251 | @itemize @bullet | 1232 | @itemize @bullet |
| 1252 | @item | 1233 | @item |
| 1253 | @cindex mode variable | 1234 | @cindex mode variable |
| 1254 | Make a variable whose name ends in @samp{-mode} to control the minor | 1235 | Define a variable whose name ends in @samp{-mode}. We call this the |
| 1255 | mode. We call this the @dfn{mode variable}. The minor mode command | 1236 | @dfn{mode variable}. The minor mode command should set this variable. |
| 1256 | should set this variable (@code{nil} to disable; anything else to | 1237 | The value will be @code{nil} is the mode is disabled, and non-@code{nil} |
| 1257 | enable). | 1238 | if the mode is enabled. The variable should be buffer-local if the |
| 1258 | 1239 | minor mode is buffer-local. | |
| 1259 | If possible, implement the mode so that setting the variable | ||
| 1260 | automatically enables or disables the mode. Then the minor mode command | ||
| 1261 | does not need to do anything except set the variable. | ||
| 1262 | 1240 | ||
| 1263 | This variable is used in conjunction with the @code{minor-mode-alist} to | 1241 | This variable is used in conjunction with the @code{minor-mode-alist} to |
| 1264 | display the minor mode name in the mode line. It can also enable | 1242 | display the minor mode name in the mode line. It also determines |
| 1265 | or disable a minor mode keymap. Individual commands or hooks can also | 1243 | whether the minor mode keymap is active, via @code{minor-mode-map-alist} |
| 1266 | check the variable's value. | 1244 | (@pxref{Controlling Active Maps}). Individual commands or hooks can |
| 1267 | 1245 | also check its value. | |
| 1268 | If you want the minor mode to be enabled separately in each buffer, | ||
| 1269 | make the variable buffer-local. | ||
| 1270 | 1246 | ||
| 1271 | @item | 1247 | @item |
| 1272 | Define a command whose name is the same as the mode variable. | 1248 | Define a command, called the @dfn{mode command}, whose name is the same |
| 1273 | Its job is to enable and disable the mode by setting the variable. | 1249 | as the mode variable. Its job is to set the value of the mode variable, |
| 1250 | plus anything else that needs to be done to actually enable or disable | ||
| 1251 | the mode's features. | ||
| 1274 | 1252 | ||
| 1275 | The command should accept one optional argument. If the argument is | 1253 | The mode command should accept one optional argument. If called |
| 1276 | @code{nil}, it should toggle the mode (turn it on if it is off, and | 1254 | interactively with no prefix argument, it should toggle the mode |
| 1277 | off if it is on). It should turn the mode on if the argument is a | 1255 | (i.e.@: enable if it is disabled, and disable if it is enabled). If |
| 1278 | positive integer, the symbol @code{t}, or a list whose @sc{car} is one | 1256 | called interactively with a prefix argument, it should enable the mode |
| 1279 | of those. It should turn the mode off if the argument is a negative | 1257 | if the argument is positive and disable it otherwise. |
| 1280 | integer or zero, the symbol @code{-}, or a list whose @sc{car} is a | ||
| 1281 | negative integer or zero. The meaning of other arguments is not | ||
| 1282 | specified. | ||
| 1283 | 1258 | ||
| 1284 | Here is an example taken from the definition of @code{transient-mark-mode}. | 1259 | If the mode command is called from Lisp (i.e.@: non-interactively), it |
| 1285 | It shows the use of @code{transient-mark-mode} as a variable that enables or | 1260 | should enable the mode if the argument is omitted or @code{nil}; it |
| 1286 | disables the mode's behavior, and also shows the proper way to toggle, | 1261 | should toggle the mode if the argument is the symbol @code{toggle}; |
| 1287 | enable or disable the minor mode based on the raw prefix argument value. | 1262 | otherwise it should treat the argument in the same way as for an |
| 1263 | interactive call with a numeric prefix argument, as described above. | ||
| 1288 | 1264 | ||
| 1289 | @smallexample | 1265 | The following example shows how to implement this behavior (it is |
| 1290 | @group | 1266 | similar to the code generated by the @code{define-minor-mode} macro): |
| 1291 | (setq transient-mark-mode | 1267 | |
| 1292 | (if (null arg) (not transient-mark-mode) | 1268 | @example |
| 1293 | (> (prefix-numeric-value arg) 0))) | 1269 | (interactive (list (or current-prefix-arg 'toggle))) |
| 1294 | @end group | 1270 | (let ((enable (if (eq arg 'toggle) |
| 1295 | @end smallexample | 1271 | (not foo-mode) ; @r{this mode's mode variable} |
| 1272 | (> (prefix-numeric-value arg) 0)))) | ||
| 1273 | (if enable | ||
| 1274 | @var{do-enable} | ||
| 1275 | @var{do-disable})) | ||
| 1276 | @end example | ||
| 1277 | |||
| 1278 | The reason for this somewhat complex behavior is that it lets users | ||
| 1279 | easily toggle the minor mode interactively, and also lets the minor mode | ||
| 1280 | be easily enabled in a mode hook, like this: | ||
| 1281 | |||
| 1282 | @example | ||
| 1283 | (add-hook 'text-mode-hook 'foo-mode) | ||
| 1284 | @end example | ||
| 1285 | |||
| 1286 | @noindent | ||
| 1287 | This behaves correctly whether or not @code{foo-mode} was already | ||
| 1288 | enabled, since the @code{foo-mode} mode command unconditionally enables | ||
| 1289 | the minor mode when it is called from Lisp with no argument. Disabling | ||
| 1290 | a minor mode in a mode hook is a little uglier: | ||
| 1291 | |||
| 1292 | @example | ||
| 1293 | (add-hook 'text-mode-hook (lambda () (foo-mode -1))) | ||
| 1294 | @end example | ||
| 1295 | |||
| 1296 | @noindent | ||
| 1297 | However, this is not very commonly done. | ||
| 1296 | 1298 | ||
| 1297 | @item | 1299 | @item |
| 1298 | Add an element to @code{minor-mode-alist} for each minor mode | 1300 | Add an element to @code{minor-mode-alist} for each minor mode |
| @@ -1315,8 +1317,7 @@ check for an existing element, to avoid duplication. For example: | |||
| 1315 | @smallexample | 1317 | @smallexample |
| 1316 | @group | 1318 | @group |
| 1317 | (unless (assq 'leif-mode minor-mode-alist) | 1319 | (unless (assq 'leif-mode minor-mode-alist) |
| 1318 | (setq minor-mode-alist | 1320 | (push '(leif-mode " Leif") minor-mode-alist)) |
| 1319 | (cons '(leif-mode " Leif") minor-mode-alist))) | ||
| 1320 | @end group | 1321 | @end group |
| 1321 | @end smallexample | 1322 | @end smallexample |
| 1322 | 1323 | ||
| @@ -1330,25 +1331,24 @@ or like this, using @code{add-to-list} (@pxref{List Variables}): | |||
| 1330 | @end smallexample | 1331 | @end smallexample |
| 1331 | @end itemize | 1332 | @end itemize |
| 1332 | 1333 | ||
| 1333 | Global minor modes distributed with Emacs should if possible support | 1334 | In addition, several major mode conventions apply to minor modes as |
| 1334 | enabling and disabling via Custom (@pxref{Customization}). To do this, | 1335 | well: those regarding the names of global symbols, the use of a hook at |
| 1335 | the first step is to define the mode variable with @code{defcustom}, and | 1336 | the end of the initialization function, and the use of keymaps and other |
| 1336 | specify @code{:type 'boolean}. | 1337 | tables. |
| 1337 | 1338 | ||
| 1338 | If just setting the variable is not sufficient to enable the mode, you | 1339 | The minor mode should, if possible, support enabling and disabling via |
| 1340 | Custom (@pxref{Customization}). To do this, the mode variable should be | ||
| 1341 | defined with @code{defcustom}, usually with @code{:type 'boolean}. If | ||
| 1342 | just setting the variable is not sufficient to enable the mode, you | ||
| 1339 | should also specify a @code{:set} method which enables the mode by | 1343 | should also specify a @code{:set} method which enables the mode by |
| 1340 | invoking the mode command. Note in the variable's documentation string that | 1344 | invoking the mode command. Note in the variable's documentation string |
| 1341 | setting the variable other than via Custom may not take effect. | 1345 | that setting the variable other than via Custom may not take effect. |
| 1342 | 1346 | Also, mark the definition with an autoload cookie (@pxref{autoload | |
| 1343 | Also mark the definition with an autoload cookie (@pxref{autoload cookie}), | 1347 | cookie}), and specify a @code{:require} so that customizing the variable |
| 1344 | and specify a @code{:require} so that customizing the variable will load | 1348 | will load the library that defines the mode. For example: |
| 1345 | the library that defines the mode. This will copy suitable definitions | ||
| 1346 | into @file{loaddefs.el} so that users can use @code{customize-option} to | ||
| 1347 | enable the mode. For example: | ||
| 1348 | 1349 | ||
| 1349 | @smallexample | 1350 | @smallexample |
| 1350 | @group | 1351 | @group |
| 1351 | |||
| 1352 | ;;;###autoload | 1352 | ;;;###autoload |
| 1353 | (defcustom msb-mode nil | 1353 | (defcustom msb-mode nil |
| 1354 | "Toggle msb-mode. | 1354 | "Toggle msb-mode. |
| @@ -1578,7 +1578,7 @@ mode's hook. | |||
| 1578 | 1578 | ||
| 1579 | 1579 | ||
| 1580 | @node Mode Line Format | 1580 | @node Mode Line Format |
| 1581 | @section Mode-Line Format | 1581 | @section Mode Line Format |
| 1582 | @cindex mode line | 1582 | @cindex mode line |
| 1583 | 1583 | ||
| 1584 | Each Emacs window (aside from minibuffer windows) typically has a mode | 1584 | Each Emacs window (aside from minibuffer windows) typically has a mode |
| @@ -1608,61 +1608,59 @@ minor modes. | |||
| 1608 | @node Mode Line Basics | 1608 | @node Mode Line Basics |
| 1609 | @subsection Mode Line Basics | 1609 | @subsection Mode Line Basics |
| 1610 | 1610 | ||
| 1611 | @code{mode-line-format} is a buffer-local variable that holds a | 1611 | The contents of each mode line are specified by the buffer-local |
| 1612 | @dfn{mode line construct}, a kind of template, which controls what is | 1612 | variable @code{mode-line-format} (@pxref{Mode Line Top}). This variable |
| 1613 | displayed on the mode line of the current buffer. The value of | 1613 | holds a @dfn{mode line construct}: a template that controls what is |
| 1614 | @code{header-line-format} specifies the buffer's header line in the | 1614 | displayed on the buffer's mode line. The value of |
| 1615 | same way. All windows for the same buffer use the same | 1615 | @code{header-line-format} specifies the buffer's header line in the same |
| 1616 | way. All windows for the same buffer use the same | ||
| 1616 | @code{mode-line-format} and @code{header-line-format}. | 1617 | @code{mode-line-format} and @code{header-line-format}. |
| 1617 | 1618 | ||
| 1618 | For efficiency, Emacs does not continuously recompute the mode | 1619 | For efficiency, Emacs does not continuously recompute each window's |
| 1619 | line and header line of a window. It does so when circumstances | 1620 | mode line and header line. It does so when circumstances appear to call |
| 1620 | appear to call for it---for instance, if you change the window | 1621 | for it---for instance, if you change the window configuration, switch |
| 1621 | configuration, switch buffers, narrow or widen the buffer, scroll, or | 1622 | buffers, narrow or widen the buffer, scroll, or modify the buffer. If |
| 1622 | change the buffer's modification status. If you modify any of the | 1623 | you alter any of the variables referenced by @code{mode-line-format} or |
| 1623 | variables referenced by @code{mode-line-format} (@pxref{Mode Line | 1624 | @code{header-line-format} (@pxref{Mode Line Variables}), or any other |
| 1624 | Variables}), or any other variables and data structures that affect | 1625 | data structures that affect how text is displayed (@pxref{Display}), you |
| 1625 | how text is displayed (@pxref{Display}), you may want to force an | 1626 | should use the function @code{force-mode-line-update} to update the |
| 1626 | update of the mode line so as to display the new information or | 1627 | display. |
| 1627 | display it in the new way. | ||
| 1628 | 1628 | ||
| 1629 | @defun force-mode-line-update &optional all | 1629 | @defun force-mode-line-update &optional all |
| 1630 | Force redisplay of the current buffer's mode line and header line. | 1630 | This function forces Emacs to update the current buffer's mode line and |
| 1631 | The next redisplay will update the mode line and header line based on | 1631 | header line, based on the latest values of all relevant variables, |
| 1632 | the latest values of all relevant variables. With optional | 1632 | during its next redisplay cycle. If the optional argument @var{all} is |
| 1633 | non-@code{nil} @var{all}, force redisplay of all mode lines and header | 1633 | non-@code{nil}, it forces an update for all mode lines and header lines. |
| 1634 | lines. | 1634 | |
| 1635 | 1635 | This function also forces an update of the menu bar and frame title. | |
| 1636 | This function also forces recomputation of the menu bar menus | ||
| 1637 | and the frame title. | ||
| 1638 | @end defun | 1636 | @end defun |
| 1639 | 1637 | ||
| 1640 | The selected window's mode line is usually displayed in a different | 1638 | The selected window's mode line is usually displayed in a different |
| 1641 | color using the face @code{mode-line}. Other windows' mode lines | 1639 | color using the face @code{mode-line}. Other windows' mode lines appear |
| 1642 | appear in the face @code{mode-line-inactive} instead. @xref{Faces}. | 1640 | in the face @code{mode-line-inactive} instead. @xref{Faces}. |
| 1643 | 1641 | ||
| 1644 | @node Mode Line Data | 1642 | @node Mode Line Data |
| 1645 | @subsection The Data Structure of the Mode Line | 1643 | @subsection The Data Structure of the Mode Line |
| 1646 | @cindex mode-line construct | 1644 | @cindex mode line construct |
| 1647 | 1645 | ||
| 1648 | The mode-line contents are controlled by a data structure called a | 1646 | The mode line contents are controlled by a data structure called a |
| 1649 | @dfn{mode-line construct}, made up of lists, strings, symbols, and | 1647 | @dfn{mode line construct}, made up of lists, strings, symbols, and |
| 1650 | numbers kept in buffer-local variables. Each data type has a specific | 1648 | numbers kept in buffer-local variables. Each data type has a specific |
| 1651 | meaning for the mode-line appearance, as described below. The same | 1649 | meaning for the mode line appearance, as described below. The same data |
| 1652 | data structure is used for constructing frame titles (@pxref{Frame | 1650 | structure is used for constructing frame titles (@pxref{Frame Titles}) |
| 1653 | Titles}) and header lines (@pxref{Header Lines}). | 1651 | and header lines (@pxref{Header Lines}). |
| 1654 | 1652 | ||
| 1655 | A mode-line construct may be as simple as a fixed string of text, | 1653 | A mode line construct may be as simple as a fixed string of text, |
| 1656 | but it usually specifies how to combine fixed strings with variables' | 1654 | but it usually specifies how to combine fixed strings with variables' |
| 1657 | values to construct the text. Many of these variables are themselves | 1655 | values to construct the text. Many of these variables are themselves |
| 1658 | defined to have mode-line constructs as their values. | 1656 | defined to have mode line constructs as their values. |
| 1659 | 1657 | ||
| 1660 | Here are the meanings of various data types as mode-line constructs: | 1658 | Here are the meanings of various data types as mode line constructs: |
| 1661 | 1659 | ||
| 1662 | @table @code | 1660 | @table @code |
| 1663 | @cindex percent symbol in mode line | 1661 | @cindex percent symbol in mode line |
| 1664 | @item @var{string} | 1662 | @item @var{string} |
| 1665 | A string as a mode-line construct appears verbatim except for | 1663 | A string as a mode line construct appears verbatim except for |
| 1666 | @dfn{@code{%}-constructs} in it. These stand for substitution of | 1664 | @dfn{@code{%}-constructs} in it. These stand for substitution of |
| 1667 | other data; see @ref{%-Constructs}. | 1665 | other data; see @ref{%-Constructs}. |
| 1668 | 1666 | ||
| @@ -1675,8 +1673,8 @@ default, in the face @code{mode-line} or @code{mode-line-inactive} | |||
| 1675 | special meanings. @xref{Properties in Mode}. | 1673 | special meanings. @xref{Properties in Mode}. |
| 1676 | 1674 | ||
| 1677 | @item @var{symbol} | 1675 | @item @var{symbol} |
| 1678 | A symbol as a mode-line construct stands for its value. The value of | 1676 | A symbol as a mode line construct stands for its value. The value of |
| 1679 | @var{symbol} is used as a mode-line construct, in place of @var{symbol}. | 1677 | @var{symbol} is used as a mode line construct, in place of @var{symbol}. |
| 1680 | However, the symbols @code{t} and @code{nil} are ignored, as is any | 1678 | However, the symbols @code{t} and @code{nil} are ignored, as is any |
| 1681 | symbol whose value is void. | 1679 | symbol whose value is void. |
| 1682 | 1680 | ||
| @@ -1685,17 +1683,17 @@ displayed verbatim: the @code{%}-constructs are not recognized. | |||
| 1685 | 1683 | ||
| 1686 | Unless @var{symbol} is marked as ``risky'' (i.e., it has a | 1684 | Unless @var{symbol} is marked as ``risky'' (i.e., it has a |
| 1687 | non-@code{nil} @code{risky-local-variable} property), all text | 1685 | non-@code{nil} @code{risky-local-variable} property), all text |
| 1688 | properties specified in @var{symbol}'s value are ignored. This | 1686 | properties specified in @var{symbol}'s value are ignored. This includes |
| 1689 | includes the text properties of strings in @var{symbol}'s value, as | 1687 | the text properties of strings in @var{symbol}'s value, as well as all |
| 1690 | well as all @code{:eval} and @code{:propertize} forms in it. (The | 1688 | @code{:eval} and @code{:propertize} forms in it. (The reason for this |
| 1691 | reason for this is security: non-risky variables could be set | 1689 | is security: non-risky variables could be set automatically from file |
| 1692 | automatically from file variables without prompting the user.) | 1690 | variables without prompting the user.) |
| 1693 | 1691 | ||
| 1694 | @item (@var{string} @var{rest}@dots{}) | 1692 | @item (@var{string} @var{rest}@dots{}) |
| 1695 | @itemx (@var{list} @var{rest}@dots{}) | 1693 | @itemx (@var{list} @var{rest}@dots{}) |
| 1696 | A list whose first element is a string or list means to process all the | 1694 | A list whose first element is a string or list means to process all the |
| 1697 | elements recursively and concatenate the results. This is the most | 1695 | elements recursively and concatenate the results. This is the most |
| 1698 | common form of mode-line construct. | 1696 | common form of mode line construct. |
| 1699 | 1697 | ||
| 1700 | @item (:eval @var{form}) | 1698 | @item (:eval @var{form}) |
| 1701 | A list whose first element is the symbol @code{:eval} says to evaluate | 1699 | A list whose first element is the symbol @code{:eval} says to evaluate |
| @@ -1705,24 +1703,24 @@ recursion. | |||
| 1705 | 1703 | ||
| 1706 | @item (:propertize @var{elt} @var{props}@dots{}) | 1704 | @item (:propertize @var{elt} @var{props}@dots{}) |
| 1707 | A list whose first element is the symbol @code{:propertize} says to | 1705 | A list whose first element is the symbol @code{:propertize} says to |
| 1708 | process the mode-line construct @var{elt} recursively, then add the text | 1706 | process the mode line construct @var{elt} recursively, then add the text |
| 1709 | properties specified by @var{props} to the result. The argument | 1707 | properties specified by @var{props} to the result. The argument |
| 1710 | @var{props} should consist of zero or more pairs @var{text-property} | 1708 | @var{props} should consist of zero or more pairs @var{text-property} |
| 1711 | @var{value}. (This feature is new as of Emacs 22.1.) | 1709 | @var{value}. |
| 1712 | 1710 | ||
| 1713 | @item (@var{symbol} @var{then} @var{else}) | 1711 | @item (@var{symbol} @var{then} @var{else}) |
| 1714 | A list whose first element is a symbol that is not a keyword specifies | 1712 | A list whose first element is a symbol that is not a keyword specifies |
| 1715 | a conditional. Its meaning depends on the value of @var{symbol}. If | 1713 | a conditional. Its meaning depends on the value of @var{symbol}. If |
| 1716 | @var{symbol} has a non-@code{nil} value, the second element, | 1714 | @var{symbol} has a non-@code{nil} value, the second element, |
| 1717 | @var{then}, is processed recursively as a mode-line element. | 1715 | @var{then}, is processed recursively as a mode line element. |
| 1718 | Otherwise, the third element, @var{else}, is processed recursively. | 1716 | Otherwise, the third element, @var{else}, is processed recursively. |
| 1719 | You may omit @var{else}; then the mode-line element displays nothing | 1717 | You may omit @var{else}; then the mode line element displays nothing |
| 1720 | if the value of @var{symbol} is @code{nil} or void. | 1718 | if the value of @var{symbol} is @code{nil} or void. |
| 1721 | 1719 | ||
| 1722 | @item (@var{width} @var{rest}@dots{}) | 1720 | @item (@var{width} @var{rest}@dots{}) |
| 1723 | A list whose first element is an integer specifies truncation or | 1721 | A list whose first element is an integer specifies truncation or |
| 1724 | padding of the results of @var{rest}. The remaining elements | 1722 | padding of the results of @var{rest}. The remaining elements |
| 1725 | @var{rest} are processed recursively as mode-line constructs and | 1723 | @var{rest} are processed recursively as mode line constructs and |
| 1726 | concatenated together. When @var{width} is positive, the result is | 1724 | concatenated together. When @var{width} is positive, the result is |
| 1727 | space filled on the right if its width is less than @var{width}. When | 1725 | space filled on the right if its width is less than @var{width}. When |
| 1728 | @var{width} is negative, the result is truncated on the right to | 1726 | @var{width} is negative, the result is truncated on the right to |
| @@ -1739,12 +1737,12 @@ the top of the window is to use a list like this: @code{(-3 "%p")}. | |||
| 1739 | @code{mode-line-format}. | 1737 | @code{mode-line-format}. |
| 1740 | 1738 | ||
| 1741 | @defopt mode-line-format | 1739 | @defopt mode-line-format |
| 1742 | The value of this variable is a mode-line construct that controls the | 1740 | The value of this variable is a mode line construct that controls the |
| 1743 | contents of the mode-line. It is always buffer-local in all buffers. | 1741 | contents of the mode-line. It is always buffer-local in all buffers. |
| 1744 | 1742 | ||
| 1745 | If you set this variable to @code{nil} in a buffer, that buffer does | 1743 | If you set this variable to @code{nil} in a buffer, that buffer does not |
| 1746 | not have a mode line. (A window that is just one line tall never | 1744 | have a mode line. (A window that is just one line tall also does not |
| 1747 | displays a mode line.) | 1745 | display a mode line.) |
| 1748 | @end defopt | 1746 | @end defopt |
| 1749 | 1747 | ||
| 1750 | The default value of @code{mode-line-format} is designed to use the | 1748 | The default value of @code{mode-line-format} is designed to use the |
| @@ -1762,9 +1760,9 @@ the information in another fashion. This way, customizations made by | |||
| 1762 | the user or by Lisp programs (such as @code{display-time} and major | 1760 | the user or by Lisp programs (such as @code{display-time} and major |
| 1763 | modes) via changes to those variables remain effective. | 1761 | modes) via changes to those variables remain effective. |
| 1764 | 1762 | ||
| 1765 | Here is an example of a @code{mode-line-format} that might be | 1763 | Here is a hypothetical example of a @code{mode-line-format} that might |
| 1766 | useful for @code{shell-mode}, since it contains the host name and default | 1764 | be useful for Shell mode (in reality, Shell mode does not set |
| 1767 | directory. | 1765 | @code{mode-line-format}): |
| 1768 | 1766 | ||
| 1769 | @example | 1767 | @example |
| 1770 | @group | 1768 | @group |
| @@ -1777,7 +1775,7 @@ directory. | |||
| 1777 | @end group | 1775 | @end group |
| 1778 | @group | 1776 | @group |
| 1779 | ;; @r{Note that this is evaluated while making the list.} | 1777 | ;; @r{Note that this is evaluated while making the list.} |
| 1780 | ;; @r{It makes a mode-line construct which is just a string.} | 1778 | ;; @r{It makes a mode line construct which is just a string.} |
| 1781 | (getenv "HOST") | 1779 | (getenv "HOST") |
| 1782 | @end group | 1780 | @end group |
| 1783 | ":" | 1781 | ":" |
| @@ -1794,8 +1792,7 @@ directory. | |||
| 1794 | '(which-func-mode ("" which-func-format "--")) | 1792 | '(which-func-mode ("" which-func-format "--")) |
| 1795 | '(line-number-mode "L%l--") | 1793 | '(line-number-mode "L%l--") |
| 1796 | '(column-number-mode "C%c--") | 1794 | '(column-number-mode "C%c--") |
| 1797 | '(-3 "%p") | 1795 | '(-3 "%p"))) |
| 1798 | "-%-")) | ||
| 1799 | @end group | 1796 | @end group |
| 1800 | @end example | 1797 | @end example |
| 1801 | 1798 | ||
| @@ -1807,23 +1804,23 @@ these variable names are also the minor mode command names.) | |||
| 1807 | @node Mode Line Variables | 1804 | @node Mode Line Variables |
| 1808 | @subsection Variables Used in the Mode Line | 1805 | @subsection Variables Used in the Mode Line |
| 1809 | 1806 | ||
| 1810 | This section describes variables incorporated by the standard value | 1807 | This section describes variables incorporated by the standard value of |
| 1811 | of @code{mode-line-format} into the text of the mode line. There is | 1808 | @code{mode-line-format} into the text of the mode line. There is |
| 1812 | nothing inherently special about these variables; any other variables | 1809 | nothing inherently special about these variables; any other variables |
| 1813 | could have the same effects on the mode line if | 1810 | could have the same effects on the mode line if the value of |
| 1814 | @code{mode-line-format}'s value were changed to use them. However, | 1811 | @code{mode-line-format} is changed to use them. However, various parts |
| 1815 | various parts of Emacs set these variables on the understanding that | 1812 | of Emacs set these variables on the understanding that they will control |
| 1816 | they will control parts of the mode line; therefore, practically | 1813 | parts of the mode line; therefore, practically speaking, it is essential |
| 1817 | speaking, it is essential for the mode line to use them. | 1814 | for the mode line to use them. |
| 1818 | 1815 | ||
| 1819 | @defvar mode-line-mule-info | 1816 | @defvar mode-line-mule-info |
| 1820 | This variable holds the value of the mode-line construct that displays | 1817 | This variable holds the value of the mode line construct that displays |
| 1821 | information about the language environment, buffer coding system, and | 1818 | information about the language environment, buffer coding system, and |
| 1822 | current input method. @xref{Non-ASCII Characters}. | 1819 | current input method. @xref{Non-ASCII Characters}. |
| 1823 | @end defvar | 1820 | @end defvar |
| 1824 | 1821 | ||
| 1825 | @defvar mode-line-modified | 1822 | @defvar mode-line-modified |
| 1826 | This variable holds the value of the mode-line construct that displays | 1823 | This variable holds the value of the mode line construct that displays |
| 1827 | whether the current buffer is modified. Its default value displays | 1824 | whether the current buffer is modified. Its default value displays |
| 1828 | @samp{**} if the buffer is modified, @samp{--} if the buffer is not | 1825 | @samp{**} if the buffer is modified, @samp{--} if the buffer is not |
| 1829 | modified, @samp{%%} if the buffer is read only, and @samp{%*} if the | 1826 | modified, @samp{%%} if the buffer is read only, and @samp{%*} if the |
| @@ -1886,7 +1883,7 @@ identify the mode name in the mode line, use @code{format-mode-line} | |||
| 1886 | @end defvar | 1883 | @end defvar |
| 1887 | 1884 | ||
| 1888 | @defvar mode-line-process | 1885 | @defvar mode-line-process |
| 1889 | This buffer-local variable contains the mode-line information on process | 1886 | This buffer-local variable contains the mode line information on process |
| 1890 | status in modes used for communicating with subprocesses. It is | 1887 | status in modes used for communicating with subprocesses. It is |
| 1891 | displayed immediately following the major mode name, with no intervening | 1888 | displayed immediately following the major mode name, with no intervening |
| 1892 | space. For example, its value in the @samp{*shell*} buffer is | 1889 | space. For example, its value in the @samp{*shell*} buffer is |
| @@ -1905,12 +1902,12 @@ the @code{minor-mode-alist} should be a two-element list: | |||
| 1905 | (@var{minor-mode-variable} @var{mode-line-string}) | 1902 | (@var{minor-mode-variable} @var{mode-line-string}) |
| 1906 | @end example | 1903 | @end example |
| 1907 | 1904 | ||
| 1908 | More generally, @var{mode-line-string} can be any mode-line spec. It | 1905 | More generally, @var{mode-line-string} can be any mode line construct. |
| 1909 | appears in the mode line when the value of @var{minor-mode-variable} | 1906 | It appears in the mode line when the value of @var{minor-mode-variable} |
| 1910 | is non-@code{nil}, and not otherwise. These strings should begin with | 1907 | is non-@code{nil}, and not otherwise. These strings should begin with |
| 1911 | spaces so that they don't run together. Conventionally, the | 1908 | spaces so that they don't run together. Conventionally, the |
| 1912 | @var{minor-mode-variable} for a specific mode is set to a | 1909 | @var{minor-mode-variable} for a specific mode is set to a non-@code{nil} |
| 1913 | non-@code{nil} value when that minor mode is activated. | 1910 | value when that minor mode is activated. |
| 1914 | 1911 | ||
| 1915 | @code{minor-mode-alist} itself is not buffer-local. Each variable | 1912 | @code{minor-mode-alist} itself is not buffer-local. Each variable |
| 1916 | mentioned in the alist should be buffer-local if its minor mode can be | 1913 | mentioned in the alist should be buffer-local if its minor mode can be |
| @@ -1918,12 +1915,12 @@ enabled separately in each buffer. | |||
| 1918 | @end defvar | 1915 | @end defvar |
| 1919 | 1916 | ||
| 1920 | @defvar global-mode-string | 1917 | @defvar global-mode-string |
| 1921 | This variable holds a mode-line spec that, by default, appears in the | 1918 | This variable holds a mode line construct that, by default, appears in |
| 1922 | mode line just after the @code{which-func-mode} minor mode if set, | 1919 | the mode line just after the @code{which-func-mode} minor mode if set, |
| 1923 | else after @code{mode-line-modes}. The command @code{display-time} | 1920 | else after @code{mode-line-modes}. The command @code{display-time} sets |
| 1924 | sets @code{global-mode-string} to refer to the variable | 1921 | @code{global-mode-string} to refer to the variable |
| 1925 | @code{display-time-string}, which holds a string containing the time | 1922 | @code{display-time-string}, which holds a string containing the time and |
| 1926 | and load information. | 1923 | load information. |
| 1927 | 1924 | ||
| 1928 | The @samp{%M} construct substitutes the value of | 1925 | The @samp{%M} construct substitutes the value of |
| 1929 | @code{global-mode-string}, but that is obsolete, since the variable is | 1926 | @code{global-mode-string}, but that is obsolete, since the variable is |
| @@ -1957,7 +1954,7 @@ specifies addition of text properties. | |||
| 1957 | @node %-Constructs | 1954 | @node %-Constructs |
| 1958 | @subsection @code{%}-Constructs in the Mode Line | 1955 | @subsection @code{%}-Constructs in the Mode Line |
| 1959 | 1956 | ||
| 1960 | Strings used as mode-line constructs can use certain | 1957 | Strings used as mode line constructs can use certain |
| 1961 | @code{%}-constructs to substitute various kinds of data. Here is a | 1958 | @code{%}-constructs to substitute various kinds of data. Here is a |
| 1962 | list of the defined @code{%}-constructs, and what they mean. In any | 1959 | list of the defined @code{%}-constructs, and what they mean. In any |
| 1963 | construct except @samp{%%}, you can add a decimal integer after the | 1960 | construct except @samp{%%}, you can add a decimal integer after the |
| @@ -2003,8 +2000,8 @@ of the buffer. | |||
| 2003 | 2000 | ||
| 2004 | @item %p | 2001 | @item %p |
| 2005 | The percentage of the buffer text above the @strong{top} of window, or | 2002 | The percentage of the buffer text above the @strong{top} of window, or |
| 2006 | @samp{Top}, @samp{Bottom} or @samp{All}. Note that the default | 2003 | @samp{Top}, @samp{Bottom} or @samp{All}. Note that the default mode |
| 2007 | mode-line specification truncates this to three characters. | 2004 | line construct truncates this to three characters. |
| 2008 | 2005 | ||
| 2009 | @item %P | 2006 | @item %P |
| 2010 | The percentage of the buffer text that is above the @strong{bottom} of | 2007 | The percentage of the buffer text that is above the @strong{bottom} of |
| @@ -2084,11 +2081,11 @@ line: | |||
| 2084 | 2081 | ||
| 2085 | @enumerate | 2082 | @enumerate |
| 2086 | @item | 2083 | @item |
| 2087 | Put a string with a text property directly into the mode-line data | 2084 | Put a string with a text property directly into the mode line data |
| 2088 | structure. | 2085 | structure. |
| 2089 | 2086 | ||
| 2090 | @item | 2087 | @item |
| 2091 | Put a text property on a mode-line %-construct such as @samp{%12b}; then | 2088 | Put a text property on a mode line %-construct such as @samp{%12b}; then |
| 2092 | the expansion of the %-construct will have that same text property. | 2089 | the expansion of the %-construct will have that same text property. |
| 2093 | 2090 | ||
| 2094 | @item | 2091 | @item |
| @@ -2096,7 +2093,7 @@ Use a @code{(:propertize @var{elt} @var{props}@dots{})} construct to | |||
| 2096 | give @var{elt} a text property specified by @var{props}. | 2093 | give @var{elt} a text property specified by @var{props}. |
| 2097 | 2094 | ||
| 2098 | @item | 2095 | @item |
| 2099 | Use a list containing @code{:eval @var{form}} in the mode-line data | 2096 | Use a list containing @code{:eval @var{form}} in the mode line data |
| 2100 | structure, and make @var{form} evaluate to a string that has a text | 2097 | structure, and make @var{form} evaluate to a string that has a text |
| 2101 | property. | 2098 | property. |
| 2102 | @end enumerate | 2099 | @end enumerate |
| @@ -2118,10 +2115,10 @@ local variables. | |||
| 2118 | @cindex header line (of a window) | 2115 | @cindex header line (of a window) |
| 2119 | @cindex window header line | 2116 | @cindex window header line |
| 2120 | 2117 | ||
| 2121 | A window can have a @dfn{header line} at the | 2118 | A window can have a @dfn{header line} at the top, just as it can have |
| 2122 | top, just as it can have a mode line at the bottom. The header line | 2119 | a mode line at the bottom. The header line feature works just like the |
| 2123 | feature works just like the mode-line feature, except that it's | 2120 | mode line feature, except that it's controlled by |
| 2124 | controlled by different variables. | 2121 | @code{header-line-format}: |
| 2125 | 2122 | ||
| 2126 | @defvar header-line-format | 2123 | @defvar header-line-format |
| 2127 | This variable, local in every buffer, specifies how to display the | 2124 | This variable, local in every buffer, specifies how to display the |
| @@ -2136,11 +2133,11 @@ header line at once; if it has a mode line, then it does not display a | |||
| 2136 | header line. | 2133 | header line. |
| 2137 | 2134 | ||
| 2138 | @node Emulating Mode Line | 2135 | @node Emulating Mode Line |
| 2139 | @subsection Emulating Mode-Line Formatting | 2136 | @subsection Emulating Mode Line Formatting |
| 2140 | 2137 | ||
| 2141 | You can use the function @code{format-mode-line} to compute | 2138 | You can use the function @code{format-mode-line} to compute the text |
| 2142 | the text that would appear in a mode line or header line | 2139 | that would appear in a mode line or header line based on a certain |
| 2143 | based on a certain mode-line specification. | 2140 | mode line construct. |
| 2144 | 2141 | ||
| 2145 | @defun format-mode-line format &optional face window buffer | 2142 | @defun format-mode-line format &optional face window buffer |
| 2146 | This function formats a line of text according to @var{format} as if it | 2143 | This function formats a line of text according to @var{format} as if it |
| @@ -2374,12 +2371,12 @@ Setting this variable makes it buffer-local in the current buffer. | |||
| 2374 | @section Font Lock Mode | 2371 | @section Font Lock Mode |
| 2375 | @cindex Font Lock mode | 2372 | @cindex Font Lock mode |
| 2376 | 2373 | ||
| 2377 | @dfn{Font Lock mode} is a feature that automatically attaches | 2374 | @dfn{Font Lock mode} is a buffer-local minor mode that automatically |
| 2378 | @code{face} properties to certain parts of the buffer based on their | 2375 | attaches @code{face} properties to certain parts of the buffer based on |
| 2379 | syntactic role. How it parses the buffer depends on the major mode; | 2376 | their syntactic role. How it parses the buffer depends on the major |
| 2380 | most major modes define syntactic criteria for which faces to use in | 2377 | mode; most major modes define syntactic criteria for which faces to use |
| 2381 | which contexts. This section explains how to customize Font Lock for a | 2378 | in which contexts. This section explains how to customize Font Lock for |
| 2382 | particular major mode. | 2379 | a particular major mode. |
| 2383 | 2380 | ||
| 2384 | Font Lock mode finds text to highlight in two ways: through | 2381 | Font Lock mode finds text to highlight in two ways: through |
| 2385 | syntactic parsing based on the syntax table, and through searching | 2382 | syntactic parsing based on the syntax table, and through searching |
| @@ -2398,8 +2395,6 @@ Search-based fontification happens second. | |||
| 2398 | contents can also specify how to fontify it. | 2395 | contents can also specify how to fontify it. |
| 2399 | * Faces for Font Lock:: Special faces specifically for Font Lock. | 2396 | * Faces for Font Lock:: Special faces specifically for Font Lock. |
| 2400 | * Syntactic Font Lock:: Fontification based on syntax tables. | 2397 | * Syntactic Font Lock:: Fontification based on syntax tables. |
| 2401 | * Setting Syntax Properties:: Defining character syntax based on context | ||
| 2402 | using the Font Lock mechanism. | ||
| 2403 | * Multiline Font Lock:: How to coerce Font Lock into properly | 2398 | * Multiline Font Lock:: How to coerce Font Lock into properly |
| 2404 | highlighting multiline constructs. | 2399 | highlighting multiline constructs. |
| 2405 | @end menu | 2400 | @end menu |
| @@ -2414,12 +2409,12 @@ variable. The value assigned to this variable is used, if and when Font | |||
| 2414 | Lock mode is enabled, to set all the other variables. | 2409 | Lock mode is enabled, to set all the other variables. |
| 2415 | 2410 | ||
| 2416 | @defvar font-lock-defaults | 2411 | @defvar font-lock-defaults |
| 2417 | This variable is set by major modes, as a buffer-local variable, to | 2412 | This variable is set by major modes to specify how to fontify text in |
| 2418 | specify how to fontify text in that mode. It automatically becomes | 2413 | that mode. It automatically becomes buffer-local when set. If its |
| 2419 | buffer-local when you set it. If its value is @code{nil}, Font-Lock | 2414 | value is @code{nil}, Font Lock mode does no highlighting, and you can |
| 2420 | mode does no highlighting, and you can use the @samp{Faces} menu | 2415 | use the @samp{Faces} menu (under @samp{Edit} and then @samp{Text |
| 2421 | (under @samp{Edit} and then @samp{Text Properties} in the menu bar) to | 2416 | Properties} in the menu bar) to assign faces explicitly to text in the |
| 2422 | assign faces explicitly to text in the buffer. | 2417 | buffer. |
| 2423 | 2418 | ||
| 2424 | If non-@code{nil}, the value should look like this: | 2419 | If non-@code{nil}, the value should look like this: |
| 2425 | 2420 | ||
| @@ -2442,19 +2437,20 @@ value. @xref{Levels of Font Lock}. | |||
| 2442 | The second element, @var{keywords-only}, specifies the value of the | 2437 | The second element, @var{keywords-only}, specifies the value of the |
| 2443 | variable @code{font-lock-keywords-only}. If this is omitted or | 2438 | variable @code{font-lock-keywords-only}. If this is omitted or |
| 2444 | @code{nil}, syntactic fontification (of strings and comments) is also | 2439 | @code{nil}, syntactic fontification (of strings and comments) is also |
| 2445 | performed. If this is non-@code{nil}, such fontification is not | 2440 | performed. If this is non-@code{nil}, syntactic fontification is not |
| 2446 | performed. @xref{Syntactic Font Lock}. | 2441 | performed. @xref{Syntactic Font Lock}. |
| 2447 | 2442 | ||
| 2448 | The third element, @var{case-fold}, specifies the value of | 2443 | The third element, @var{case-fold}, specifies the value of |
| 2449 | @code{font-lock-keywords-case-fold-search}. If it is non-@code{nil}, | 2444 | @code{font-lock-keywords-case-fold-search}. If it is non-@code{nil}, |
| 2450 | Font Lock mode ignores case when searching as directed by | 2445 | Font Lock mode ignores case during search-based fontification. |
| 2451 | @code{font-lock-keywords}. | ||
| 2452 | 2446 | ||
| 2453 | If the fourth element, @var{syntax-alist}, is non-@code{nil}, it | 2447 | If the fourth element, @var{syntax-alist}, is non-@code{nil}, it should |
| 2454 | should be a list of cons cells of the form @code{(@var{char-or-string} | 2448 | be a list of cons cells of the form @code{(@var{char-or-string} |
| 2455 | . @var{string})}. These are used to set up a syntax table for | 2449 | . @var{string})}. These are used to set up a syntax table for syntactic |
| 2456 | syntactic fontification (@pxref{Syntax Table Functions}). The | 2450 | fontification; the resulting syntax table is stored in |
| 2457 | resulting syntax table is stored in @code{font-lock-syntax-table}. | 2451 | @code{font-lock-syntax-table}. If @var{syntax-alist} is omitted or |
| 2452 | @code{nil}, syntactic fontification uses the syntax table returned by | ||
| 2453 | the @code{syntax-table} function. @xref{Syntax Table Functions}. | ||
| 2458 | 2454 | ||
| 2459 | The fifth element, @var{syntax-begin}, specifies the value of | 2455 | The fifth element, @var{syntax-begin}, specifies the value of |
| 2460 | @code{font-lock-beginning-of-syntax-function}. We recommend setting | 2456 | @code{font-lock-beginning-of-syntax-function}. We recommend setting |
| @@ -2480,15 +2476,17 @@ fontification for other parts of the text. | |||
| 2480 | @node Search-based Fontification | 2476 | @node Search-based Fontification |
| 2481 | @subsection Search-based Fontification | 2477 | @subsection Search-based Fontification |
| 2482 | 2478 | ||
| 2483 | The most important variable for customizing Font Lock mode is | 2479 | The variable which directly controls search-based fontification is |
| 2484 | @code{font-lock-keywords}. It specifies the search criteria for | 2480 | @code{font-lock-keywords}, which is typically specified via the |
| 2485 | search-based fontification. You should specify the value of this | 2481 | @var{keywords} element in @code{font-lock-defaults}. |
| 2486 | variable with @var{keywords} in @code{font-lock-defaults}. | ||
| 2487 | 2482 | ||
| 2488 | @defvar font-lock-keywords | 2483 | @defvar font-lock-keywords |
| 2489 | This variable's value is a list of the keywords to highlight. Be | 2484 | The value of this variable is a list of the keywords to highlight. Lisp |
| 2490 | careful when composing regular expressions for this list; a poorly | 2485 | programs should not set this variable directly. Normally, the value is |
| 2491 | written pattern can dramatically slow things down! | 2486 | automatically set by Font Lock mode, using the @var{keywords} element in |
| 2487 | @code{font-lock-defaults}. The value can also be altered using the | ||
| 2488 | functions @code{font-lock-add-keywords} and | ||
| 2489 | @code{font-lock-remove-keywords} (@pxref{Customizing Keywords}). | ||
| 2492 | @end defvar | 2490 | @end defvar |
| 2493 | 2491 | ||
| 2494 | Each element of @code{font-lock-keywords} specifies how to find | 2492 | Each element of @code{font-lock-keywords} specifies how to find |
| @@ -2513,9 +2511,10 @@ Highlight all matches for @var{regexp} using | |||
| 2513 | "\\<foo\\>" | 2511 | "\\<foo\\>" |
| 2514 | @end example | 2512 | @end example |
| 2515 | 2513 | ||
| 2516 | The function @code{regexp-opt} (@pxref{Regexp Functions}) is useful | 2514 | Be careful when composing these regular expressions; a poorly written |
| 2517 | for calculating optimal regular expressions to match a number of | 2515 | pattern can dramatically slow things down! The function |
| 2518 | different keywords. | 2516 | @code{regexp-opt} (@pxref{Regexp Functions}) is useful for calculating |
| 2517 | optimal regular expressions to match several keywords. | ||
| 2519 | 2518 | ||
| 2520 | @item @var{function} | 2519 | @item @var{function} |
| 2521 | Find text by calling @var{function}, and highlight the matches | 2520 | Find text by calling @var{function}, and highlight the matches |
| @@ -2740,7 +2739,7 @@ highlighting patterns. See the variables | |||
| 2740 | @code{c-font-lock-extra-types}, @code{c++-font-lock-extra-types}, | 2739 | @code{c-font-lock-extra-types}, @code{c++-font-lock-extra-types}, |
| 2741 | and @code{java-font-lock-extra-types}, for example. | 2740 | and @code{java-font-lock-extra-types}, for example. |
| 2742 | 2741 | ||
| 2743 | @strong{Warning:} major mode commands must not call | 2742 | @strong{Warning:} Major mode commands must not call |
| 2744 | @code{font-lock-add-keywords} under any circumstances, either directly | 2743 | @code{font-lock-add-keywords} under any circumstances, either directly |
| 2745 | or indirectly, except through their mode hooks. (Doing so would lead to | 2744 | or indirectly, except through their mode hooks. (Doing so would lead to |
| 2746 | incorrect behavior for some minor modes.) They should set up their | 2745 | incorrect behavior for some minor modes.) They should set up their |
| @@ -2756,7 +2755,10 @@ command name or @code{nil}. All the caveats and requirements for | |||
| 2756 | @code{font-lock-add-keywords} apply here too. | 2755 | @code{font-lock-add-keywords} apply here too. |
| 2757 | @end defun | 2756 | @end defun |
| 2758 | 2757 | ||
| 2759 | For example, this code | 2758 | For example, the following code adds two fontification patterns for C |
| 2759 | mode: one to fontify the word @samp{FIXME}, even in comments, and | ||
| 2760 | another to fontify the words @samp{and}, @samp{or} and @samp{not} as | ||
| 2761 | keywords. | ||
| 2760 | 2762 | ||
| 2761 | @smallexample | 2763 | @smallexample |
| 2762 | (font-lock-add-keywords 'c-mode | 2764 | (font-lock-add-keywords 'c-mode |
| @@ -2765,13 +2767,8 @@ command name or @code{nil}. All the caveats and requirements for | |||
| 2765 | @end smallexample | 2767 | @end smallexample |
| 2766 | 2768 | ||
| 2767 | @noindent | 2769 | @noindent |
| 2768 | adds two fontification patterns for C mode: one to fontify the word | 2770 | This example affects only C mode proper. To add the same patterns to C |
| 2769 | @samp{FIXME}, even in comments, and another to fontify the words | 2771 | mode @emph{and} all modes derived from it, do this instead: |
| 2770 | @samp{and}, @samp{or} and @samp{not} as keywords. | ||
| 2771 | |||
| 2772 | @noindent | ||
| 2773 | That example affects only C mode proper. To add the same patterns to | ||
| 2774 | C mode @emph{and} all modes derived from it, do this instead: | ||
| 2775 | 2772 | ||
| 2776 | @smallexample | 2773 | @smallexample |
| 2777 | (add-hook 'c-mode-hook | 2774 | (add-hook 'c-mode-hook |
| @@ -2858,13 +2855,13 @@ function using @code{jit-lock-register}, this function unregisters it. | |||
| 2858 | @node Levels of Font Lock | 2855 | @node Levels of Font Lock |
| 2859 | @subsection Levels of Font Lock | 2856 | @subsection Levels of Font Lock |
| 2860 | 2857 | ||
| 2861 | Many major modes offer three different levels of fontification. You | 2858 | Some major modes offer three different levels of fontification. You |
| 2862 | can define multiple levels by using a list of symbols for @var{keywords} | 2859 | can define multiple levels by using a list of symbols for @var{keywords} |
| 2863 | in @code{font-lock-defaults}. Each symbol specifies one level of | 2860 | in @code{font-lock-defaults}. Each symbol specifies one level of |
| 2864 | fontification; it is up to the user to choose one of these levels, | 2861 | fontification; it is up to the user to choose one of these levels, |
| 2865 | normally by setting @code{font-lock-maximum-decoration} (@pxref{Font | 2862 | normally by setting @code{font-lock-maximum-decoration} (@pxref{Font |
| 2866 | Lock,,, emacs, the GNU Emacs Manual}). The chosen level's symbol | 2863 | Lock,,, emacs, the GNU Emacs Manual}). The chosen level's symbol value |
| 2867 | value is used to initialize @code{font-lock-keywords}. | 2864 | is used to initialize @code{font-lock-keywords}. |
| 2868 | 2865 | ||
| 2869 | Here are the conventions for how to define the levels of | 2866 | Here are the conventions for how to define the levels of |
| 2870 | fontification: | 2867 | fontification: |
| @@ -2912,10 +2909,10 @@ the normal Font Lock machinery, it should not set the variable | |||
| 2912 | @cindex font lock faces | 2909 | @cindex font lock faces |
| 2913 | 2910 | ||
| 2914 | Font Lock mode can highlight using any face, but Emacs defines several | 2911 | Font Lock mode can highlight using any face, but Emacs defines several |
| 2915 | faces specifically for syntactic highlighting. These @dfn{Font Lock | 2912 | faces specifically for Font Lock to use to highlight text. These |
| 2916 | faces} are listed below. They can also be used by major modes for | 2913 | @dfn{Font Lock faces} are listed below. They can also be used by major |
| 2917 | syntactic highlighting outside of Font Lock mode (@pxref{Major Mode | 2914 | modes for syntactic highlighting outside of Font Lock mode (@pxref{Major |
| 2918 | Conventions}). | 2915 | Mode Conventions}). |
| 2919 | 2916 | ||
| 2920 | Each of these symbols is both a face name, and a variable whose | 2917 | Each of these symbols is both a face name, and a variable whose |
| 2921 | default value is the symbol itself. Thus, the default value of | 2918 | default value is the symbol itself. Thus, the default value of |
| @@ -2990,128 +2987,60 @@ for easily-overlooked negation characters. | |||
| 2990 | @subsection Syntactic Font Lock | 2987 | @subsection Syntactic Font Lock |
| 2991 | @cindex syntactic font lock | 2988 | @cindex syntactic font lock |
| 2992 | 2989 | ||
| 2993 | Syntactic fontification uses the syntax table to find comments and | 2990 | Syntactic fontification uses a syntax table (@pxref{Syntax Tables}) to |
| 2994 | string constants (@pxref{Syntax Tables}). It highlights them using | 2991 | find and highlight syntactically relevant text. If enabled, it runs |
| 2995 | @code{font-lock-comment-face} and @code{font-lock-string-face} | 2992 | prior to search-based fontification. The variable |
| 2996 | (@pxref{Faces for Font Lock}), or whatever | 2993 | @code{font-lock-syntactic-face-function}, documented below, determines |
| 2997 | @code{font-lock-syntactic-face-function} chooses. There are several | 2994 | which syntactic constructs to highlight. There are several variables |
| 2998 | variables that affect syntactic fontification; you should set them by | 2995 | that affect syntactic fontification; you should set them by means of |
| 2999 | means of @code{font-lock-defaults} (@pxref{Font Lock Basics}). | 2996 | @code{font-lock-defaults} (@pxref{Font Lock Basics}). |
| 3000 | 2997 | ||
| 3001 | @defvar font-lock-keywords-only | 2998 | @defvar font-lock-keywords-only |
| 3002 | Non-@code{nil} means Font Lock should not do syntactic fontification; | 2999 | If the value of this variable is non-@code{nil}, Font Lock does not do |
| 3003 | it should only fontify based on @code{font-lock-keywords}. The normal | 3000 | syntactic fontification, only search-based fontification based on |
| 3004 | way for a mode to set this variable to @code{t} is with | 3001 | @code{font-lock-keywords}. It is normally set by Font Lock mode based |
| 3005 | @var{keywords-only} in @code{font-lock-defaults}. | 3002 | on the @var{keywords-only} element in @code{font-lock-defaults}. |
| 3006 | @end defvar | 3003 | @end defvar |
| 3007 | 3004 | ||
| 3008 | @defvar font-lock-syntax-table | 3005 | @defvar font-lock-syntax-table |
| 3009 | This variable holds the syntax table to use for fontification of | 3006 | This variable holds the syntax table to use for fontification of |
| 3010 | comments and strings. Specify it using @var{syntax-alist} in | 3007 | comments and strings. It is normally set by Font Lock mode based on the |
| 3011 | @code{font-lock-defaults}. If this is @code{nil}, fontification uses | 3008 | @var{syntax-alist} element in @code{font-lock-defaults}. If this value |
| 3012 | the buffer's syntax table. | 3009 | is @code{nil}, syntactic fontification uses the buffer's syntax table |
| 3010 | (the value returned by the function @code{syntax-table}; @pxref{Syntax | ||
| 3011 | Table Functions}). | ||
| 3013 | @end defvar | 3012 | @end defvar |
| 3014 | 3013 | ||
| 3015 | @defvar font-lock-beginning-of-syntax-function | 3014 | @defvar font-lock-beginning-of-syntax-function |
| 3016 | If this variable is non-@code{nil}, it should be a function to move | 3015 | If this variable is non-@code{nil}, it should be a function to move |
| 3017 | point back to a position that is syntactically at ``top level'' and | 3016 | point back to a position that is syntactically at ``top level'' and |
| 3018 | outside of strings or comments. Font Lock uses this when necessary | 3017 | outside of strings or comments. The value is normally set through an |
| 3019 | to get the right results for syntactic fontification. | 3018 | @var{other-vars} element in @code{font-lock-defaults}. If it is |
| 3020 | 3019 | @code{nil}, Font Lock uses @code{syntax-begin-function} to move back | |
| 3021 | This function is called with no arguments. It should leave point at | 3020 | outside of any comment, string, or sexp (@pxref{Position Parse}). |
| 3022 | the beginning of any enclosing syntactic block. Typical values are | 3021 | |
| 3023 | @code{beginning-of-line} (used when the start of the line is known to | 3022 | This variable is semi-obsolete; we usually recommend setting |
| 3024 | be outside a syntactic block), or @code{beginning-of-defun} for | 3023 | @code{syntax-begin-function} instead. One of its uses is to tune the |
| 3024 | behavior of syntactic fontification, e.g.@: to ensure that different | ||
| 3025 | kinds of strings or comments are highlighted differently. | ||
| 3026 | |||
| 3027 | The specified function is called with no arguments. It should leave | ||
| 3028 | point at the beginning of any enclosing syntactic block. Typical values | ||
| 3029 | are @code{beginning-of-line} (used when the start of the line is known | ||
| 3030 | to be outside a syntactic block), or @code{beginning-of-defun} for | ||
| 3025 | programming modes, or @code{backward-paragraph} for textual modes. | 3031 | programming modes, or @code{backward-paragraph} for textual modes. |
| 3026 | |||
| 3027 | If the value is @code{nil}, Font Lock uses | ||
| 3028 | @code{syntax-begin-function} to move back outside of any comment, | ||
| 3029 | string, or sexp. This variable is semi-obsolete; we recommend setting | ||
| 3030 | @code{syntax-begin-function} instead. | ||
| 3031 | |||
| 3032 | Specify this variable using @var{syntax-begin} in | ||
| 3033 | @code{font-lock-defaults}. | ||
| 3034 | @end defvar | 3032 | @end defvar |
| 3035 | 3033 | ||
| 3036 | @defvar font-lock-syntactic-face-function | 3034 | @defvar font-lock-syntactic-face-function |
| 3037 | A function to determine which face to use for a given syntactic | 3035 | If this variable is non-@code{nil}, it should be a function to determine |
| 3038 | element (a string or a comment). The function is called with one | 3036 | which face to use for a given syntactic element (a string or a comment). |
| 3039 | argument, the parse state at point returned by | 3037 | The value is normally set through an @var{other-vars} element in |
| 3040 | @code{parse-partial-sexp}, and should return a face. The default | ||
| 3041 | value returns @code{font-lock-comment-face} for comments and | ||
| 3042 | @code{font-lock-string-face} for strings. | ||
| 3043 | |||
| 3044 | This can be used to highlighting different kinds of strings or | ||
| 3045 | comments differently. It is also sometimes abused together with | ||
| 3046 | @code{font-lock-syntactic-keywords} to highlight constructs that span | ||
| 3047 | multiple lines, but this is too esoteric to document here. | ||
| 3048 | |||
| 3049 | Specify this variable using @var{other-vars} in | ||
| 3050 | @code{font-lock-defaults}. | 3038 | @code{font-lock-defaults}. |
| 3051 | @end defvar | ||
| 3052 | |||
| 3053 | @node Setting Syntax Properties | ||
| 3054 | @subsection Setting Syntax Properties | ||
| 3055 | |||
| 3056 | Font Lock mode can be used to update @code{syntax-table} properties | ||
| 3057 | automatically (@pxref{Syntax Properties}). This is useful in | ||
| 3058 | languages for which a single syntax table by itself is not sufficient. | ||
| 3059 | |||
| 3060 | @defvar font-lock-syntactic-keywords | ||
| 3061 | This variable enables and controls updating @code{syntax-table} | ||
| 3062 | properties by Font Lock. Its value should be a list of elements of | ||
| 3063 | this form: | ||
| 3064 | |||
| 3065 | @example | ||
| 3066 | (@var{matcher} @var{subexp} @var{syntax} @var{override} @var{laxmatch}) | ||
| 3067 | @end example | ||
| 3068 | |||
| 3069 | The parts of this element have the same meanings as in the corresponding | ||
| 3070 | sort of element of @code{font-lock-keywords}, | ||
| 3071 | 3039 | ||
| 3072 | @example | 3040 | The function is called with one argument, the parse state at point |
| 3073 | (@var{matcher} @var{subexp} @var{facespec} @var{override} @var{laxmatch}) | 3041 | returned by @code{parse-partial-sexp}, and should return a face. The |
| 3074 | @end example | 3042 | default value returns @code{font-lock-comment-face} for comments and |
| 3075 | 3043 | @code{font-lock-string-face} for strings (@pxref{Faces for Font Lock}). | |
| 3076 | However, instead of specifying the value @var{facespec} to use for the | ||
| 3077 | @code{face} property, it specifies the value @var{syntax} to use for | ||
| 3078 | the @code{syntax-table} property. Here, @var{syntax} can be a string | ||
| 3079 | (as taken by @code{modify-syntax-entry}), a syntax table, a cons cell | ||
| 3080 | (as returned by @code{string-to-syntax}), or an expression whose value | ||
| 3081 | is one of those two types. @var{override} cannot be @code{prepend} or | ||
| 3082 | @code{append}. | ||
| 3083 | |||
| 3084 | For example, an element of the form: | ||
| 3085 | |||
| 3086 | @example | ||
| 3087 | ("\\$\\(#\\)" 1 ".") | ||
| 3088 | @end example | ||
| 3089 | |||
| 3090 | highlights syntactically a hash character when following a dollar | ||
| 3091 | character, with a SYNTAX of @code{"."} (meaning punctuation syntax). | ||
| 3092 | Assuming that the buffer syntax table specifies hash characters to | ||
| 3093 | have comment start syntax, the element will only highlight hash | ||
| 3094 | characters that do not follow dollar characters as comments | ||
| 3095 | syntactically. | ||
| 3096 | |||
| 3097 | An element of the form: | ||
| 3098 | |||
| 3099 | @example | ||
| 3100 | ("\\('\\).\\('\\)" | ||
| 3101 | (1 "\"") | ||
| 3102 | (2 "\"")) | ||
| 3103 | @end example | ||
| 3104 | |||
| 3105 | highlights syntactically both single quotes which surround a single | ||
| 3106 | character, with a SYNTAX of @code{"\""} (meaning string quote syntax). | ||
| 3107 | Assuming that the buffer syntax table does not specify single quotes | ||
| 3108 | to have quote syntax, the element will only highlight single quotes of | ||
| 3109 | the form @samp{'@var{c}'} as strings syntactically. Other forms, such | ||
| 3110 | as @samp{foo'bar} or @samp{'fubar'}, will not be highlighted as | ||
| 3111 | strings. | ||
| 3112 | |||
| 3113 | Major modes normally set this variable with @var{other-vars} in | ||
| 3114 | @code{font-lock-defaults}. | ||
| 3115 | @end defvar | 3044 | @end defvar |
| 3116 | 3045 | ||
| 3117 | @node Multiline Font Lock | 3046 | @node Multiline Font Lock |
| @@ -3220,18 +3149,17 @@ easy to add the @code{font-lock-multiline} property by hand. | |||
| 3220 | 3149 | ||
| 3221 | The @code{font-lock-multiline} property is meant to ensure proper | 3150 | The @code{font-lock-multiline} property is meant to ensure proper |
| 3222 | refontification; it does not automatically identify new multiline | 3151 | refontification; it does not automatically identify new multiline |
| 3223 | constructs. Identifying the requires that Font-Lock operate on large | 3152 | constructs. Identifying the requires that Font Lock mode operate on |
| 3224 | enough chunks at a time. This will happen by accident on many cases, | 3153 | large enough chunks at a time. This will happen by accident on many |
| 3225 | which may give the impression that multiline constructs magically work. | 3154 | cases, which may give the impression that multiline constructs magically |
| 3226 | If you set the @code{font-lock-multiline} variable non-@code{nil}, | 3155 | work. If you set the @code{font-lock-multiline} variable |
| 3227 | this impression will be even stronger, since the highlighting of those | 3156 | non-@code{nil}, this impression will be even stronger, since the |
| 3228 | constructs which are found will be properly updated from then on. | 3157 | highlighting of those constructs which are found will be properly |
| 3229 | But that does not work reliably. | 3158 | updated from then on. But that does not work reliably. |
| 3230 | 3159 | ||
| 3231 | To find multiline constructs reliably, you must either manually | 3160 | To find multiline constructs reliably, you must either manually place |
| 3232 | place the @code{font-lock-multiline} property on the text before | 3161 | the @code{font-lock-multiline} property on the text before Font Lock |
| 3233 | Font-Lock looks at it, or use | 3162 | mode looks at it, or use @code{font-lock-fontify-region-function}. |
| 3234 | @code{font-lock-fontify-region-function}. | ||
| 3235 | 3163 | ||
| 3236 | @node Region to Refontify | 3164 | @node Region to Refontify |
| 3237 | @subsubsection Region to Fontify after a Buffer Change | 3165 | @subsubsection Region to Fontify after a Buffer Change |
| @@ -3246,8 +3174,8 @@ earlier line. | |||
| 3246 | the following variable: | 3174 | the following variable: |
| 3247 | 3175 | ||
| 3248 | @defvar font-lock-extend-after-change-region-function | 3176 | @defvar font-lock-extend-after-change-region-function |
| 3249 | This buffer-local variable is either @code{nil} or a function for | 3177 | This buffer-local variable is either @code{nil} or a function for Font |
| 3250 | Font-Lock to call to determine the region to scan and fontify. | 3178 | Lock mode to call to determine the region to scan and fontify. |
| 3251 | 3179 | ||
| 3252 | The function is given three parameters, the standard @var{beg}, | 3180 | The function is given three parameters, the standard @var{beg}, |
| 3253 | @var{end}, and @var{old-len} from @code{after-change-functions} | 3181 | @var{end}, and @var{old-len} from @code{after-change-functions} |
diff --git a/doc/lispref/syntax.texi b/doc/lispref/syntax.texi index 3d153e43b2d..8b3e3a3febb 100644 --- a/doc/lispref/syntax.texi +++ b/doc/lispref/syntax.texi | |||
| @@ -536,9 +536,7 @@ execution starts. Other buffers are not affected. | |||
| 536 | When the syntax table is not flexible enough to specify the syntax of | 536 | When the syntax table is not flexible enough to specify the syntax of |
| 537 | a language, you can use @code{syntax-table} text properties to | 537 | a language, you can use @code{syntax-table} text properties to |
| 538 | override the syntax table for specific character occurrences in the | 538 | override the syntax table for specific character occurrences in the |
| 539 | buffer. @xref{Text Properties}. You can use Font Lock mode to set | 539 | buffer. @xref{Text Properties}. |
| 540 | @code{syntax-table} text properties. @xref{Setting Syntax | ||
| 541 | Properties}. | ||
| 542 | 540 | ||
| 543 | The valid values of @code{syntax-table} text property are: | 541 | The valid values of @code{syntax-table} text property are: |
| 544 | 542 | ||
diff --git a/doc/lispref/vol1.texi b/doc/lispref/vol1.texi index dbab287b273..c0d5767697d 100644 --- a/doc/lispref/vol1.texi +++ b/doc/lispref/vol1.texi | |||
| @@ -835,8 +835,6 @@ Font Lock Mode | |||
| 835 | contents can also specify how to fontify it. | 835 | contents can also specify how to fontify it. |
| 836 | * Faces for Font Lock:: Special faces specifically for Font Lock. | 836 | * Faces for Font Lock:: Special faces specifically for Font Lock. |
| 837 | * Syntactic Font Lock:: Fontification based on syntax tables. | 837 | * Syntactic Font Lock:: Fontification based on syntax tables. |
| 838 | * Setting Syntax Properties:: Defining character syntax based on context | ||
| 839 | using the Font Lock mechanism. | ||
| 840 | * Multiline Font Lock:: How to coerce Font Lock into properly | 838 | * Multiline Font Lock:: How to coerce Font Lock into properly |
| 841 | highlighting multiline constructs. | 839 | highlighting multiline constructs. |
| 842 | 840 | ||
diff --git a/doc/lispref/vol2.texi b/doc/lispref/vol2.texi index 38e2f1dc5e9..0c6deb5671a 100644 --- a/doc/lispref/vol2.texi +++ b/doc/lispref/vol2.texi | |||
| @@ -834,8 +834,6 @@ Font Lock Mode | |||
| 834 | contents can also specify how to fontify it. | 834 | contents can also specify how to fontify it. |
| 835 | * Faces for Font Lock:: Special faces specifically for Font Lock. | 835 | * Faces for Font Lock:: Special faces specifically for Font Lock. |
| 836 | * Syntactic Font Lock:: Fontification based on syntax tables. | 836 | * Syntactic Font Lock:: Fontification based on syntax tables. |
| 837 | * Setting Syntax Properties:: Defining character syntax based on context | ||
| 838 | using the Font Lock mechanism. | ||
| 839 | * Multiline Font Lock:: How to coerce Font Lock into properly | 837 | * Multiline Font Lock:: How to coerce Font Lock into properly |
| 840 | highlighting multiline constructs. | 838 | highlighting multiline constructs. |
| 841 | 839 | ||