Re: [groff] Heirloom troff invoke macro from string

2019-01-08 Thread Mircea Hossu
I do not have experience with online collaborative programming, so I just opened a github account and created an issue regarding this, along with source code and a few more examples: Suggestion: adding external scripting support to troff: https://github.com/n-t-roff/heirloom-doctools/issues/82 Wo

Re: [groff] Heirloom troff invoke macro from string

2019-01-08 Thread aksr
Hi, On Mon, Jan 07, 2019 at 10:01:40AM -0800, Mircea Hossu wrote: > If anyone else is interested, I can share all my work, which is > implemented in the Heirloom troff source tree. Any other suggestions > are very much appreciated. Maybe you could open a pull request or similar: https://github

Re: [groff] Heirloom troff invoke macro from string

2019-01-07 Thread Mircea Hossu
Thank you, Tadziu, it is an interesting trick and it does work in the test case posted earlier. Unfortunately, in a more realistic document, I did hit those "unexpected results", e.g. when the string was used inside a macro argument (thank you for the warning). The final solution I picked was to c

Re: [groff] Heirloom troff invoke macro from string

2019-01-04 Thread Tadziu Hoffmann
> But, after a quick experiment, it seems to not behave this > way. The macro body gets expanded instead of executing: In groff it works with the following change: .de m \c .nr x +1 .. Be aware that this is only a trick. It works in the running text, but can go wrong unexpectedly in o

Re: [groff] Heirloom troff invoke macro from string

2019-01-04 Thread Mircea Hossu
I didn't know that was possible. Yes, it would indeed solve my problem. But, after a quick experiment, it seems to not behave this way. The macro body gets expanded instead of executing: .do xflag 3 .papersize a4 .mediasize a4 .ps 14p .vs 24p . .nr x 0 1 .de m .nr x +1 .. .ds s \\n+x .ds t \\*m\\n

Re: [groff] Heirloom troff invoke macro from string

2019-01-04 Thread Carsten Kunze
You can invoke a macro with name xxx with \*[xxx] instead of .xxx You can even provide arguments for the macro in the form \*[xxx arg1 ...] as explained in http://n-t-roff.github.io/heirloom/doctools/troff.pdf §7.1. Does this answer your question or did you mean something else?

[groff] Heirloom troff invoke macro from string

2019-01-04 Thread Mircea Hossu
Is it possible in Heirloom troff to invoke a macro from a string? There is an escape sequence: \R'R ±N' => Set number register R to ±N This is useful, but the expression is too limiting in some cases. For example, is it possible to increase register R by 1 only if it hasn't reached a maximum va