all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* about "forward-paragraph" in Intro to emacs lisp.
@ 2009-07-26 19:01 waterloo
  0 siblings, 0 replies; 3+ messages in thread
From: waterloo @ 2009-07-26 19:01 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 812 bytes --]

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))) " ?
Why need the last line " (forward-line 1) " ?

Thanks

[-- Attachment #2: Type: text/html, Size: 932 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: about "forward-paragraph" in Intro to emacs lisp.
       [not found] <mailman.3183.1248634897.2239.help-gnu-emacs@gnu.org>
@ 2009-07-27 13:01 ` Barry Margolin
  0 siblings, 0 replies; 3+ messages in thread
From: Barry Margolin @ 2009-07-27 13:01 UTC (permalink / raw)
  To: help-gnu-emacs

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 ***


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: about "forward-paragraph" in Intro to emacs lisp.
@ 2009-07-28  4:22 waterloo
  0 siblings, 0 replies; 3+ messages in thread
From: waterloo @ 2009-07-28  4:22 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 38 bytes --]

Barry Margolin: Thanks for your help.

[-- Attachment #2: Type: text/html, Size: 42 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-07-28  4:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-28  4:22 about "forward-paragraph" in Intro to emacs lisp waterloo
     [not found] <mailman.3183.1248634897.2239.help-gnu-emacs@gnu.org>
2009-07-27 13:01 ` Barry Margolin
  -- strict thread matches above, loose matches on Subject: below --
2009-07-26 19:01 waterloo

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.