aboutsummaryrefslogtreecommitdiffstats
path: root/lispref
diff options
context:
space:
mode:
authorLute Kamstra2003-09-26 12:15:32 +0000
committerLute Kamstra2003-09-26 12:15:32 +0000
commit06862374481b6ff54af8b7c52ec804984d3d6418 (patch)
tree0b672bc7284dab9ff7db6a8b3bce441908b02c9a /lispref
parent6142d1d06cbc870f82591f85eaa908541d9bb4f9 (diff)
downloademacs-06862374481b6ff54af8b7c52ec804984d3d6418.tar.gz
emacs-06862374481b6ff54af8b7c52ec804984d3d6418.zip
(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.
Diffstat (limited to 'lispref')
-rw-r--r--lispref/modes.texi235
1 files changed, 134 insertions, 101 deletions
diff --git a/lispref/modes.texi b/lispref/modes.texi
index 07725ab9870..b53246fd9fc 100644
--- a/lispref/modes.texi
+++ b/lispref/modes.texi
@@ -274,7 +274,7 @@ recommended way to define one is to use @code{define-derived-mode},
274but this is not required. Such a mode should use 274but 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
276the parent mode command and the final call to @code{run-mode-hooks}. 276the 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
280If something special should be done if the user switches a buffer from 280If something special should be done if the user switches a buffer from
@@ -1101,7 +1101,7 @@ See the command \\[hungry-electric-delete]."
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
@@ -1166,37 +1166,39 @@ actually appears.
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,
1172strings, symbols, and numbers kept in buffer-local variables. The data 1172strings, symbols, and numbers kept in buffer-local variables. The data
1173structure is called a @dfn{mode line construct}, and it is built in 1173structure is called a @dfn{mode-line construct}, and it is built in
1174recursive fashion out of simpler mode line constructs. The same data 1174recursive fashion out of simpler mode-line constructs. The same data
1175structure is used for constructing frame titles (@pxref{Frame Titles}) 1175structure is used for constructing frame titles (@pxref{Frame Titles})
1176and header lines (@pxref{Header Lines}). 1176and header lines (@pxref{Header Lines}).
1177 1177
1178@defvar mode-line-format 1178@defvar mode-line-format
1179The value of this variable is a mode line construct with overall 1179The value of this variable is a mode-line construct with overall
1180responsibility for the mode line format. The value of this variable 1180responsibility for the mode-line format. The value of this variable
1181controls which other variables are used to form the mode line text, and 1181controls which other variables are used to form the mode-line text, and
1182where they appear. 1182where they appear.
1183 1183
1184If you set this variable to @code{nil} in a buffer, that buffer does not 1184If you set this variable to @code{nil} in a buffer, that buffer does not
1185have a mode line. (This feature was added in Emacs 21.) 1185have 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
1189it usually specifies how to use other variables to construct the text. 1189it usually specifies how to use other variables to construct the text.
1190Many of these variables are themselves defined to have mode line 1190Many of these variables are themselves defined to have mode-line
1191constructs as their values. 1191constructs 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
1194of variables such as @code{mode-name} and @code{minor-mode-alist}. 1194of variables such as @code{mode-line-position} and
1195Because 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
1196itself. For most purposes, it is sufficient to alter some of the 1196variables @code{mode-name} and @code{minor-mode-alist}). Because of
1197variables that @code{mode-line-format} refers to. 1197this, very few modes need to alter @code{mode-line-format} itself. For
1198 1198most 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
1200value is a list, each element may be a list, a symbol, or a string. 1202value 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
@@ -1207,14 +1209,14 @@ mode line (@pxref{Standard Faces}).
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}
1210A string as a mode line construct is displayed verbatim in the mode line 1212A string as a mode-line construct is displayed verbatim in the mode line
1211except for @dfn{@code{%}-constructs}. Decimal digits after the @samp{%} 1213except for @dfn{@code{%}-constructs}. Decimal digits after the @samp{%}
1212specify the field width for space filling on the right (i.e., the data 1214specify the field width for space filling on the right (i.e., the data
1213is left justified). @xref{%-Constructs}. 1215is left justified). @xref{%-Constructs}.
1214 1216
1215@item @var{symbol} 1217@item @var{symbol}
1216A symbol as a mode line construct stands for its value. The value of 1218A 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}.
1218However, the symbols @code{t} and @code{nil} are ignored, as is any 1220However, the symbols @code{t} and @code{nil} are ignored, as is any
1219symbol whose value is void. 1221symbol whose value is void.
1220 1222
@@ -1224,26 +1226,34 @@ displayed verbatim: the @code{%}-constructs are not recognized.
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{})
1225A list whose first element is a string or list means to process all the 1227A list whose first element is a string or list means to process all the
1226elements recursively and concatenate the results. This is the most 1228elements recursively and concatenate the results. This is the most
1227common form of mode line construct. 1229common form of mode-line construct.
1228 1230
1229@item (:eval @var{form}) 1231@item (:eval @var{form})
1230A list whose first element is the symbol @code{:eval} says to evaluate 1232A 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{})
1237A list whose first element is the symbol @code{:propertize} says to
1238process the mode-line construct @var{elt} recursively and add the text
1239properties 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})
1235A list whose first element is a symbol that is not a keyword specifies a 1245A list whose first element is a symbol that is not a keyword specifies a
1236conditional. Its meaning depends on the value of @var{symbol}. If the 1246conditional. Its meaning depends on the value of @var{symbol}. If the
1237value is non-@code{nil}, the second element, @var{then}, is processed 1247value is non-@code{nil}, the second element, @var{then}, is processed
1238recursively as a mode line element. But if the value of @var{symbol} is 1248recursively 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.
1240You may omit @var{else}; then the mode line element displays nothing if 1250You may omit @var{else}; then the mode-line element displays nothing if
1241the value of @var{symbol} is @code{nil}. 1251the value of @var{symbol} is @code{nil}.
1242 1252
1243@item (@var{width} @var{rest}@dots{}) 1253@item (@var{width} @var{rest}@dots{})
1244A list whose first element is an integer specifies truncation or 1254A list whose first element is an integer specifies truncation or
1245padding of the results of @var{rest}. The remaining elements 1255padding 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
1247concatenated together. Then the result is space filled (if 1257concatenated 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,
1249if @var{width} is negative) on the right. 1259if @var{width} is negative) on the right.
@@ -1275,7 +1285,7 @@ directory.
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 ":"
@@ -1332,8 +1342,8 @@ Changing this variable does not force an update of the mode line.
1332 1342
1333@defvar mode-line-frame-identification 1343@defvar mode-line-frame-identification
1334This variable identifies the current frame. The default value is 1344This 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
1336frames, or @code{"-%F "} on an ordinary terminal which shows only one 1346frames, or @code{"-%F "} on an ordinary terminal which shows only one
1337frame at a time. 1347frame at a time.
1338@end defvar 1348@end defvar
1339 1349
@@ -1343,24 +1353,74 @@ default value is @code{("%12b")}, which displays the buffer name, padded
1343with spaces to at least 12 columns. 1353with spaces to at least 12 columns.
1344@end defvar 1354@end defvar
1345 1355
1346@defvar global-mode-string 1356@defvar mode-line-position
1347This variable holds a mode line spec that appears in the mode line by 1357This variable indicates the position in the buffer. Here is a
1348default, just after the buffer name. The command @code{display-time} 1358simplified version of its default value. The actual default value
1349sets @code{global-mode-string} to refer to the variable 1359also specifies addition of the @code{help-echo} text property.
1350@code{display-time-string}, which holds a string containing the time and
1351load information.
1352 1360
1353The @samp{%M} construct substitutes the value of 1361@example
1354@code{global-mode-string}, but that is obsolete, since the variable is 1362@group
1355included in the mode line from @code{mode-line-format}. 1363((-3 . "%p")
1364 (size-indication-mode (8 " of %I"))
1365@end group
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
1376This means that @code{mode-line-position} displays at least the buffer
1377percentage and possibly the buffer size, the line number and the column
1378number.
1379@end defvar
1380
1381@defvar vc-mode
1382The variable @code{vc-mode}, buffer-local in each buffer, records
1383whether the buffer's visited file is maintained with version control,
1384and, if so, which kind. Its value is a string that appears in the mode
1385line, or @code{nil} for no version control.
1356@end defvar 1386@end defvar
1357 1387
1388@defvar mode-line-modes
1389This variable displays the buffer's major and minor modes. Here is a
1390simplified version of its default value. The real default value also
1391specifies 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
1401So @code{mode-line-modes} normally also displays the recursive editing
1402level, information on the process status and whether narrowing is in
1403effect.
1404@end defvar
1405
1406 The following three variables are used in @code{mode-line-modes}:
1407
1358@defvar mode-name 1408@defvar mode-name
1359This buffer-local variable holds the ``pretty'' name of the current 1409This buffer-local variable holds the ``pretty'' name of the current
1360buffer's major mode. Each major mode should set this variable so that the 1410buffer's major mode. Each major mode should set this variable so that the
1361mode name will appear in the mode line. 1411mode name will appear in the mode line.
1362@end defvar 1412@end defvar
1363 1413
1414@defvar mode-line-process
1415This buffer-local variable contains the mode-line information on process
1416status in modes used for communicating with subprocesses. It is
1417displayed immediately following the major mode name, with no intervening
1418space. For example, its value in the @samp{*shell*} buffer is
1419@code{(":%s")}, which allows the shell to display its status along
1420with the major mode as: @samp{(Shell:run)}. Normally this variable
1421is @code{nil}.
1422@end defvar
1423
1364@defvar minor-mode-alist 1424@defvar minor-mode-alist
1365This variable holds an association list whose elements specify how the 1425This variable holds an association list whose elements specify how the
1366mode line should indicate that a minor mode is active. Each element of 1426mode line should indicate that a minor mode is active. Each element of
@@ -1370,51 +1430,28 @@ the @code{minor-mode-alist} should be a two-element list:
1370(@var{minor-mode-variable} @var{mode-line-string}) 1430(@var{minor-mode-variable} @var{mode-line-string})
1371@end example 1431@end example
1372 1432
1373More generally, @var{mode-line-string} can be any mode line spec. It 1433More generally, @var{mode-line-string} can be any mode-line spec. It
1374appears in the mode line when the value of @var{minor-mode-variable} is 1434appears in the mode line when the value of @var{minor-mode-variable}
1375non-@code{nil}, and not otherwise. These strings should begin with 1435is non-@code{nil}, and not otherwise. These strings should begin with
1376spaces so that they don't run together. Conventionally, the 1436spaces 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} 1437@var{minor-mode-variable} for a specific mode is set to a
1378value when that minor mode is activated. 1438non-@code{nil} value when that minor mode is activated.
1379
1380The default value of @code{minor-mode-alist} is:
1381
1382@example
1383@group
1384minor-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 1439
1394@code{minor-mode-alist} itself is not buffer-local. Each variable 1440@code{minor-mode-alist} itself is not buffer-local. Each variable
1395mentioned in the alist should be buffer-local if its minor mode can be 1441mentioned in the alist should be buffer-local if its minor mode can be
1396enabled separately in each buffer. 1442enabled separately in each buffer.
1397@end defvar 1443@end defvar
1398 1444
1399@defvar mode-line-process 1445@defvar global-mode-string
1400This buffer-local variable contains the mode line information on process 1446This variable holds a mode-line spec that appears in the mode line by
1401status in modes used for communicating with subprocesses. It is 1447default, just after the buffer name. The command @code{display-time}
1402displayed immediately following the major mode name, with no intervening 1448sets @code{global-mode-string} to refer to the variable
1403space. For example, its value in the @samp{*shell*} buffer is 1449@code{display-time-string}, which holds a string containing the time and
1404@code{(":%s")}, which allows the shell to display its status along 1450load information.
1405with the major mode as: @samp{(Shell:run)}. Normally this variable
1406is @code{nil}.
1407@end defvar
1408
1409 Some variables are used by @code{minor-mode-alist} to display
1410a string for various minor modes when enabled. This is a typical
1411example:
1412 1451
1413@defvar vc-mode 1452The @samp{%M} construct substitutes the value of
1414The variable @code{vc-mode}, buffer-local in each buffer, records 1453@code{global-mode-string}, but that is obsolete, since the variable is
1415whether the buffer's visited file is maintained with version control, 1454included in the mode line from @code{mode-line-format}.
1416and, if so, which kind. Its value is a string that appears in the mode
1417line, or @code{nil} for no version control.
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
@@ -1425,7 +1462,9 @@ This variable holds the default @code{mode-line-format} for buffers
1425that do not override it. This is the same as @code{(default-value 1462that do not override it. This is the same as @code{(default-value
1426'mode-line-format)}. 1463'mode-line-format)}.
1427 1464
1428The default value of @code{default-mode-line-format} is this list: 1465Here is a simplified version of the default value of
1466@code{default-mode-line-format}. The real default value also
1467specifies addition of text properties.
1429 1468
1430@example 1469@example
1431@group 1470@group
@@ -1436,23 +1475,13 @@ The default value of @code{default-mode-line-format} is this list:
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}
1443 ;; @r{that copies the mode name and adds text}
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 1481@group
1482 mode-line-modes
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
@@ -1564,29 +1593,33 @@ The value of @code{global-mode-string}. Currently, only
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
1569mode line. The @code{face} property affects the appearance of text; the 1599mode 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
1574line: 1604line:
1575 1605
1576@enumerate 1606@enumerate
1577@item 1607@item
1578Put a string with the @code{local-map} property directly into the 1608Put a string with a text property directly into the mode-line data
1579mode-line data structure. 1609structure.
1610
1611@item
1612Put a text property on a mode-line %-construct such as @samp{%12b}; then
1613the expansion of the %-construct will have that same text property.
1580 1614
1581@item 1615@item
1582Put a @code{local-map} property on a mode-line %-construct 1616Use a @code{(:propertize @var{elt} @var{props}@dots{})} construct to
1583such as @samp{%12b}; then the expansion of the %-construct 1617give @var{elt} a text property specified by @var{props}.
1584will have that same text property.
1585 1618
1586@item 1619@item
1587Use a list containing @code{:eval @var{form}} in the mode-line data 1620Use a list containing @code{:eval @var{form}} in the mode-line data
1588structure, and make @var{form} evaluate to a string that has a 1621structure, and make @var{form} evaluate to a string that has a text
1589@code{local-map} property. 1622property.
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
@@ -1601,7 +1634,7 @@ keymap can only take real effect for mouse clicks.
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
1603top, just as it can have a mode line at the bottom. The header line 1636top, just as it can have a mode line at the bottom. The header line
1604feature works just like the mode line feature, except that it's 1637feature works just like the mode-line feature, except that it's
1605controlled by different variables. 1638controlled by different variables.
1606 1639
1607@tindex header-line-format 1640@tindex header-line-format
@@ -1621,11 +1654,11 @@ 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
1627the text that would appear in a mode line or header line 1660the text that would appear in a mode line or header line
1628based on certain mode line specification. 1661based 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
1631This function formats a line of text according to @var{format} as if 1664This function formats a line of text according to @var{format} as if
@@ -2214,7 +2247,7 @@ 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
2215acts just like the explicit @code{face} property, but its activation 2248acts just like the explicit @code{face} property, but its activation
2216is toggled when the user calls @kbd{M-x font-lock-mode}. Using 2249is 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
2218which construct their text programmatically, such as 2251which construct their text programmatically, such as
2219@code{list-buffers} and @code{occur}. 2252@code{list-buffers} and @code{occur}.
2220 2253