Next: Summing up zap-to-char, Previous: search-forward, Up: zap-to-char [Contents][Index]
progn
Special Formprogn
is a special form that causes each of its arguments to be
evaluated in sequence and then returns the value of the last one. The
preceding expressions are evaluated only for the side effects they perform.
The values produced by them are discarded.
The template for a progn
expression is very simple:
(progn body…)
In zap-to-char
, the progn
expression has to do two things: put
point in exactly the right position; and return the location of point so
that kill-region
will know how far to kill to.
The first argument to the progn
is search-forward
. When
search-forward
finds the string, the function leaves point
immediately after the last character in the target string. (In this case
the target string is just one character long.) If the search is backwards,
search-forward
leaves point just before the first character in the
target. The movement of point is a side effect.
The second and last argument to progn
is the expression
(point)
. This expression returns the value of point, which in this
case will be the location to which it has been moved by
search-forward
. (In the source, a line that tells the function to go
to the previous character, if it is going forward, was commented out in
1999; I don’t remember whether that feature or mis-feature was ever a part
of the distributed source.) The value of point
is returned by the
progn
expression and is passed to kill-region
as
kill-region
’s second argument.