Function: TeX-fold-macro-nth-arg

TeX-fold-macro-nth-arg is a byte-compiled function defined in tex-fold.el.

Signature

(TeX-fold-macro-nth-arg N MACRO-START &optional MACRO-END DELIMS)

Documentation

Return a property list of the argument number N of a macro.

The start of the macro to examine is given by MACRO-START, its end optionally by MACRO-END. With DELIMS the type of delimiters can be specified as a cons cell containing the opening char as the car and the closing char as the cdr. The chars have to have opening and closing syntax as defined in TeX-search-syntax-table(var)/TeX-search-syntax-table(fun).

The first item in the returned list is the string specified in the argument, with text properties. The second item is for backward compatibility and always nil.

Source Code

;; Defined in ~/.emacs.d/elpa/auctex-14.1.2/tex-fold.el
(defun TeX-fold-macro-nth-arg (n macro-start &optional macro-end delims)
  "Return a property list of the argument number N of a macro.
The start of the macro to examine is given by MACRO-START, its
end optionally by MACRO-END.  With DELIMS the type of delimiters
can be specified as a cons cell containing the opening char as
the car and the closing char as the cdr.  The chars have to have
opening and closing syntax as defined in
`TeX-search-syntax-table'.

The first item in the returned list is the string specified in
the argument, with text properties.  The second item is for
backward compatibility and always nil."
  (save-excursion
    (let* ((macro-end (or macro-end
                          (save-excursion (goto-char macro-start)
                                          (TeX-find-macro-end))))
           (open-char (if delims (car delims) ?{))
           (open-string (char-to-string open-char))
           (close-char (if delims (cdr delims) ?}))
           ;; (close-string (char-to-string close-char))
           content-start content-end)
      (goto-char macro-start)
      (if (condition-case nil
              (progn
                (while (> n 0)
                  (skip-chars-forward (concat "^" open-string) macro-end)
                  (when (= (point) macro-end)
                    (error nil))
                  (setq content-start (progn
                                        (skip-chars-forward
                                         (concat open-string " \t"))
                                        (point)))
                  (goto-char
                   (if (save-restriction
                         (widen)
                         ;; `widen' accomodates the following issue:
                         ;; with point on the `v' in `\end{verbatim}',
                         ;; LaTeX-verbatim-p returns nil normally, but t
                         ;; with region narrowed to avoid the
                         ;; corresponding `\begin{verbatim}'.
                         (TeX-verbatim-p))
                       (cond ((derived-mode-p 'LaTeX-mode)
                              (cdr (LaTeX-verbatim-macro-boundaries)))
                             ;; FIXME: When other modes implement a
                             ;; nontrivial `TeX-verbatim-p-function', we
                             ;; should return the appropriate endpoint
                             ;; here.
                             )
                     (if delims
                         (with-syntax-table
                             (TeX-search-syntax-table open-char close-char)
                           (scan-lists (point) 1 1))
                       (TeX-find-closing-brace))))
                  (setq content-end (save-excursion
                                      (backward-char)
                                      (skip-chars-backward " \t")
                                      (point)))
                  (setq n (1- n)))
                t)
            (error nil))
          (list (TeX-fold-buffer-substring content-start content-end))
        nil))))