aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2005-06-11 13:53:34 +0000
committerEli Zaretskii2005-06-11 13:53:34 +0000
commit0c2cfb962aa5fc48e1a5c2fd4e0d2b44ca747c6a (patch)
treed7650755eeaa713de66a424b6a1f16087b62c480
parentb48e52066f205b23ada938d9e8d83e0e9cebfdce (diff)
downloademacs-0c2cfb962aa5fc48e1a5c2fd4e0d2b44ca747c6a.tar.gz
emacs-0c2cfb962aa5fc48e1a5c2fd4e0d2b44ca747c6a.zip
(Adaptive Fill): Amplify the description of fill-context-prefix.
-rw-r--r--lispref/text.texi80
1 files changed, 63 insertions, 17 deletions
diff --git a/lispref/text.texi b/lispref/text.texi
index 1d4dc0fce8a..1c0fd09322b 100644
--- a/lispref/text.texi
+++ b/lispref/text.texi
@@ -1667,8 +1667,12 @@ line won't be broken there.
1667@section Adaptive Fill Mode 1667@section Adaptive Fill Mode
1668@cindex Adaptive Fill mode 1668@cindex Adaptive Fill mode
1669 1669
1670 Adaptive Fill mode chooses a fill prefix automatically from the text 1670 When @dfn{Adaptive Fill Mode} is enabled, Emacs determines the fill
1671in each paragraph being filled. 1671prefix automatically from the text in each paragraph being filled
1672rather than using a predetermined value. During filling, this fill
1673prefix gets inserted at the start of the second and subsequent lines
1674of the paragraph as described in @ref{Filling}, and in @ref{Auto
1675Filling}.
1672 1676
1673@defopt adaptive-fill-mode 1677@defopt adaptive-fill-mode
1674Adaptive Fill mode is enabled when this variable is non-@code{nil}. 1678Adaptive Fill mode is enabled when this variable is non-@code{nil}.
@@ -1677,38 +1681,80 @@ It is @code{t} by default.
1677 1681
1678@defun fill-context-prefix from to 1682@defun fill-context-prefix from to
1679This function implements the heart of Adaptive Fill mode; it chooses a 1683This function implements the heart of Adaptive Fill mode; it chooses a
1680fill prefix based on the text between @var{from} and @var{to}. It does 1684fill prefix based on the text between @var{from} and @var{to},
1681this by looking at the first two lines of the paragraph, based on the 1685typically the start and end of a paragraph. It does this by looking
1682variables described below. 1686at the first two lines of the paragraph, based on the variables
1687described below.
1683@c The optional argument first-line-regexp is not documented 1688@c The optional argument first-line-regexp is not documented
1684@c because it exists for internal purposes and might be eliminated 1689@c because it exists for internal purposes and might be eliminated
1685@c in the future. 1690@c in the future.
1691
1692Usually, this function returns the fill prefix, a string. However,
1693before doing this, the function makes a final check (not specially
1694mentioned in the following) that a line starting with this prefix
1695wouldn't look like the start of a paragraph. Should this happen, the
1696function signals the anomaly by returning @code{nil} instead.
1697
1698In detail, @code{fill-context-prefix} does this:
1699
1700@enumerate
1701@item
1702It takes a candidate for the fill prefix from the first line---it
1703tries first the function in @code{adaptive-fill-function} (if any),
1704then the regular expression @code{adaptive-fill-regexp} (see below).
1705The first non-@code{nil} result of these, or the empty string if
1706they're both @code{nil}, becomes the first line's candidate.
1707@item
1708If the paragraph has as yet only one line, the function tests the
1709validity of the prefix candidate just found. The function then
1710returns the candidate if it's valid, or a string of spaces otherwise.
1711(see the description of @code{adaptive-fill-first-line-regexp} below).
1712@item
1713When the paragraph already has two lines, the function next looks for
1714a prefix candidate on the second line, in just the same way it did for
1715the first line. If it doesn't find one, it returns @code{nil}.
1716@item
1717The function now compares the two candidate prefixes heuristically: if
1718the non-whitespace characters in the line 2 candidate occur in the
1719same order in the line 1 candidate, the function returns the line 2
1720candidate. Otherwise, it returns the largest initial substring which
1721is common to both candidates (which might be the empty string).
1722@end enumerate
1686@end defun 1723@end defun
1687 1724
1688@defopt adaptive-fill-regexp 1725@defopt adaptive-fill-regexp
1689This variable holds a regular expression to control Adaptive Fill mode.
1690Adaptive Fill mode matches this regular expression against the text 1726Adaptive Fill mode matches this regular expression against the text
1691starting after the left margin whitespace (if any) on a line; the 1727starting after the left margin whitespace (if any) on a line; the
1692characters it matches are that line's candidate for the fill prefix. 1728characters it matches are that line's candidate for the fill prefix.
1729
1730The default value of this variable is
1731@w{@samp{"[ \t]*\\([-|#;>*]+[ \t]*\\|(?[0-9]+[.)][ \t]*\\)*"}}. This
1732matches a number enclosed in parentheses or followed by a period,
1733or certain punctuation characters, or any sequence of these
1734intermingled with whitespace. In particular, it matches a sequence of
1735whitespace, possibly empty.
1693@end defopt 1736@end defopt
1694 1737
1695@defopt adaptive-fill-first-line-regexp 1738@defopt adaptive-fill-first-line-regexp
1696In a one-line paragraph, if the candidate fill prefix matches this 1739Used only in one-line paragraphs, this regular expression acts as an
1697regular expression, or if it matches @code{comment-start-skip}, then it 1740additional check of the validity of the one available candidate fill
1698is used---otherwise, spaces amounting to the same width are used 1741prefix: the candidate must match this regular expression, or match
1699instead. 1742@code{comment-start-skip}. If it doesn't, @code{fill-context-prefix}
1700 1743replaces the candidate with a string of spaces ``of the same width''
1701However, the fill prefix is never taken from a one-line paragraph 1744as it.
1702if it would act as a paragraph starter on subsequent lines. 1745
1746The default value of this variable is @w{@samp{"\\`[ \t]*\\'"}}, which
1747matches only a string of whitespace. The effect of this default is to
1748force the fill prefixes found in one-line paragraphs always to be pure
1749whitespace.
1703@end defopt 1750@end defopt
1704 1751
1705@defopt adaptive-fill-function 1752@defopt adaptive-fill-function
1706You can specify more complex ways of choosing a fill prefix 1753You can specify more complex ways of choosing a fill prefix
1707automatically by setting this variable to a function. The function is 1754automatically by setting this variable to a function. The function is
1708called when @code{adaptive-fill-regexp} does not match, with point after 1755called with point after the left margin (if any) of a line, and it
1709the left margin of a line, and it should return the appropriate fill 1756must preserve point. It should return either ``that line's'' fill
1710prefix based on that line. If it returns @code{nil}, that means it sees 1757prefix or @code{nil}, meaning it has failed to determine a prefix.
1711no fill prefix in that line.
1712@end defopt 1758@end defopt
1713 1759
1714@node Auto Filling 1760@node Auto Filling