16.5 Line Macros

You can also define a macro using the ‘@linemacro’ command. The syntax for line macro definitions is similar to that for @macro.

However, the syntax for using a macro defined this way is different. The macro call uses the rest of the line, with arguments separated by spaces. The line macro facility is mainly intended to allow you to define commands that operate similarly to the builtin commands for providing definitions (see Definition Commands).

For example:

@linemacro defbuiltin {name, args}
@defline {Builtin} \name\ \args\
@end linemacro

The above macro may be used as

@defblock
@defbuiltin foo (bar)
Explanation
@end defblock

This produces the following result:

Builtin: foo (bar)

Explanation

Here the first argument is ‘foo’, and is substituted where ‘\name\’ appears in the macro body. Likewise, ‘(bar)’ is substituted for ‘\args\’.

You can include spaces in a macro argument by surrounding the argument by braces. Any pair of braces enclosing an argument is removed before substitution. Any empty arguments (including the last one) must be given as ‘{}’. Additionally, non-initial spaces may appear in the final argument in the argument list without surrounding braces (as in the example below).

If an argument line for a line macro ends in a ‘@’ character, then this character together with the following newline are included in a macro argument, and the following line in the input file is also used to get the arguments for the macro. Note that any substitution of the ‘@<newline>’ sequence must be in a valid context, such as a definition line (see Definition Command Continuation Lines).

Another example:

@linemacro deffunc {type, name, args}
@findex \name\
@deftypeline {Func} {\type\} \name\ \args\
@end linemacro

@defblock
@deffunc {long int} F (int @var{one}, int @var{two}, @
int @var{three}, int @var{four}, int @var{five})
Explanation
@end defblock

Note how braces are needed around ‘\type\’ in the macro body in case the type argument contains a space. This example produces the output below and enters an index entry for F.

Func: long int F (int one, int two, int three, int four, int five)

Explanation

Line macros produce a whole number of lines of output in their expansion. There may be better compatibility between the Texinfo processors (texi2any and TeX with texinfo.tex) for macros defined with @linemacro than for those defined with @macro.