Function: LaTeX-backward-paragraph

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

Signature

(LaTeX-backward-paragraph &optional COUNT)

Documentation

Move backward to beginning 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-backward-paragraph (&optional count)
  "Move backward to beginning 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)))
      (if (and macro-start
               ;; Point really has to be inside of the macro, not before it.
               (not (= macro-start (point)))
               (save-excursion
                 (goto-char macro-start)
                 (looking-at LaTeX-paragraph-commands-regexp)))
          ;; Point is inside of a paragraph command.
          (progn
            (goto-char macro-start)
            (beginning-of-line))
        (let (limit
              (start (line-beginning-position)))
          (goto-char
           (max (save-excursion
                  (backward-paragraph)
                  (setq limit (point)))
                ;; Search for possible transitions from commented to
                ;; uncommented regions and vice versa.
                (save-excursion
                  (TeX-backward-comment-skip 1 limit)
                  (point))
                ;; Search for paragraph commands.
                (save-excursion
                  (let ((end-point 0) macro-bol)
                    (when (setq macro-bol
                                (re-search-backward
                                 (format "^[ \t]*%s*[ \t]*\\(%s\\)"
                                         TeX-comment-start-regexp
                                         LaTeX-paragraph-commands-regexp)
                                 limit t))
                      (if (and (string= (match-string 1) "\\begin")
                               (progn
                                 (goto-char (match-end 1))
                                 (skip-chars-forward "{ \t")
                                 (member (buffer-substring-no-properties
                                          (point) (progn (skip-chars-forward
                                                          "A-Za-z*") (point)))
                                         LaTeX-verbatim-environments)))
                          ;; If inside a verbatim environment, just
                          ;; use the next line.  In such environments
                          ;; `TeX-find-macro-end' could otherwise
                          ;; think brackets or braces belong to the
                          ;; \begin macro.
                          (setq end-point (line-beginning-position 2))
                        ;; Jump to the macro end otherwise.
                        (goto-char (match-beginning 1))
                        (goto-char (TeX-find-macro-end))
                        ;; For an explanation of this distinction see
                        ;; `LaTeX-forward-paragraph'.
                        (if (looking-at (concat (regexp-quote TeX-esc)
                                                "[@A-Za-z]+\\|[ \t]*\\($\\|"
                                                TeX-comment-start-regexp "\\)"))
                            (progn
                              (when (looking-at (regexp-quote TeX-esc))
                                (goto-char (TeX-find-macro-end)))
                              (forward-line 1)
                              (when (< (point) start)
                                (setq end-point (point))))
                          (setq end-point macro-bol))))
                    end-point)))))))))