Gaius Mulley wrote: > What is the best way to prepend commands to an existing macro. > For example, say, in -ms how can one easily define a new `.LP' > do some work and then call the original old `.LP' safely.. > > Here is my example code and I'm puzzled at the infinite recursion > when LP is invoked. > > [sample doc source snipped]
Hi Gaius, The way you have done this looks about right. I wonder if you are being bitten by the internal workings of `s.tmac', for in reality `LP' is defined as [EMAIL PROTECTED]', and then `LP' is made an alias for this; furthermore, this alias is reasserted, at various points in a variety of other `ms' macro invocations. In fact, because of the way the alias is initialised, it may refer to a one-time setup macro, at the time you redefine it; your redefinition would then put `ms' into an infinite initialisation logic loop. This seems to produce the required behaviour: --------8<--------------------------- .mso s.tmac .pl 20 \" keep output on screen with `nroff -c' .rn @LP [EMAIL PROTECTED] .de @LP .tm This is my LP extension. [EMAIL PROTECTED] .. .LP Here is some text. .LP And here is some more. --------8<--------------------------- BTW, keeping your example exactly as is, I reproduce your infinite recursion, but if I add a `.SH' say, before the first `.LP', then I see the behaviour I expected, except that the extended behaviour isn't invoked; `.SH' implicitly reasserts `.als LP @LP', so overriding the redefinition, which I would suggest confirms the initialisation loop theory. Redefining the [EMAIL PROTECTED]' macro, as above, gives expected behaviour, including invocation of the extension, in either case. Also note that you don't need to `.rm @LP' after the `.rn' -- it doesn't exist at this point anyway. HTH. Regards, Keith. _______________________________________________ Groff mailing list [email protected] http://lists.gnu.org/mailman/listinfo/groff
