Function: LaTeX-arg-usepackage-read-packages-with-options
LaTeX-arg-usepackage-read-packages-with-options is a byte-compiled
function defined in latex.el.
Signature
(LaTeX-arg-usepackage-read-packages-with-options)
Documentation
Read the packages and the options for the usepackage macro.
If at least one package is provided, this function returns a cons cell, whose CAR is the list of packages and the CDR is the string of the options, nil otherwise.
Source Code
;; Defined in ~/.emacs.d/elpa/auctex-14.1.2/latex.el
(defun LaTeX-arg-usepackage-read-packages-with-options ()
"Read the packages and the options for the usepackage macro.
If at least one package is provided, this function returns a cons
cell, whose CAR is the list of packages and the CDR is the string
of the options, nil otherwise."
(let* ((TeX-file-extensions '("sty"))
(crm-separator ",")
packages var options)
(unless LaTeX-global-package-files
(if (if (eq TeX-arg-input-file-search 'ask)
(not (y-or-n-p "Find packages yourself? "))
TeX-arg-input-file-search)
(progn
(message "Searching for LaTeX packages...")
(setq LaTeX-global-package-files
(mapcar #'list (TeX-search-files-by-type
'texinputs 'global t t)))
(message "Searching for LaTeX packages...done"))))
(setq packages (TeX-completing-read-multiple
"Packages: " LaTeX-global-package-files))
;; Clean up hook before use in `LaTeX-arg-usepackage-insert'.
(setq LaTeX-after-usepackage-hook nil)
(mapc #'TeX-load-style packages)
;; Prompt for options only if at least one package has been supplied, return
;; nil otherwise.
(when packages
(setq var (if (= 1 (length packages))
(intern (format "LaTeX-%s-package-options" (car packages)))
;; Something like `\usepackage[options]{pkg1,pkg2,pkg3,...}' is
;; allowed (provided that pkg1, pkg2, pkg3, ... accept same
;; options). When there is more than one package, set `var' to
;; a dummy value so next `if' enters else form.
t))
(if (or (and (boundp var)
(listp (symbol-value var)))
(fboundp var))
(if (functionp var)
(setq options (funcall var))
(when (symbol-value var)
(setq options
(mapconcat #'identity
(TeX-completing-read-multiple
"Options: " (mapcar #'list (symbol-value var)))
","))))
(setq options (TeX-read-string "Options: ")))
(cons packages options))))