Function: reftex-what-special-env

reftex-what-special-env is an autoloaded and byte-compiled function defined in reftex-parse.el.gz.

Signature

(reftex-what-special-env WHICH &optional BOUND)

Documentation

Run the special environment parsers and return the matches.

The return value is (e.g.) either ("my-parser-function" . (point)) or a list of them.

If WHICH is nil, immediately return nil. If WHICH is 1, return innermost enclosing environment. If WHICH is t, return list of all environments enclosing point. If WHICH is a list of environments, look only for those environments and
  return the name of the first environment in this list found to enclose
  point.

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/reftex-parse.el.gz
;;;###autoload
(defun reftex-what-special-env (which &optional bound)
  "Run the special environment parsers and return the matches.

The return value is (e.g.) either (\"my-parser-function\" . (point))
or a list of them.

If WHICH is nil, immediately return nil.
If WHICH is 1, return innermost enclosing environment.
If WHICH is t, return list of all environments enclosing point.
If WHICH is a list of environments, look only for those environments and
  return the name of the first environment in this list found to enclose
  point."
  (unless reftex-section-regexp (reftex-compile-variables))
  (catch 'exit
    (save-excursion
      (if (null reftex-special-env-parsers) (throw 'exit nil))
      (if (null which) (throw 'exit nil))
      (let ((bound (or bound (save-excursion (re-search-backward
                                              reftex-section-regexp nil 1)
                                             (point))))
            (fun-list (if (listp which)
                          (mapcar (lambda (x) (if (memq x which) x nil))
                                  reftex-special-env-parsers)
                        reftex-special-env-parsers))
            specials rtn)
        ;; Call all functions
        (setq specials (mapcar
                        (lambda (fun)
                          (save-excursion
                            (setq rtn (and fun (funcall fun bound)))
                            (if rtn (cons (symbol-name fun) rtn) nil)))
                        fun-list))
        ;; Delete the non-matches
        (setq specials (delq nil specials))
        ;; Sort
        (setq specials (sort specials (lambda (a b) (> (cdr a) (cdr b)))))
        (if (eq which t)
            specials
          (car specials))))))