[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

OT: need M4 help-macros/stripping arg. spaces



I'm writing some macros for a latex package which uses M4 to preprocess them
before heading into Perl.  This is a first time for me in scripting such
things, and I'm learning by example and the info page on M4 how to decide
various things.  

My question relates to managing the following scenario:

In latex, writing 
   _cox(_oh,-)
should expand based on the definition

define('_cox', 'branch { atom("C",C);
                ifelse($2,'-',' bond(l+,=C) atom("O",C); bond(l--) $1; ',
                ' bond(l+) $1; bond(l--,=C) atom("O",C); ')
                } ')

(BTW, I use joe and don't know how to allow the back-tic character... so
I've substituted with the normal forward tic in the above.)  (One day I'll
move to a "real" editor.  Is there one like what is used in mc, BTW?)

The issue involves managing times when I (or someone else) types
   _cox(_oh, - )   or   _cox(_oh,- )
which adds the extra space onto the 2nd argument (I understand leading
spaces are stripped). At this point the ifelse statement fails.

I tried substituting
    ifelse(substr($2,1,1),'-', ... )
but this failed as well.

Is there a way to deal with this (either through some manipulation or use
of a different flag which wouldn't be affected this way)?

Thanks very much for any help!

Kenward Vaughan


Reply to: