Next: , Up: Programming definitions


7.1 Category codes

Plain TeX defines \active (as the number 13) for use in changing category codes. Although the author of The TeXbook has “intentionally kept the category codes numeric”, two other categories are commonly used: letters (category code 11) and others (12). Therefore, Eplain defines \letter and \other. Sometimes it is cleaner to make a character active without actually writing a \catcode command. The \makeactive command takes a character as an argument to make active (and ignores following spaces). For example, here are two commands which both make \ active:

     \makeactive\\   \makeactive92

Sometimes you might want to temporarily change the category code of the `@' character to \letter, so that you can use or define macros which are normally inaccessible to the user. For such situations, Eplain provides the \makeatletter command. It sets the category code of `@' to \letter (11) and defines \resetatcatcode to restore the category code to whatever it was before the call to \makeatletter. For example:

     \makeatletter
     \def\@hidden@macro{This macro cannot normally be
                        called / redefined by the user}
     \resetatcatcode

There is also \makeatother which works similarly but sets the category code of `@' to \other (12).

Usually, when you give a definition to an active character, you have to do so inside a group where you temporarily make the character active, and then give it a global definition (cf. the definition of \obeyspaces in The TeXbook). This is inconvenient if you are writing a long macro, or if the character already has a global definition you do not wish to transcend. Eplain provides \letreturn, which defines the usual end-of-line character to be the argument. For example:

     \def\mymacro{... \letreturn\myreturn ... }
     \mymacro hello
     there

The end-of-line between `hello' and `there' causes \myreturn to be expanded.

The TeXbook describes \uncatcodespecials, which makes all characters which are normally “special” into “other” characters, but the definition never made it into plain TeX. Eplain therefore defines it.

Finally, \percentchar expands into a literal `%' character. This is useful when you \write TeX output to a file, and want to avoid spurious spaces. For example, Eplain writes a \percentchar after the definition of cross-references. The macros \lbracechar and \rbracechar expand similarly.