[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: about "forward-paragraph" in Intro to emacs lisp.
From: |
Barry Margolin |
Subject: |
Re: about "forward-paragraph" in Intro to emacs lisp. |
Date: |
Mon, 27 Jul 2009 09:01:19 -0400 |
User-agent: |
MT-NewsWatcher/3.5.3b3 (Intel Mac OS X) |
In article <mailman.3183.1248634897.2239.help-gnu-emacs@gnu.org>,
waterloo <waterloo2005@gmail.com> wrote:
> I can not understand code of forward-paragraph in Intro to emacs lisp.
>
> On " The forward motion `while' loop " of 12.4 in Intro to emacs lisp.
> -------------------------------
> ;; going forwards and not at the end of the buffer
> (while (and (> arg 0) (not (eobp)))
>
> ;; between paragraphs
> ;; Move forward over separator lines...
> (while (and (not (eobp))
> (progn (move-to-left-margin) (not (eobp)))
> (looking-at parsep))
> (forward-line 1))
> ;; This decrements the loop
> (unless (eobp) (setq arg (1- arg)))
> ;; ... and one more line.
> (forward-line 1)
> -----------------------------------------------------
>
> Why need "(progn (move-to-left-margin) (not (eobp))) " ?
You only want 'and' to check the value of (not (eobp)), you don't want
it looking at the value of (move-to-left-margin). So you combine them
with 'progn', which just returns the value of its last expression.
(move-to-left-margin) is needed because the parsep regexp is expected to
be found at the beginning of line.
> Why need the last line " (forward-line 1) " ?
Not sure about that one. I guess it wants to move to the beginning of
the next paragraph, rather than the end of the current one.
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***