Next: Conditional Nesting, Previous: Flags: @set
, @clear
, conditionals, and @value
, Up: Conditionally Visible Text [Contents][Index]
@ifcommanddefined
, @ifcommandnotdefined
Occasionally, you may want to arrange for your manual to test if a
given Texinfo command is available and (presumably) do some sort of
fallback formatting if not. There are conditionals
@ifcommanddefined
and @ifcommandnotdefined
to do this.
For example:
@ifcommanddefined node Good, @samp{@@node} is defined. @end ifcommanddefined
will output the expected ‘Good, ‘@node’ is defined.’.
This conditional will also consider any new commands defined by
the document via @macro
, @alias
,
@definfoenclose
, and @def(code)index
(see Defining New Texinfo Commands) to be true. Caveat: the TeX
implementation reports internal TeX commands, in addition to all
the Texinfo commands, as being “defined”; the makeinfo
implementation is reliable in this regard, however.
You can check the NEWS file in the Texinfo source distribution and linked from the Texinfo home page (http://www.gnu.org/software/texinfo) to see when a particular command was added.
These command-checking conditionals themselves were added in
Texinfo 5.0, released in 2013—decades after Texinfo’s
inception. In order to test if they themselves are available,
the predefined flag txicommandconditionals
can be tested, like
this:
@ifset txicommandconditionals @ifcommandnotdefined foobarnode (Good, @samp{@@foobarnode} is not defined.) @end ifcommandnotdefined @end ifset
Since flags (see the previous section) were added early in the existence of Texinfo, there is no problem with assuming they are available.
We recommend avoiding these tests whenever possible—which is usually the case. For many software packages, it is reasonable for all developers to have a given version of Texinfo (or newer) installed, and thus no reason to worry about older versions. (It is straightforward for anyone to download and install the Texinfo source; it does not have any problematic dependencies.)
The issue of Texinfo versions does not generally arise for end users. With properly distributed packages, users need not process the Texinfo manual simply to build and install the package; they can use preformatted Info (or other) output files. This is desirable in general, to avoid unnecessary dependencies between packages (see Releases in GNU Coding Standards).
Next: Conditional Nesting, Previous: Flags: @set
, @clear
, conditionals, and @value
, Up: Conditionally Visible Text [Contents][Index]