Function: LaTeX-completion-parse-arg

LaTeX-completion-parse-arg is a byte-compiled function defined in latex.el.

Signature

(LaTeX-completion-parse-arg ARG)

Documentation

Parse ARG and call the correct candidates completion function.

ARG is the entry for the current argument in buffer stored in TeX-symbol-list(var)/TeX-symbol-list(fun) or LaTeX-environment-list(var)/LaTeX-environment-list(fun).

Source Code

;; Defined in ~/.emacs.d/elpa/auctex-14.1.2/latex.el
(defun LaTeX-completion-parse-arg (arg)
  "Parse ARG and call the correct candidates completion function.
ARG is the entry for the current argument in buffer stored in
`TeX-symbol-list' or `LaTeX-environment-list'."
  (when (or (and (vectorp arg)
                 (symbolp (elt arg 0))
                 (fboundp (elt arg 0)))
            (and (listp arg)
                 (symbolp (car arg))
                 (fboundp (car arg)))
            (and (symbolp arg)
                 (fboundp arg)))
    ;; Turn a vector into a list:
    (when (vectorp arg)
      (setq arg (append arg nil)))
    ;; Turn a single function symbol into a list:
    (unless (listp arg)
      (setq arg (list arg)))
    (let* ((head (car arg))
           (tail (cadr arg))
           (fun1 (lambda (elt)
                   (cond ((and (listp elt)
                               (symbolp (car elt))
                               (fboundp (car elt))
                               (not (eq (car elt) 'lambda)))
                          ;; It is a named function and not anonymous:
                          (funcall (car elt)))
                         ;; It is a function object
                         ((functionp elt)
                          (funcall elt))
                         ;; It is a variable name
                         ((and (symbolp elt)
                               (boundp elt))
                          (symbol-value elt))
                         ;; It is a plain list of strings:
                         (t elt)))))
      (cond ((eq head #'TeX-arg-key-val)
             (LaTeX-completion-candidates-key-val
              (funcall fun1 tail)))

            ((eq head #'TeX-arg-completing-read-multiple)
             (LaTeX-completion-candidates-completing-read-multiple
              (funcall fun1 tail)))

            ((eq head #'TeX-arg-completing-read)
             (LaTeX-completion-candidates-completing-read
              (funcall fun1 tail)))

            ((assq head LaTeX-completion-function-map-alist-keyval)
             (LaTeX-completion-candidates-key-val
              (funcall fun1 (cdr (assq head LaTeX-completion-function-map-alist-keyval)))))

            ((assq head LaTeX-completion-function-map-alist-cr)
             (LaTeX-completion-candidates-completing-read
              (funcall fun1 (cdr (assq head LaTeX-completion-function-map-alist-cr)))))

            (t nil)))))