5.6.4.3 Adding Support for Option Completion
When the user inserts '\usepackage' by C-c C-m, AUCTeX asks for the optional arguments after the package name is given. The style file of that package can provide completion support for the optional arguments.
Variable: LaTeX-packagename-package-options
List of optional arguments available for the package.
Here is an excerpt from 'acronym.el':
(defvar LaTeX-acronym-package-options
'("footnote" "nohyperlinks" "printonlyused" "withpage"
"smaller" "dua" "nolist")
"Package options for the acronym package.")
When the package accepts key-value style optional arguments, more sophisticated completion support is needed. The package style file can provide dynamic completion support by custom elisp function.
Function: LaTeX-packagename-package-options
This function should ask the user for optional arguments and return them as a string, instead of built-in option query facility. When this function is defined, AUCTeX calls it with no argument.
Here is an excerpt from 'acro.el':
(defun LaTeX-acro-package-options ()
"Prompt for package options for the acro package."
(TeX-read-key-val t LaTeX-acro-package-options-list))
As you can see in the above example, a utility function TeX-read-key-val is available to read key-value pair(s) from users.
Note that defvar or defun of LaTeX-packagename-package-options should be at the top level of the style file and not inside the style hook, because the style hook is not yet called when the user inputs the optional arguments in response to C-c C-m.
There are similar facilities for class options. When the user inserts '\documentclass' by C-c C-e, the respective class style file can provide completion support for the optional arguments.
Variable: LaTeX-classname-class-options
List of optional arguments available for the class.
Function: LaTeX-classname-class-options
Which see.
In case the utility function TeX-read-key-val is used, the variable containing the key-value pair(s) should be called LaTeX-packagename-package-options-list or LaTeX-classname-class-options-list accordingly.