Next: Outlining, Previous: Inserting end-tags, Up: Top [Contents]

## 4 Paragraphs

Emacs has several commands that operate on paragraphs, most notably `M-q`. nXML mode redefines these to work in a way that is useful for XML. The exact rules that are used to find the beginning and end of a paragraph are complicated; they are designed mainly to ensure that `M-q` does the right thing.

A paragraph consists of one or more complete, consecutive lines. A group of lines is not considered a paragraph unless it contains some non-whitespace characters between tags or inside comments. A blank line separates paragraphs. A single tag on a line by itself also separates paragraphs. More precisely, if one tag together with any leading and trailing whitespace completely occupy one or more lines, then those lines will not be included in any paragraph.

A start-tag at the beginning of the line (possibly indented) may be treated as starting a paragraph. Similarly, an end-tag at the end of the line may be treated as ending a paragraph. The following rules are used to determine whether such a tag is in fact treated as a paragraph boundary:

- If the schema does not allow text at that point, then it is a paragraph boundary.
- If the end-tag corresponding to the start-tag is not at the end of its line, or the start-tag corresponding to the end-tag is not at the beginning of its line, then it is not a paragraph boundary. For example, in

      <p>This is a paragraph with an
      <emph>emphasized</emph> phrase.

  the ‘`<emph>`’ start-tag would not be considered as starting a paragraph, because its corresponding end-tag is not at the end of the line.

- If there is text that is a sibling in element tree, then it is not a paragraph boundary. For example, in

      <p>This is a paragraph with an
      <emph>emphasized phrase that takes one source line</emph>

  the ‘`<emph>`’ start-tag would not be considered as starting a paragraph, even though its end-tag is at the end of its line, because there the text ‘`This is a paragraph with an`’ is a sibling of the ‘`emph`’ element.

- Otherwise, it is a paragraph boundary.

Next: Outlining, Previous: Inserting end-tags, Up: Top [Contents]