1

Problem

When i evaluate the paragraph-start variable in the major mode lisp-mode, it has the following value

"^L\\|[    ]*$"

In emacs the ^L is displayed in red color so I'm not sure if there is some character in between that I could not be displayed properly.

According to the elisp manual paragraph-start is a buffer local variable and is set "to specify that only blank lines separate paragrap" in Lisp mode. However, I don't see how the regex above matches blank line. I would parse the regex above in the following way:

  1. ^L\\: This matches lines that begin with L\, since the anchor ^ indicates start of string or line and \\ indicates an escaped \.
  2. | indicates an or joining the regex before (1) and after (3).
  3. [ ]*$: The first part [ ] is a character class containing just the space character (why are there multiple space characters in it?). The quantifier * indicates that the preceding character class, which is only space, shall be matched zero or more times at the End which is indicated by the anchor $.

Furthermore, the emacs (25.2.1) documentation C-hv paragraph-start states that:

This regexp should match lines that separate paragraphs and should also match lines that start a paragraph

Question

The regular expression (3) should either match the end of a any line, if no white spaces were found, or a string of spaces at the end of each line.

  1. Does (3) match "lines that separate paragraphs"? If yes, why? If not, what does it mean?

Regular expression (1) should only match a line beginning with L\ as far as I can see.

  1. Does (1) match "lines that start a paragraph" If yes, why? If not, what does it mean?

I probably messed up somewhere by misunderstanding either the documentation or the regex. However, a small explanation where I went wrong would be greatly appreciated.

As a reference for the regex matching i used the online emacs documentation.

1 Answer 1

1

Your main confusion lies in that ^L isn't a two-characters regexp, it's an ASCII control character (page-break/ FORM FEED), that's why it appears in red in your system.

on #3, if you iterate over the blanks and using M-x describe-char you'll notice that it should match either space or tab. Reasons are described in the documentation string:

Regexp for beginning of a line that starts OR separates paragraphs. This regexp should match lines that separate paragraphs and should also match lines that start a paragraph (and are part of that paragraph).

This is matched against the text at the left margin, which is not necessarily the beginning of the line, so it should never use "^" as an anchor. This ensures that the paragraph functions will work equally well within a region of text indented by a margin setting.

6
  • Note also that you can type a form feed character with C-q C-l
    – phils
    Oct 2, 2019 at 11:19
  • If you set print-escape-control-characters then ^L will be represented as \14 instead.
    – npostavs
    Oct 2, 2019 at 12:44
  • Thanks for clarifying that ^L is the form feed character. I also found out that you need to escape ` in elisp strings hence \\|` becomes \| which is or in emacs regex. Hence the first regex should just match form feed. Why does a line containing form feed separate paragraphs?
    – Max1
    Oct 2, 2019 at 13:12
  • Definition of paragraph varies depending on mode, you should read the manual :<gnu.org/software/emacs/manual/html_node/emacs/Paragraphs.html> where this question and the uses of paragrapah-start and paragraph-separate are discussed.
    – Muihlinn
    Oct 2, 2019 at 14:11
  • Forgot to mention that ^L is also used to separate sections or jump to another page, both uses match the definition given in the manual. Remember that those variables are customizable.
    – Muihlinn
    Oct 2, 2019 at 14:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.