Mercurial > emacs
comparison lispref/modes.texi @ 52628:74d358d76ea8
(Mode Line Data): Document the :propertize construct.
(Mode Line Variables): Reorder the descriptions of the variables
to match their order in the default mode-line-format.
Describe the new variables mode-line-position and mode-line-modes.
Update the default values of mode-line-frame-identification,
minor-mode-alist, and default-mode-line-format.
(Properties in Mode): Mention the :propertize construct.
author | Lute Kamstra <lute@gnu.org> |
---|---|
date | Fri, 26 Sep 2003 12:15:32 +0000 |
parents | be54b19bb668 |
children | 5f70316d2ec5 |
comparison
equal
deleted
inserted
replaced
52627:e3a0f4e62b53 | 52628:74d358d76ea8 |
---|---|
272 settings. A mode that does this is called a @dfn{derived mode}. The | 272 settings. A mode that does this is called a @dfn{derived mode}. The |
273 recommended way to define one is to use @code{define-derived-mode}, | 273 recommended way to define one is to use @code{define-derived-mode}, |
274 but this is not required. Such a mode should use | 274 but this is not required. Such a mode should use |
275 @code{delay-mode-hooks} around its entire body, including the call to | 275 @code{delay-mode-hooks} around its entire body, including the call to |
276 the parent mode command and the final call to @code{run-mode-hooks}. | 276 the parent mode command and the final call to @code{run-mode-hooks}. |
277 (Using @code{define-derived-mode} does this automatically.) | 277 (Using @code{define-derived-mode} does this automatically.) |
278 | 278 |
279 @item | 279 @item |
280 If something special should be done if the user switches a buffer from | 280 If something special should be done if the user switches a buffer from |
281 this mode to any other major mode, this mode can set up a buffer-local | 281 this mode to any other major mode, this mode can set up a buffer-local |
282 value for @code{change-major-mode-hook} (@pxref{Creating Buffer-Local}). | 282 value for @code{change-major-mode-hook} (@pxref{Creating Buffer-Local}). |
1099 (hungry-electric-delete t)))) | 1099 (hungry-electric-delete t)))) |
1100 :group 'hunger) | 1100 :group 'hunger) |
1101 @end smallexample | 1101 @end smallexample |
1102 | 1102 |
1103 @node Mode Line Format | 1103 @node Mode Line Format |
1104 @section Mode Line Format | 1104 @section Mode-Line Format |
1105 @cindex mode line | 1105 @cindex mode line |
1106 | 1106 |
1107 Each Emacs window (aside from minibuffer windows) typically has a mode | 1107 Each Emacs window (aside from minibuffer windows) typically has a mode |
1108 line at the bottom, which displays status information about the buffer | 1108 line at the bottom, which displays status information about the buffer |
1109 displayed in the window. The mode line contains information about the | 1109 displayed in the window. The mode line contains information about the |
1164 * Emulating Mode Line:: Formatting text as the mode line would. | 1164 * Emulating Mode Line:: Formatting text as the mode line would. |
1165 @end menu | 1165 @end menu |
1166 | 1166 |
1167 @node Mode Line Data | 1167 @node Mode Line Data |
1168 @subsection The Data Structure of the Mode Line | 1168 @subsection The Data Structure of the Mode Line |
1169 @cindex mode line construct | 1169 @cindex mode-line construct |
1170 | 1170 |
1171 The mode line contents are controlled by a data structure of lists, | 1171 The mode-line contents are controlled by a data structure of lists, |
1172 strings, symbols, and numbers kept in buffer-local variables. The data | 1172 strings, symbols, and numbers kept in buffer-local variables. The data |
1173 structure is called a @dfn{mode line construct}, and it is built in | 1173 structure is called a @dfn{mode-line construct}, and it is built in |
1174 recursive fashion out of simpler mode line constructs. The same data | 1174 recursive fashion out of simpler mode-line constructs. The same data |
1175 structure is used for constructing frame titles (@pxref{Frame Titles}) | 1175 structure is used for constructing frame titles (@pxref{Frame Titles}) |
1176 and header lines (@pxref{Header Lines}). | 1176 and header lines (@pxref{Header Lines}). |
1177 | 1177 |
1178 @defvar mode-line-format | 1178 @defvar mode-line-format |
1179 The value of this variable is a mode line construct with overall | 1179 The value of this variable is a mode-line construct with overall |
1180 responsibility for the mode line format. The value of this variable | 1180 responsibility for the mode-line format. The value of this variable |
1181 controls which other variables are used to form the mode line text, and | 1181 controls which other variables are used to form the mode-line text, and |
1182 where they appear. | 1182 where they appear. |
1183 | 1183 |
1184 If you set this variable to @code{nil} in a buffer, that buffer does not | 1184 If you set this variable to @code{nil} in a buffer, that buffer does not |
1185 have a mode line. (This feature was added in Emacs 21.) | 1185 have a mode line. (This feature was added in Emacs 21.) |
1186 @end defvar | 1186 @end defvar |
1187 | 1187 |
1188 A mode line construct may be as simple as a fixed string of text, but | 1188 A mode-line construct may be as simple as a fixed string of text, but |
1189 it usually specifies how to use other variables to construct the text. | 1189 it usually specifies how to use other variables to construct the text. |
1190 Many of these variables are themselves defined to have mode line | 1190 Many of these variables are themselves defined to have mode-line |
1191 constructs as their values. | 1191 constructs as their values. |
1192 | 1192 |
1193 The default value of @code{mode-line-format} incorporates the values | 1193 The default value of @code{mode-line-format} incorporates the values |
1194 of variables such as @code{mode-name} and @code{minor-mode-alist}. | 1194 of variables such as @code{mode-line-position} and |
1195 Because of this, very few modes need to alter @code{mode-line-format} | 1195 @code{mode-line-modes} (which in turn incorporates the values of the |
1196 itself. For most purposes, it is sufficient to alter some of the | 1196 variables @code{mode-name} and @code{minor-mode-alist}). Because of |
1197 variables that @code{mode-line-format} refers to. | 1197 this, very few modes need to alter @code{mode-line-format} itself. For |
1198 | 1198 most purposes, it is sufficient to alter some of the variables that |
1199 A mode line construct may be a list, a symbol, or a string. If the | 1199 @code{mode-line-format} either directly or indirectly refers to. |
1200 | |
1201 A mode-line construct may be a list, a symbol, or a string. If the | |
1200 value is a list, each element may be a list, a symbol, or a string. | 1202 value is a list, each element may be a list, a symbol, or a string. |
1201 | 1203 |
1202 The mode line can display various faces, if the strings that control | 1204 The mode line can display various faces, if the strings that control |
1203 it have the @code{face} property. @xref{Properties in Mode}. In | 1205 it have the @code{face} property. @xref{Properties in Mode}. In |
1204 addition, the face @code{mode-line} is used as a default for the whole | 1206 addition, the face @code{mode-line} is used as a default for the whole |
1205 mode line (@pxref{Standard Faces}). | 1207 mode line (@pxref{Standard Faces}). |
1206 | 1208 |
1207 @table @code | 1209 @table @code |
1208 @cindex percent symbol in mode line | 1210 @cindex percent symbol in mode line |
1209 @item @var{string} | 1211 @item @var{string} |
1210 A string as a mode line construct is displayed verbatim in the mode line | 1212 A string as a mode-line construct is displayed verbatim in the mode line |
1211 except for @dfn{@code{%}-constructs}. Decimal digits after the @samp{%} | 1213 except for @dfn{@code{%}-constructs}. Decimal digits after the @samp{%} |
1212 specify the field width for space filling on the right (i.e., the data | 1214 specify the field width for space filling on the right (i.e., the data |
1213 is left justified). @xref{%-Constructs}. | 1215 is left justified). @xref{%-Constructs}. |
1214 | 1216 |
1215 @item @var{symbol} | 1217 @item @var{symbol} |
1216 A symbol as a mode line construct stands for its value. The value of | 1218 A symbol as a mode-line construct stands for its value. The value of |
1217 @var{symbol} is used as a mode line construct, in place of @var{symbol}. | 1219 @var{symbol} is used as a mode-line construct, in place of @var{symbol}. |
1218 However, the symbols @code{t} and @code{nil} are ignored, as is any | 1220 However, the symbols @code{t} and @code{nil} are ignored, as is any |
1219 symbol whose value is void. | 1221 symbol whose value is void. |
1220 | 1222 |
1221 There is one exception: if the value of @var{symbol} is a string, it is | 1223 There is one exception: if the value of @var{symbol} is a string, it is |
1222 displayed verbatim: the @code{%}-constructs are not recognized. | 1224 displayed verbatim: the @code{%}-constructs are not recognized. |
1223 | 1225 |
1224 @item (@var{string} @var{rest}@dots{}) @r{or} (@var{list} @var{rest}@dots{}) | 1226 @item (@var{string} @var{rest}@dots{}) @r{or} (@var{list} @var{rest}@dots{}) |
1225 A list whose first element is a string or list means to process all the | 1227 A list whose first element is a string or list means to process all the |
1226 elements recursively and concatenate the results. This is the most | 1228 elements recursively and concatenate the results. This is the most |
1227 common form of mode line construct. | 1229 common form of mode-line construct. |
1228 | 1230 |
1229 @item (:eval @var{form}) | 1231 @item (:eval @var{form}) |
1230 A list whose first element is the symbol @code{:eval} says to evaluate | 1232 A list whose first element is the symbol @code{:eval} says to evaluate |
1231 @var{form}, and use the result as a string to display. | 1233 @var{form}, and use the result as a string to display. |
1232 (This feature is new as of Emacs 21.) | 1234 (This feature is new as of Emacs 21.) |
1233 | 1235 |
1236 @item (:propertize @var{elt} @var{props}@dots{}) | |
1237 A list whose first element is the symbol @code{:propertize} says to | |
1238 process the mode-line construct @var{elt} recursively and add the text | |
1239 properties specified by @var{props} to the result. The argument | |
1240 @var{props} should consist of zero or more pairs @var{text-property} | |
1241 @var{value}. (This feature is new as of Emacs 21.4.) | |
1242 @c FIXME: This might be Emacs 21.5. | |
1243 | |
1234 @item (@var{symbol} @var{then} @var{else}) | 1244 @item (@var{symbol} @var{then} @var{else}) |
1235 A list whose first element is a symbol that is not a keyword specifies a | 1245 A list whose first element is a symbol that is not a keyword specifies a |
1236 conditional. Its meaning depends on the value of @var{symbol}. If the | 1246 conditional. Its meaning depends on the value of @var{symbol}. If the |
1237 value is non-@code{nil}, the second element, @var{then}, is processed | 1247 value is non-@code{nil}, the second element, @var{then}, is processed |
1238 recursively as a mode line element. But if the value of @var{symbol} is | 1248 recursively as a mode-line element. But if the value of @var{symbol} is |
1239 @code{nil}, the third element, @var{else}, is processed recursively. | 1249 @code{nil}, the third element, @var{else}, is processed recursively. |
1240 You may omit @var{else}; then the mode line element displays nothing if | 1250 You may omit @var{else}; then the mode-line element displays nothing if |
1241 the value of @var{symbol} is @code{nil}. | 1251 the value of @var{symbol} is @code{nil}. |
1242 | 1252 |
1243 @item (@var{width} @var{rest}@dots{}) | 1253 @item (@var{width} @var{rest}@dots{}) |
1244 A list whose first element is an integer specifies truncation or | 1254 A list whose first element is an integer specifies truncation or |
1245 padding of the results of @var{rest}. The remaining elements | 1255 padding of the results of @var{rest}. The remaining elements |
1246 @var{rest} are processed recursively as mode line constructs and | 1256 @var{rest} are processed recursively as mode-line constructs and |
1247 concatenated together. Then the result is space filled (if | 1257 concatenated together. Then the result is space filled (if |
1248 @var{width} is positive) or truncated (to @minus{}@var{width} columns, | 1258 @var{width} is positive) or truncated (to @minus{}@var{width} columns, |
1249 if @var{width} is negative) on the right. | 1259 if @var{width} is negative) on the right. |
1250 | 1260 |
1251 For example, the usual way to show what percentage of a buffer is above | 1261 For example, the usual way to show what percentage of a buffer is above |
1273 'mode-line-frame-identification | 1283 'mode-line-frame-identification |
1274 "%b--" | 1284 "%b--" |
1275 @end group | 1285 @end group |
1276 @group | 1286 @group |
1277 ;; @r{Note that this is evaluated while making the list.} | 1287 ;; @r{Note that this is evaluated while making the list.} |
1278 ;; @r{It makes a mode line construct which is just a string.} | 1288 ;; @r{It makes a mode-line construct which is just a string.} |
1279 (getenv "HOST") | 1289 (getenv "HOST") |
1280 @end group | 1290 @end group |
1281 ":" | 1291 ":" |
1282 'default-directory | 1292 'default-directory |
1283 " " | 1293 " " |
1330 Changing this variable does not force an update of the mode line. | 1340 Changing this variable does not force an update of the mode line. |
1331 @end defvar | 1341 @end defvar |
1332 | 1342 |
1333 @defvar mode-line-frame-identification | 1343 @defvar mode-line-frame-identification |
1334 This variable identifies the current frame. The default value is | 1344 This variable identifies the current frame. The default value is |
1335 @code{" "} if you are using a window system which can show multiple | 1345 @code{" "} if you are using a window system which can show multiple |
1336 frames, or @code{"-%F "} on an ordinary terminal which shows only one | 1346 frames, or @code{"-%F "} on an ordinary terminal which shows only one |
1337 frame at a time. | 1347 frame at a time. |
1338 @end defvar | 1348 @end defvar |
1339 | 1349 |
1340 @defvar mode-line-buffer-identification | 1350 @defvar mode-line-buffer-identification |
1341 This variable identifies the buffer being displayed in the window. Its | 1351 This variable identifies the buffer being displayed in the window. Its |
1342 default value is @code{("%12b")}, which displays the buffer name, padded | 1352 default value is @code{("%12b")}, which displays the buffer name, padded |
1343 with spaces to at least 12 columns. | 1353 with spaces to at least 12 columns. |
1344 @end defvar | 1354 @end defvar |
1345 | 1355 |
1346 @defvar global-mode-string | 1356 @defvar mode-line-position |
1347 This variable holds a mode line spec that appears in the mode line by | 1357 This variable indicates the position in the buffer. Here is a |
1348 default, just after the buffer name. The command @code{display-time} | 1358 simplified version of its default value. The actual default value |
1349 sets @code{global-mode-string} to refer to the variable | 1359 also specifies addition of the @code{help-echo} text property. |
1350 @code{display-time-string}, which holds a string containing the time and | 1360 |
1351 load information. | 1361 @example |
1352 | 1362 @group |
1353 The @samp{%M} construct substitutes the value of | 1363 ((-3 . "%p") |
1354 @code{global-mode-string}, but that is obsolete, since the variable is | 1364 (size-indication-mode (8 " of %I")) |
1355 included in the mode line from @code{mode-line-format}. | 1365 @end group |
1356 @end defvar | 1366 @group |
1367 (line-number-mode | |
1368 ((column-number-mode | |
1369 (10 " (%l,%c)") | |
1370 (6 " L%l"))) | |
1371 ((column-number-mode | |
1372 (5 " C%c"))))) | |
1373 @end group | |
1374 @end example | |
1375 | |
1376 This means that @code{mode-line-position} displays at least the buffer | |
1377 percentage and possibly the buffer size, the line number and the column | |
1378 number. | |
1379 @end defvar | |
1380 | |
1381 @defvar vc-mode | |
1382 The variable @code{vc-mode}, buffer-local in each buffer, records | |
1383 whether the buffer's visited file is maintained with version control, | |
1384 and, if so, which kind. Its value is a string that appears in the mode | |
1385 line, or @code{nil} for no version control. | |
1386 @end defvar | |
1387 | |
1388 @defvar mode-line-modes | |
1389 This variable displays the buffer's major and minor modes. Here is a | |
1390 simplified version of its default value. The real default value also | |
1391 specifies addition of text properties. | |
1392 | |
1393 @example | |
1394 @group | |
1395 ("%[(" mode-name | |
1396 mode-line-process minor-mode-alist | |
1397 "%n" ")%]--") | |
1398 @end group | |
1399 @end example | |
1400 | |
1401 So @code{mode-line-modes} normally also displays the recursive editing | |
1402 level, information on the process status and whether narrowing is in | |
1403 effect. | |
1404 @end defvar | |
1405 | |
1406 The following three variables are used in @code{mode-line-modes}: | |
1357 | 1407 |
1358 @defvar mode-name | 1408 @defvar mode-name |
1359 This buffer-local variable holds the ``pretty'' name of the current | 1409 This buffer-local variable holds the ``pretty'' name of the current |
1360 buffer's major mode. Each major mode should set this variable so that the | 1410 buffer's major mode. Each major mode should set this variable so that the |
1361 mode name will appear in the mode line. | 1411 mode name will appear in the mode line. |
1362 @end defvar | 1412 @end defvar |
1363 | 1413 |
1364 @defvar minor-mode-alist | |
1365 This variable holds an association list whose elements specify how the | |
1366 mode line should indicate that a minor mode is active. Each element of | |
1367 the @code{minor-mode-alist} should be a two-element list: | |
1368 | |
1369 @example | |
1370 (@var{minor-mode-variable} @var{mode-line-string}) | |
1371 @end example | |
1372 | |
1373 More generally, @var{mode-line-string} can be any mode line spec. It | |
1374 appears in the mode line when the value of @var{minor-mode-variable} is | |
1375 non-@code{nil}, and not otherwise. These strings should begin with | |
1376 spaces so that they don't run together. Conventionally, the | |
1377 @var{minor-mode-variable} for a specific mode is set to a non-@code{nil} | |
1378 value when that minor mode is activated. | |
1379 | |
1380 The default value of @code{minor-mode-alist} is: | |
1381 | |
1382 @example | |
1383 @group | |
1384 minor-mode-alist | |
1385 @result{} ((vc-mode vc-mode) | |
1386 (abbrev-mode " Abbrev") | |
1387 (overwrite-mode overwrite-mode) | |
1388 (auto-fill-function " Fill") | |
1389 (defining-kbd-macro " Def") | |
1390 (isearch-mode isearch-mode)) | |
1391 @end group | |
1392 @end example | |
1393 | |
1394 @code{minor-mode-alist} itself is not buffer-local. Each variable | |
1395 mentioned in the alist should be buffer-local if its minor mode can be | |
1396 enabled separately in each buffer. | |
1397 @end defvar | |
1398 | |
1399 @defvar mode-line-process | 1414 @defvar mode-line-process |
1400 This buffer-local variable contains the mode line information on process | 1415 This buffer-local variable contains the mode-line information on process |
1401 status in modes used for communicating with subprocesses. It is | 1416 status in modes used for communicating with subprocesses. It is |
1402 displayed immediately following the major mode name, with no intervening | 1417 displayed immediately following the major mode name, with no intervening |
1403 space. For example, its value in the @samp{*shell*} buffer is | 1418 space. For example, its value in the @samp{*shell*} buffer is |
1404 @code{(":%s")}, which allows the shell to display its status along | 1419 @code{(":%s")}, which allows the shell to display its status along |
1405 with the major mode as: @samp{(Shell:run)}. Normally this variable | 1420 with the major mode as: @samp{(Shell:run)}. Normally this variable |
1406 is @code{nil}. | 1421 is @code{nil}. |
1407 @end defvar | 1422 @end defvar |
1408 | 1423 |
1409 Some variables are used by @code{minor-mode-alist} to display | 1424 @defvar minor-mode-alist |
1410 a string for various minor modes when enabled. This is a typical | 1425 This variable holds an association list whose elements specify how the |
1411 example: | 1426 mode line should indicate that a minor mode is active. Each element of |
1412 | 1427 the @code{minor-mode-alist} should be a two-element list: |
1413 @defvar vc-mode | 1428 |
1414 The variable @code{vc-mode}, buffer-local in each buffer, records | 1429 @example |
1415 whether the buffer's visited file is maintained with version control, | 1430 (@var{minor-mode-variable} @var{mode-line-string}) |
1416 and, if so, which kind. Its value is a string that appears in the mode | 1431 @end example |
1417 line, or @code{nil} for no version control. | 1432 |
1433 More generally, @var{mode-line-string} can be any mode-line spec. It | |
1434 appears in the mode line when the value of @var{minor-mode-variable} | |
1435 is non-@code{nil}, and not otherwise. These strings should begin with | |
1436 spaces so that they don't run together. Conventionally, the | |
1437 @var{minor-mode-variable} for a specific mode is set to a | |
1438 non-@code{nil} value when that minor mode is activated. | |
1439 | |
1440 @code{minor-mode-alist} itself is not buffer-local. Each variable | |
1441 mentioned in the alist should be buffer-local if its minor mode can be | |
1442 enabled separately in each buffer. | |
1443 @end defvar | |
1444 | |
1445 @defvar global-mode-string | |
1446 This variable holds a mode-line spec that appears in the mode line by | |
1447 default, just after the buffer name. The command @code{display-time} | |
1448 sets @code{global-mode-string} to refer to the variable | |
1449 @code{display-time-string}, which holds a string containing the time and | |
1450 load information. | |
1451 | |
1452 The @samp{%M} construct substitutes the value of | |
1453 @code{global-mode-string}, but that is obsolete, since the variable is | |
1454 included in the mode line from @code{mode-line-format}. | |
1418 @end defvar | 1455 @end defvar |
1419 | 1456 |
1420 The variable @code{default-mode-line-format} is where | 1457 The variable @code{default-mode-line-format} is where |
1421 @code{mode-line-format} usually gets its value: | 1458 @code{mode-line-format} usually gets its value: |
1422 | 1459 |
1423 @defvar default-mode-line-format | 1460 @defvar default-mode-line-format |
1424 This variable holds the default @code{mode-line-format} for buffers | 1461 This variable holds the default @code{mode-line-format} for buffers |
1425 that do not override it. This is the same as @code{(default-value | 1462 that do not override it. This is the same as @code{(default-value |
1426 'mode-line-format)}. | 1463 'mode-line-format)}. |
1427 | 1464 |
1428 The default value of @code{default-mode-line-format} is this list: | 1465 Here is a simplified version of the default value of |
1466 @code{default-mode-line-format}. The real default value also | |
1467 specifies addition of text properties. | |
1429 | 1468 |
1430 @example | 1469 @example |
1431 @group | 1470 @group |
1432 ("-" | 1471 ("-" |
1433 mode-line-mule-info | 1472 mode-line-mule-info |
1434 mode-line-modified | 1473 mode-line-modified |
1435 mode-line-frame-identification | 1474 mode-line-frame-identification |
1436 mode-line-buffer-identification | 1475 mode-line-buffer-identification |
1437 @end group | 1476 @end group |
1438 " " | 1477 " " |
1439 global-mode-string | 1478 mode-line-position |
1440 @group | 1479 (vc-mode vc-mode) |
1441 " %[(" | 1480 " " |
1442 ;; @r{@code{mode-line-mode-name} is a function} | 1481 @group |
1443 ;; @r{that copies the mode name and adds text} | 1482 mode-line-modes |
1444 ;; @r{properties to make it mouse-sensitive.} | |
1445 (:eval (mode-line-mode-name)) | |
1446 mode-line-process | |
1447 minor-mode-alist | |
1448 "%n" | |
1449 ")%]--" | |
1450 @end group | |
1451 @group | |
1452 (which-func-mode ("" which-func-format "--")) | 1483 (which-func-mode ("" which-func-format "--")) |
1453 (line-number-mode "L%l--") | 1484 (global-mode-string ("--" global-mode-string)) |
1454 (column-number-mode "C%c--") | |
1455 (-3 . "%p") | |
1456 "-%-") | 1485 "-%-") |
1457 @end group | 1486 @end group |
1458 @end example | 1487 @end example |
1459 @end defvar | 1488 @end defvar |
1460 | 1489 |
1562 @code{display-time} modifies the value of @code{global-mode-string}. | 1591 @code{display-time} modifies the value of @code{global-mode-string}. |
1563 @end table | 1592 @end table |
1564 | 1593 |
1565 @node Properties in Mode | 1594 @node Properties in Mode |
1566 @subsection Properties in the Mode Line | 1595 @subsection Properties in the Mode Line |
1596 @cindex text properties in the mode line | |
1567 | 1597 |
1568 Starting in Emacs 21, certain text properties are meaningful in the | 1598 Starting in Emacs 21, certain text properties are meaningful in the |
1569 mode line. The @code{face} property affects the appearance of text; the | 1599 mode line. The @code{face} property affects the appearance of text; the |
1570 @code{help-echo} property associate help strings with the text, and | 1600 @code{help-echo} property associate help strings with the text, and |
1571 @code{local-map} can make the text mouse-sensitive. | 1601 @code{local-map} can make the text mouse-sensitive. |
1572 | 1602 |
1573 There are three ways to specify text properties for text in the mode | 1603 There are four ways to specify text properties for text in the mode |
1574 line: | 1604 line: |
1575 | 1605 |
1576 @enumerate | 1606 @enumerate |
1577 @item | 1607 @item |
1578 Put a string with the @code{local-map} property directly into the | 1608 Put a string with a text property directly into the mode-line data |
1579 mode-line data structure. | 1609 structure. |
1580 | 1610 |
1581 @item | 1611 @item |
1582 Put a @code{local-map} property on a mode-line %-construct | 1612 Put a text property on a mode-line %-construct such as @samp{%12b}; then |
1583 such as @samp{%12b}; then the expansion of the %-construct | 1613 the expansion of the %-construct will have that same text property. |
1584 will have that same text property. | 1614 |
1615 @item | |
1616 Use a @code{(:propertize @var{elt} @var{props}@dots{})} construct to | |
1617 give @var{elt} a text property specified by @var{props}. | |
1585 | 1618 |
1586 @item | 1619 @item |
1587 Use a list containing @code{:eval @var{form}} in the mode-line data | 1620 Use a list containing @code{:eval @var{form}} in the mode-line data |
1588 structure, and make @var{form} evaluate to a string that has a | 1621 structure, and make @var{form} evaluate to a string that has a text |
1589 @code{local-map} property. | 1622 property. |
1590 @end enumerate | 1623 @end enumerate |
1591 | 1624 |
1592 You use the @code{local-map} property to specify a keymap. Like any | 1625 You use the @code{local-map} property to specify a keymap. Like any |
1593 keymap, it can bind character keys and function keys; but that has no | 1626 keymap, it can bind character keys and function keys; but that has no |
1594 effect, since it is impossible to move point into the mode line. This | 1627 effect, since it is impossible to move point into the mode line. This |
1599 @cindex header line (of a window) | 1632 @cindex header line (of a window) |
1600 @cindex window header line | 1633 @cindex window header line |
1601 | 1634 |
1602 Starting in Emacs 21, a window can have a @dfn{header line} at the | 1635 Starting in Emacs 21, a window can have a @dfn{header line} at the |
1603 top, just as it can have a mode line at the bottom. The header line | 1636 top, just as it can have a mode line at the bottom. The header line |
1604 feature works just like the mode line feature, except that it's | 1637 feature works just like the mode-line feature, except that it's |
1605 controlled by different variables. | 1638 controlled by different variables. |
1606 | 1639 |
1607 @tindex header-line-format | 1640 @tindex header-line-format |
1608 @defvar header-line-format | 1641 @defvar header-line-format |
1609 This variable, local in every buffer, specifies how to display the | 1642 This variable, local in every buffer, specifies how to display the |
1619 | 1652 |
1620 It is normally @code{nil}, so that ordinary buffers have no header line. | 1653 It is normally @code{nil}, so that ordinary buffers have no header line. |
1621 @end defvar | 1654 @end defvar |
1622 | 1655 |
1623 @node Emulating Mode Line | 1656 @node Emulating Mode Line |
1624 @subsection Emulating Mode Line Formatting | 1657 @subsection Emulating Mode-Line Formatting |
1625 | 1658 |
1626 You can use the function @code{format-mode-line} to compute | 1659 You can use the function @code{format-mode-line} to compute |
1627 the text that would appear in a mode line or header line | 1660 the text that would appear in a mode line or header line |
1628 based on certain mode line specification. | 1661 based on certain mode-line specification. |
1629 | 1662 |
1630 @defun format-mode-line &optional format window no-props | 1663 @defun format-mode-line &optional format window no-props |
1631 This function formats a line of text according to @var{format} as if | 1664 This function formats a line of text according to @var{format} as if |
1632 it were generating the mode line for @var{window}, but instead of | 1665 it were generating the mode line for @var{window}, but instead of |
1633 displaying the text in the mode line or the header line, it returns | 1666 displaying the text in the mode line or the header line, it returns |
2212 In addition to using @code{font-lock-defaults} for search-based | 2245 In addition to using @code{font-lock-defaults} for search-based |
2213 fontification, you may use the special character property | 2246 fontification, you may use the special character property |
2214 @code{font-lock-face} (@pxref{Special Properties}). This property | 2247 @code{font-lock-face} (@pxref{Special Properties}). This property |
2215 acts just like the explicit @code{face} property, but its activation | 2248 acts just like the explicit @code{face} property, but its activation |
2216 is toggled when the user calls @kbd{M-x font-lock-mode}. Using | 2249 is toggled when the user calls @kbd{M-x font-lock-mode}. Using |
2217 @code{font-lock-face} is especially conveninent for special modes | 2250 @code{font-lock-face} is especially convenient for special modes |
2218 which construct their text programmatically, such as | 2251 which construct their text programmatically, such as |
2219 @code{list-buffers} and @code{occur}. | 2252 @code{list-buffers} and @code{occur}. |
2220 | 2253 |
2221 If your mode does not use any of the other machinery of Font Lock | 2254 If your mode does not use any of the other machinery of Font Lock |
2222 (i.e. it only uses the @code{font-lock-face} property), you can tell | 2255 (i.e. it only uses the @code{font-lock-face} property), you can tell |