Improve filling-related documentation

* doc/emacs/text.texi (Auto Fill, Fill Commands): Mention special
line-breaking rules for CJK characters and the kinsoku rules.
(Bug#47856)

* lisp/textmodes/fill.el
(fill-separate-heterogeneous-words-with-space): Doc fix.
This commit is contained in:
Eli Zaretskii 2021-04-20 15:12:10 +03:00
parent 2b7eed23eb
commit cad8913c89
2 changed files with 33 additions and 15 deletions

View file

@ -502,8 +502,8 @@ text.
@cindex mode, Auto Fill @cindex mode, Auto Fill
@dfn{Auto Fill} mode is a buffer-local minor mode (@pxref{Minor @dfn{Auto Fill} mode is a buffer-local minor mode (@pxref{Minor
Modes}) in which lines are broken automatically at spaces when the Modes}) in which lines are broken automatically when the line becomes
line becomes too wide. too wide and you type @kbd{@key{SPC}} or @kbd{@key{RET}}.
@table @kbd @table @kbd
@item M-x auto-fill-mode @item M-x auto-fill-mode
@ -522,12 +522,21 @@ certain major modes, add @code{auto-fill-mode} to the mode hooks
(@pxref{Major Modes}). When Auto Fill mode is enabled, the mode (@pxref{Major Modes}). When Auto Fill mode is enabled, the mode
indicator @samp{Fill} appears in the mode line (@pxref{Mode Line}). indicator @samp{Fill} appears in the mode line (@pxref{Mode Line}).
Auto Fill mode breaks lines automatically at spaces whenever they Auto Fill mode breaks lines automatically at the appropriate places
get longer than the desired width. This line breaking occurs only whenever lines get longer than the desired width. This line breaking
when you type @key{SPC} or @key{RET}. If you wish to insert a space occurs only when you type @kbd{@key{SPC}} or @kbd{@key{RET}}. If you
or newline without permitting line-breaking, type @kbd{C-q @key{SPC}} wish to insert a space or newline without permitting line-breaking,
or @kbd{C-q C-j} respectively. Also, @kbd{C-o} inserts a newline type @kbd{C-q @key{SPC}} or @kbd{C-q C-j} respectively. Also,
without line breaking. @kbd{C-o} inserts a newline without line breaking.
@cindex kinsoku line-breaking rules
The place where Auto Fill breaks a line depends on the line's
characters. For characters from @acronym{ASCII}, Latin, and most
other scripts Emacs breaks a line on space characters, to keep the
words intact. But for CJK scripts, a line can be broken between any
two characters. (If you load the @file{kinsoku} library, Emacs will
avoid breaking a line between certain pairs of CJK characters, where
special rules prohibit that.)
When Auto Fill mode breaks a line, it tries to obey the When Auto Fill mode breaks a line, it tries to obey the
@dfn{adaptive fill prefix}: if a fill prefix can be deduced from the @dfn{adaptive fill prefix}: if a fill prefix can be deduced from the
@ -549,6 +558,9 @@ described in the next section.
(@pxref{Fill Commands}). (@pxref{Fill Commands}).
@end ifnottex @end ifnottex
A similar feature that wraps long lines automatically at display
time is Visual Line Mode (@pxref{Visual Line Mode}).
@node Fill Commands @node Fill Commands
@subsection Explicit Fill Commands @subsection Explicit Fill Commands
@ -571,7 +583,11 @@ Center a line.
current paragraph. It redistributes the line breaks within the current paragraph. It redistributes the line breaks within the
paragraph, and deletes any excess space and tab characters occurring paragraph, and deletes any excess space and tab characters occurring
within the paragraph, in such a way that the lines end up fitting within the paragraph, in such a way that the lines end up fitting
within a certain maximum width. within a certain maximum width. Like Auto Fill mode, this and other
filling commands usually break lines at space characters, but for CJK
characters these commands can break a line between almost any two
characters, and they can also obey the kinsoku rules. @xref{Auto
Fill}.
@findex fill-region @findex fill-region
Normally, @kbd{M-q} acts on the paragraph where point is, but if Normally, @kbd{M-q} acts on the paragraph where point is, but if
@ -645,8 +661,8 @@ or before @samp{)}, @samp{:} or @samp{?}); and
even if preceded by a non-whitespace character). even if preceded by a non-whitespace character).
Emacs can display an indicator in the @code{fill-column} position Emacs can display an indicator in the @code{fill-column} position
using the Display fill column indicator mode using the Display fill column indicator mode (@pxref{Displaying
(@pxref{Displaying Boundaries, display-fill-column-indicator}). Boundaries, display-fill-column-indicator}).
@node Fill Prefix @node Fill Prefix
@subsection The Fill Prefix @subsection The Fill Prefix

View file

@ -51,10 +51,12 @@ A value of nil means that any change in indentation starts a new paragraph."
(defcustom fill-separate-heterogeneous-words-with-space nil (defcustom fill-separate-heterogeneous-words-with-space nil
"Non-nil means to use a space to separate words of a different kind. "Non-nil means to use a space to separate words of a different kind.
This will be done with a word in the end of a line and a word in For example, when an English word at the end of a line and a CJK word
the beginning of the next line when concatenating them for at the beginning of the next line are joined into a single line, they
filling those lines. Whether to use a space depends on how the will be separated by a space if this variable is non-nil.
words are categorized." Whether to use a space to separate such words also depends on the entry
in `fill-nospace-between-words-table' for the characters before and
after the newline."
:type 'boolean :type 'boolean
:group 'fill :group 'fill
:version "26.1") :version "26.1")