www.delorie.com/gnu/docs/emacs-lisp-intro/emacs-lisp-intro_192.html   search  
Buy the book!

Programming in Emacs Lisp

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

12.4 forward-paragraph: a Goldmine of Functions

The forward-paragraph function moves point forward to the end of the paragraph. It is usually bound to M-} and makes use of a number of functions that are important in themselves, including let*, match-beginning, and looking-at.

The function definition for forward-paragraph is considerably longer than the function definition for forward-sentence because it works with a paragraph, each line of which may begin with a fill prefix.

A fill prefix consists of a string of characters that are repeated at the beginning of each line. For example, in Lisp code, it is a convention to start each line of a paragraph-long comment with `;;; '. In Text mode, four blank spaces make up another common fill prefix, creating an indented paragraph. (See section `Fill Prefix' in The GNU Emacs Manual, for more information about fill prefixes.)

The existence of a fill prefix means that in addition to being able to find the end of a paragraph whose lines begin on the left-most column, the forward-paragraph function must be able to find the end of a paragraph when all or many of the lines in the buffer begin with the fill prefix.

Moreover, it is sometimes practical to ignore a fill prefix that exists, especially when blank lines separate paragraphs. This is an added complication.

Shortened forward-paragraph function definition  Key parts of the function definition.
The let* expression  
The forward motion while loop  
Between paragraphs  Movement between paragraphs.
Within paragraphs  Movement within paragraphs.
No fill prefix  When there is no fill prefix.
With a fill prefix  When there is a fill prefix.
Summary  Summary of forward-paragraph code.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003