re-search-forward function searches for the end of the
sentence, that is, for the pattern defined by the
regular expression. If the pattern is found--if the end of the sentence is
re-search-forward function does two things:
re-search-forwardfunction carries out a side effect, which is to move point to the end of the occurrence found.
re-search-forwardfunction returns a value of true. This is the value received by the
if, and means that the search was successful.
The side effect, the movement of point, is completed before the
if function is handed the value returned by the successful
conclusion of the search.
if function receives the value of true from a successful
if evaluates the then-part,
which is the expression
(skip-chars-backward " \t\n"). This
expression moves backwards over any blank spaces, tabs or carriage
returns until a printed character is found and then leaves point after
the character. Since point has already been moved to the end of the
pattern that marks the end of the sentence, this action leaves point
right after the closing printed character of the sentence, which is
usually a period.
On the other hand, if the
re-search-forward function fails to
find a pattern marking the end of the sentence, the function returns
false. The false then causes the
if to evaluate its third
argument, which is
(goto-char par-end): it moves point to the
end of the paragraph.
Regular expression searches are exceptionally useful and the pattern
re-search-forward, in which the search is the
test of an
if expression, is handy. You will see or write code
incorporating this pattern often.
Go to the first, previous, next, last section, table of contents.