Function: ConTeXt-environment-menu

ConTeXt-environment-menu is a byte-compiled function defined in context.el.

Signature

(ConTeXt-environment-menu ENVIRONMENT)

Documentation

Insert ENVIRONMENT around point or region.

Source Code

;; Defined in ~/.emacs.d/elpa/auctex-14.1.2/context.el
(defun ConTeXt-environment-menu (environment)
  "Insert ENVIRONMENT around point or region."
  (let ((entry (assoc environment (ConTeXt-environment-list))))
    (cond ((not (and entry (nth 1 entry)))
           (ConTeXt-insert-environment environment))
          ((numberp (nth 1 entry))
           (let ((count (nth 1 entry))
                 (args ""))
             (while (> count 0)
               (setq args (concat args TeX-grop TeX-grcl))
               (setq count (- count 1)))
             (ConTeXt-insert-environment environment args)))
          ((or (stringp (nth 1 entry)) (vectorp (nth 1 entry)))
           (let ((prompts (cdr entry))
                 (args ""))
             (dolist (elt prompts)
               (let* ((optional (vectorp elt))
                      (elt (if optional (elt elt 0) elt))
                      (arg (TeX-read-string
                            (TeX-argument-prompt optional elt nil))))
                 (setq args (concat args
                                    (cond ((and optional (> (length arg) 0))
                                           (concat ConTeXt-optop arg ConTeXt-optcl))
                                          ((not optional)
                                           (concat TeX-grop arg TeX-grcl)))))))
             (ConTeXt-insert-environment environment args)))
          (t
           (apply (nth 1 entry) environment (nthcdr 2 entry))))))