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