7.2 Setting and Getting Conversion Customization Variables

The conversion customization variables are set as follows. First, variables set in the main program, in particular from init files, are passed to the converter. Some variables are especially set in the converter to default values (see Getting Converter Default Variables Values). Next, variables are set in the converter based on the main program customization variables values. Finally, some variables should be set or reset during conversion, in particular when converting the tree representing the Texinfo document, when expanding the tree element corresponding to @-commands associated with customization variables (see Customization Variables for @-Commands in Texinfo).

The functions described here should be used in user defined functions, but should not be used out of functions. Conversely, the similar functions used to set customization variables from init files without a converter should not be used in functions, but should be used out of functions in init files (see Managing Customization Variables).

To get the value of a variable in a converter $converter, the function is get_conf:

Function: $result = $converter->get_conf ($variable_name)

$variable_name is the name of the variable; its value in the converter $converter (possibly undef) is returned.

For example:

my $footnotestyle = $converter->get_conf('footnotestyle');

To set a variable in a converter $converter, the function is set_conf:

Function: $converter->set_conf ($variable_name, $variable_value)

$variable_name is the name of the variable; its value in the converter $converter is set to $variable_value. The $variable_name value will not be overidden if it was set from the command line or from an init file.

For example:

$converter->set_conf('footnotestyle', 'separate');

Customization variables are mainly set and accessed during conversion, using the current value obtained from the command-line, init files or @-commands in the document. However, they may also be accessed before starting the conversion for example for the conversion of the title obtained from commands such as @settitle. In that case, the values customization variables had before the conversion, at the end of the preambule or at the end of the document could be used.

This has consequences on how early you should set the values for customizations variables in your code, especially for the customization variables associated with @-commands. If a value set by set_conf is intended to be found when pre-conversion value is needed, or preambule or end of document value is needed and there are are no @-commands at those locations in the Texinfo manual, set_conf should be called early. For example, when called from a user-defined function called at different stage, it should be called in the ‘setup’ stage (see Init File Calling at Different Stages).

The values set in converter with set_conf will not override command-line set customization variables, nor variables set early in init files. This is the expected behaviour, in particular when the values are set from the document. In the rare cases when overriding the customization would be needed, the force_conf function can be used:

Function: $converter->force_conf ($variable_name, $variable_value)

$variable_name is the name of the variable; its value in the converter $converter is set to $variable_value, overriding any previous value.