Node:fwd-para summary, Previous:fwd-para with fill prefix, Up:forward-paragraph



Summary

In summary, when moving forward, the forward-paragraph function does the following:

For review, here is the code we have just been discussing, formatted for clarity:

(interactive "p")
(or arg (setq arg 1))
(let* (
       (fill-prefix-regexp
        (and fill-prefix (not (equal fill-prefix ""))
             (not paragraph-ignore-fill-prefix)
             (regexp-quote fill-prefix)))

       (paragraph-separate
        (if fill-prefix-regexp
            (concat paragraph-separate
                    "\\|^"
                    fill-prefix-regexp
                    "[ \t]*$")
          paragraph-separate)))

  omitted-backward-moving-code ...

  (while (> arg 0)                ; forward-moving-code
    (beginning-of-line)

    (while (prog1 (and (not (eobp))
                       (looking-at paragraph-separate))
             (forward-line 1)))

    (if fill-prefix-regexp
        (while (and (not (eobp))  ; then-part
                    (not (looking-at paragraph-separate))
                    (looking-at fill-prefix-regexp))
          (forward-line 1))
                                  ; else-part: the inner-if
      (if (re-search-forward paragraph-start nil t)
          (goto-char (match-beginning 0))
        (goto-char (point-max))))

    (setq arg (1- arg)))))        ; decrementer

The full definition for the forward-paragraph function not only includes this code for going forwards, but also code for going backwards.

If you are reading this inside of GNU Emacs and you want to see the whole function, you can type C-h f (describe-function) and the name of the function. This gives you the function documentation and the name of the library containing the function's source. Place point over the name of the library and press the RET key; you will be taken directly to the source. (Be sure to install your sources! Without them, you are like a person who tries to drive a car with his eyes shut!)

Or - a good habit to get into - you can type M-. (find-tag) and the name of the function when prompted for it. This will take you directly to the source. If the find-tag function first asks you for the name of a TAGS table, give it the name of the TAGS file such as /usr/local/share/emacs/21.0.100/lisp/TAGS. (The exact path to your TAGS file depends on how your copy of Emacs was installed.)

You can also create your own TAGS file for directories that lack one. See Create Your Own TAGS File.