Function: Texinfo-mark-environment

Texinfo-mark-environment is an interactive and byte-compiled function defined in tex-info.el.

Signature

(Texinfo-mark-environment &optional COUNT)

Documentation

Set mark to end of current environment and point to the matching begin.

If prefix argument COUNT is given, mark the respective number of enclosing environments. The command will not work properly if there are unbalanced begin-end pairs in comments and verbatim environments.

Key Bindings

Source Code

;; Defined in ~/.emacs.d/elpa/auctex-14.1.2/tex-info.el
(defun Texinfo-mark-environment (&optional count)
  "Set mark to end of current environment and point to the matching begin.
If prefix argument COUNT is given, mark the respective number of
enclosing environments.  The command will not work properly if
there are unbalanced begin-end pairs in comments and verbatim
environments."
  ;; TODO:
  ;; This is identical to the LaTeX counterpart but for the find begin/end
  ;; functions.  So some day the implemenation should be factorized.
  (interactive "p")
  (setq count (if count (abs count) 1))
  (let ((cur (point)) beg end)
    ;; Only change point and mark after beginning and end were found.
    ;; Point should not end up in the middle of nowhere if the search fails.
    (save-excursion
      (dotimes (_ count)
        (Texinfo-find-env-end))
      (setq end (line-beginning-position 2))
      (goto-char cur)
      (dotimes (c count)
        (Texinfo-find-env-start)
        (unless (= (1+ c) count)
          (beginning-of-line 0)))
      (setq beg (point)))
    (push-mark end)
    (goto-char beg)
    (TeX-activate-region)))