Function: LaTeX-forward-paragraph

LaTeX-forward-paragraph is a byte-compiled function defined in latex.el.

Signature

(LaTeX-forward-paragraph &optional COUNT)

Documentation

Move forward to end of paragraph.

If COUNT is non-nil, do it COUNT times.

Source Code

;; Defined in ~/.emacs.d/elpa/auctex-14.1.2/latex.el
(defun LaTeX-forward-paragraph (&optional count)
  "Move forward to end of paragraph.
If COUNT is non-nil, do it COUNT times."
  (or count (setq count 1))
  (dotimes (_ count)
    (let* ((macro-start (TeX-find-macro-start))
           (paragraph-command-start
            (cond
             ;; Point is inside of a paragraph command.
             ((and macro-start
                   (save-excursion
                     (goto-char macro-start)
                     (looking-at LaTeX-paragraph-commands-regexp)))
              (match-beginning 0))
             ;; Point is before a paragraph command in the same line.
             ((looking-at
               (concat "[ \t]*\\(?:" TeX-comment-start-regexp
                       "\\(?:" TeX-comment-start-regexp "\\|[ \t]\\)*\\)?"
                       "\\(" LaTeX-paragraph-commands-regexp "\\)"))
              (match-beginning 1))))
           macro-end)
      ;; If a paragraph command is encountered there are two cases to be
      ;; distinguished:
      ;; 1) If the end of the paragraph command coincides (apart from
      ;;    potential whitespace) with the end of the line, is only
      ;;    followed by a comment or is directly followed by a macro,
      ;;    it is assumed that it should be handled separately.
      ;; 2) If the end of the paragraph command is followed by other
      ;;    code, it is assumed that it should be included with the rest
      ;;    of the paragraph.
      (if (and paragraph-command-start
               (save-excursion
                 (goto-char paragraph-command-start)
                 (setq macro-end (goto-char (TeX-find-macro-end)))
                 (looking-at (concat (regexp-quote TeX-esc) "[@A-Za-z]+\\|"
                                     "[ \t]*\\($\\|"
                                     TeX-comment-start-regexp "\\)"))))
          (progn
            (goto-char macro-end)
            ;; If the paragraph command is followed directly by
            ;; another macro, regard the latter as part of the
            ;; paragraph command's paragraph.
            (when (looking-at (concat (regexp-quote TeX-esc) "[@A-Za-z]+"))
              (goto-char (TeX-find-macro-end)))
            (forward-line))
        (let (limit)
          (goto-char (min (save-excursion
                            (forward-paragraph)
                            (setq limit (point)))
                          (save-excursion
                            (TeX-forward-comment-skip 1 limit)
                            (point)))))))))