Function: reftex-nth-arg

reftex-nth-arg is an autoloaded and byte-compiled function defined in reftex-parse.el.gz.

Signature

(reftex-nth-arg N &optional OPT-ARGS)

Documentation

Return the Nth following {} or [] parentheses content.

OPT-ARGS is a list of argument numbers which are optional.

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/reftex-parse.el.gz
;;;###autoload
(defun reftex-nth-arg (n &optional opt-args)
  "Return the Nth following {} or [] parentheses content.
OPT-ARGS is a list of argument numbers which are optional."

  ;; If we are sitting at a macro start, skip to end of macro name.
  (and (eq (following-char) ?\\) (skip-chars-forward "a-zA-Z*\\\\"))

  (if (= n 1000)
      ;; Special case:  Skip all touching arguments
      (progn
        (reftex-move-over-touching-args)
        (reftex-context-substring))

    ;; Do the real thing.
    (let ((cnt 1))

      (when (reftex-move-to-next-arg)

        (while (< cnt n)
          (while (and (member cnt opt-args)
                      (eq (following-char) ?\{))
            (cl-incf cnt))
          (when (< cnt n)
            (unless (and (condition-case nil
                             (or (forward-list 1) t)
                           (error nil))
                         (reftex-move-to-next-arg)
                         (cl-incf cnt))
              (setq cnt 1000))))

        (while (and (memq cnt opt-args)
                    (eq (following-char) ?\{))
          (cl-incf cnt)))
      (if (and (= n cnt)
               (> (skip-chars-forward "{[") 0))
          (reftex-context-substring)
        nil))))