D.10.2 Catching Errors with Info Formatting

After you have written part of a Texinfo file, you can use the texinfo-format-region or the makeinfo-region command to see whether the region formats properly.

Most likely, however, you are reading this section because for some reason you cannot use the makeinfo-region command; therefore, the rest of this section presumes that you are using texinfo-format-region.

If you have made a mistake with an @-command, texinfo-format-region will stop processing at or after the error and display an error message. To see where in the buffer the error occurred, switch to the ‘*Info Region*’ buffer; the cursor will be in a position that is after the location of the error. Also, the text will not be formatted after the place where the error occurred (or more precisely, where it was detected).

For example, if you accidentally end a menu with the command @end menus with an ‘s’ on the end, instead of with @end menu, you will see an error message that says:

@end menus is not handled by texinfo

The cursor will stop at the point in the buffer where the error occurs, or not long after it. The buffer will look like this:

---------- Buffer: *Info Region* ----------
* Menu:

* Using texinfo-show-structure::  How to use
                                 to catch mistakes.
* Running Info-validate::         How to check for
                                 unreferenced nodes.
@end menus
---------- Buffer: *Info Region* ----------

The texinfo-format-region command sometimes provides slightly odd error messages. For example, the following cross-reference fails to format:

(@xref{Catching Mistakes, for more info.)

In this case, texinfo-format-region detects the missing closing brace but displays a message that says ‘Unbalanced parentheses’ rather than ‘Unbalanced braces’. This is because the formatting command looks for mismatches between braces as if they were parentheses.

Sometimes texinfo-format-region fails to detect mistakes. For example, in the following, the closing brace is swapped with the closing parenthesis:

(@xref{Catching Mistakes), for more info.}

Formatting produces:

(*Note for more info.: Catching Mistakes)

The only way for you to detect this error is to realize that the reference should have looked like this:

(*Note Catching Mistakes::, for more info.)

Incidentally, if you are reading this node in Info and type f RET (Info-follow-reference), you will generate an error message that says:

No such node: "Catching Mistakes) The only way ...

This is because Info perceives the example of the error as the first cross-reference in this node and if you type a RET immediately after typing the Info f command, Info will attempt to go to the referenced node. If you type f catch TAB RET, Info will complete the node name of the correctly written example and take you to the ‘Catching Mistakes’ node. (If you try this, you can return from the ‘Catching Mistakes’ node by typing l (Info-last).)