# Why does \iid macro in OPmac only support “,” or “.”

To create an index entry in OPmac one enters something like this:

Oh, how I like \ii figs figs.

Notice the repetition there? As a convenience OPmac provides \iid:

Oh, how I like \iid figs .

In this case, I didn't need to repeat the word "figs", though I did have to enter a space between the "s" and the "." in order for the sentence to be typeset correctly.

Unfortunately, the following does not typeset correctly:

Oh, does anyone else like \iid figs ?

In this case, instead of "figs?" being typeset, we get "figs ?" - with that space.

The culprit seems to be here:

\def\iiD{\ifx\tmp,\else\ifx\tmp.\else\space\fi\fi} % comma and period handled

I modified to include a question mark ("?") with

\def\iiD{\ifx\tmp,\else\ifx\tmp.\else\ifx\tmp?\else\space\fi\fi\fi}

but obviously other punctuation such as exclamation points, colons, semi-colons, etc are needed. Is there a better way to handle this perhaps?

-
Of course, you can redefine \iiD but you need to use the right number of \fis at the end of the macro. IMHO the other punctuation isn't frequent, than you can use \ii figs figs? or \iid figs \unskip?. Of course, you can use the claccical approach with braces and repeation: \iindex{figs}figs?. –  wipet Jun 21 '14 at 4:25
@wipet -- I fixed the missing \fi in the question. Thanks. –  acarlow Jun 21 '14 at 5:57

There is a possibility to redefine the \iid macro in order to do it more intelligent. The point is that the parameter of \iid is separated by space (instead of two braces) in order to spare typing. But may be, two braces are useful sometimes.
\let\iidC=\iid

Now you can use \iid word followed by space or \iid {word} without following space. In your case: \iid{figs}?.