[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[AUCTeX-diffs] [elpa] externals/auctex 3684fde 17/71: Explain how to sup
From: |
Tassilo Horn |
Subject: |
[AUCTeX-diffs] [elpa] externals/auctex 3684fde 17/71: Explain how to support option completion |
Date: |
Fri, 17 Dec 2021 15:00:27 -0500 (EST) |
branch: externals/auctex
commit 3684fdeb688347e1656cd922d2a658bff704016f
Author: Ikumi Keita <ikumi@ikumi.que.jp>
Commit: Ikumi Keita <ikumi@ikumi.que.jp>
Explain how to support option completion
* doc/auctex.texi (Adding Other): Add explanation for style file
authors: How to provide support for completion of optional arguments
for \usepackage and \documentclass.
---
doc/auctex.texi | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 59 insertions(+), 2 deletions(-)
diff --git a/doc/auctex.texi b/doc/auctex.texi
index 5f8df63..3a9ae01 100644
--- a/doc/auctex.texi
+++ b/doc/auctex.texi
@@ -5610,6 +5610,8 @@ Expert environments are completed depending on
@code{TeX-complete-expert-command
@cindex Bibliographies, adding
@cindex Examining package/class options
@cindex package/class options, Examining
+@cindex Adding support for completion of package/class options
+@cindex support for completion of package/class options, Adding
@cindex Viewer predicates
@cindex Defining bibliographies in style hooks
@cindex Adding labels
@@ -5633,10 +5635,10 @@ Add each @var{bibliography} to list of loaded
bibliographies.
Add each @var{label} to the list of known labels.
@end defun
-@subsubsection Examining package/class options
+@subsubsection Examining Package/Class Options
In @LaTeX{} documents, style hooks can find the package names and those
-options given as optional argument(s) of @code{\usepackage} in
+options given as optional argument(s) of @samp{\usepackage} in
@code{LaTeX-provided-package-options}.
@defvar LaTeX-provided-package-options
@@ -5685,6 +5687,61 @@ first found class option matching @var{regexp}, or nil
if not found.
These functions are also useful to implement customized predicate(s) in
@code{TeX-view-predicate-list}. @xref{Starting Viewers}.
+@subsubsection Adding Support for Option Completion
+When the user inserts @samp{\usepackage} by @kbd{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.
+
+@defvar LaTeX-@var{packagename}-package-options
+List of optional arguments available for the package.
+@end defvar
+
+Here is an excerption from @samp{acronym.el}:
+@lisp
+(defvar LaTeX-acronym-package-options
+ '("footnote" "nohyperlinks" "printonlyused" "withpage" "smaller" "dua"
"nolist")
+ "Package options for the acronym package.")
+@end lisp
+
+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.
+
+@defun LaTeX-@var{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.
+@end defun
+
+Here is an excerption from @samp{acro.el}:
+@lisp
+(defun LaTeX-acro-package-options ()
+ "Prompt for package options for the acro package."
+ (TeX-read-key-val t LaTeX-acro-package-options-list))
+@end lisp
+
+As you can see in the above example, a utility function
+@code{TeX-read-key-val} is available to read key-value pair(s) from users.
+
+Note that @code{defvar} or @code{defun} of
+@code{LaTeX-@var{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
+@kbd{C-c C-m}.
+
+There are similar facilities for class options. When the user inserts
+@samp{\documentclass} by @kbd{C-c C-e}, the respective class style file
+can provide completion support for the optional arguments.
+
+@defvar LaTeX-@var{classname}-class-options
+List of optional arguments available for the class.
+@end defvar
+
+@defun LaTeX-@var{classname}-class-options
+Which see.
+@end defun
+
@node Hacking the Parser
@subsection Automatic Extraction of New Things
@cindex Parsing new macros
- [AUCTeX-diffs] [elpa] externals/auctex 16bcc8d 21/71: ; * tex.el (TeX-source-correlate-mode): Quote function name by #'., (continued)
- [AUCTeX-diffs] [elpa] externals/auctex 16bcc8d 21/71: ; * tex.el (TeX-source-correlate-mode): Quote function name by #'., Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 2af20f4 27/71: ; Silence TeX warnings, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 363b778 56/71: Update style/multicol.el to package version 1.9b, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 7fa094f 14/71: ; * style/tabulary.el ("tabulary"): Really append the entry., Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 2ee9a07 71/71: Merge remote-tracking branch 'origin/master' into externals/auctex, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 0752650 44/71: Don't use obsolete @inforef, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex bc5f7bc 60/71: Add new style/cancel.el, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 380bc4a 06/71: Handle optional embellishment arguments correctly, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex db45d9e 41/71: Improve handling of key=vals in style/mdframed.el, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 9f3e760 10/71: Recognize L3 \msg_line_context: on warning parsing, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 3684fde 17/71: Explain how to support option completion,
Tassilo Horn <=
- [AUCTeX-diffs] [elpa] externals/auctex 44a8a42 09/71: ; Don't use `assoc-delete-all', Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 22e4415 68/71: Add styles for packages from sttools collection, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex ae2d7ef 23/71: Silence compiler warning, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 6433dc3 30/71: Extend `TeX-read-key-val' to accept a function call, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex c6350aa 07/71: Track standardized generic hook names in LaTeX kernel, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 8e0fb65 47/71: Improve handling of key=vals in style/listings.el, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex accfe51 58/71: Add new style/xr-hyper.el, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 483f6e9 05/71: ; * style/hyperref.el ("hyperref"): Fix other link to testform.tex., Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 0c01b75 13/71: ; * doc/changes.texi: Fix a markup., Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex ee37db3 33/71: Supplement doc string, Tassilo Horn, 2021/12/17