[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

About forward-paragraph

From: xfq
Subject: About forward-paragraph
Date: Tue, 27 Nov 2012 22:13:10 +0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0

I'm reading `An Introduction to Programming in Emacs Lisp' by Bob. And I have a question. In the node `fwd-para while'(explanation of the `while' loop of forward-paragraph), it says:
   "Interestingly, the loop count is not decremented until we leave the
space between paragraphs, unless we come to the end of buffer or stop
seeing the local value of the paragraph separator."
I can't understand it, can somebody explain it for me?  Thanks.

   The `while' loop looks like this:

     ;; 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)

       (if fill-prefix-regexp
           ;; There is a fill prefix; it overrides parstart;
           ;; we go forward line by line
           (while (and (not (eobp))
                       (progn (move-to-left-margin) (not (eobp)))
                       (not (looking-at parsep))
                       (looking-at fill-prefix-regexp))
             (forward-line 1))

         ;; There is no fill prefix;
         ;; we go forward character by character
         (while (and (re-search-forward sp-parstart nil 1)
                     (progn (setq start (match-beginning 0))
                            (goto-char start)
                            (not (eobp)))
                     (progn (move-to-left-margin)
                            (not (looking-at parsep)))
                     (or (not (looking-at parstart))
                         (and use-hard-newlines
                              (not (get-text-property (1- start) 'hard)))))
           (forward-char 1))

         ;; and if there is no fill prefix and if we are not at the end,
         ;;     go to whatever was found in the regular expression search
         ;;     for sp-parstart
         (if (< (point) (point-max))
             (goto-char start))))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]