Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8911967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:04:59+00:00 2026-06-15T04:04:59+00:00

I’m reading An Introduction to Programming in Emacs Lisp by Robert J. Chassell. And

  • 0

I’m reading “An Introduction to Programming in Emacs Lisp” by Robert J. Chassell. 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))))

Thanks for editing and answering. I have another three questions about forward-paragraph:

  1. What is the meaning of (progn (move-to-left-margin) (not (eobp)))? If (not (eobp)) is true, shouldn’t (progn (move-to-left-margin) (not (eobp))) always be true?

  2. About this line:

    ;; ... and one more line.
    (forward-line 1)
    

    Why forwarding one more line?

  3. About this paragraph:

    This while loop has us searching forward for `sp-parstart’, which is
    the combination of possible whitespace with a the local value of the
    start of a paragraph or of a paragraph separator.

    Why does the local value of the start of a paragraph or of a paragraph separator? As far as I’m concerned, the condition of the paragraph separator has already been processed in the first while loop of the while.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T04:05:00+00:00Added an answer on June 15, 2026 at 4:05 am

    It’s not that interesting! If you look at the docstring for forward-paragraph you’ll see that it:

    Returns the count of paragraphs left to move.

    That means that if you are one paragraph from the end of the buffer, and evaluate (forward-paragraph 3), it will return 2, meaning that it stepped forward by one paragraph, but the remaining two steps that you requested could not be taken.

    In order to return the number of steps not taken, forward-paragraph returns (just after the block of code you’ve quoted) the value arg. So arg must only be decremented when forward-paragraph actually steps forward by a paragraph. I’m sure you can figure out the rest.

    (If you’re wondering where the return value is used, it’s in fill-paragraph to avoid filling a non-existent paragraph at the end of the buffer.)

    ETA: I see that you’ve added three new questions. Instead of answering them, I’ll tell you how you might try to answer them for yourself by using the Emacs Lisp debugger to step through the code for forward-paragraph and see what it is actually doing.

    1. Find the source code for forward-paragraph by typing C-h C-f forward-paragraph RET and then clicking on the link in the *Help* buffer.

    2. Recompile forward-paragraph for debugging by running the command eval-defun, for example by typing C-M-x.

    3. Turn on debugging for forward-paragraph by typing M-x debug-on-entry RET forward-paragraph RET.

    4. Go to a suitable buffer and run forward-paragraph, for example by typing M-}.

    5. Now you’re in the debugger, which shows you the call stack and the current form being evaluated. You can type d to step into that form and see the evaluation of its subforms, or c to completely evaluate the form and see its result, and q to exit the debugger. (See the documentation for more debugger commands.)

    6. Step through the execution of forward-paragraph until you understand what it is doing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
This could be a duplicate question, but I have no idea what search terms
I don't have much knowledge about the IPv6 protocol, so sorry if the question
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I am reading a book about Javascript and jQuery and using one of the
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
I have a small JavaScript validation script that validates inputs based on Regex. I
I have this code to decode numeric html entities to the UTF8 equivalent character.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.