Hi John,

At 2024-01-18T00:32:04+1100, John Gardner wrote:
> So instead of:
> > \X'ps: \fB\s(12\m[red]big bold red text in my device command\fP'
> >
> > one would write:
> > \fB\s(12\m[red]\X'ps: big bold red text in my device command'\fP
> 
> I believe you meant to provide an example more like this?
> 
> \X'ps: exec 1.0 0 0 setrgbcolor /Times-Bold findfont \n[.s] scalefont
> setfont (Text) show'

Well, not exactly, as I don't speak PostScript.  But you're offering a
good example of the sort of thing that my proposed change would _not_
affect: register interpolation escape sequences are interpolated in copy
mode, so assuming that the `.s` register contains an appropriate value,
then what you have should work fine, and in any case the same before and
after my proposed change.

A refresher on the definition of "copy mode" might be useful to the
discussion.

---snip groff info manual---
5.24.2 Copy Mode
----------------

GNU 'troff' processes certain requests in "copy mode": it interpolates
the escape sequences '\n', '\g', '\$', '\*', '\V', and '\?' normally;
interprets '\<RET>' immediately; discards comments '\"' and '\#';
interpolates the current leader, escape, or tab character with '\a',
'\e', and '\t', respectively; and represents all other escape sequences
in an encoded form.  The term "copy mode" reflects its most visible
application in requests that populate macros and strings, but other
requests also use it when interpreting arguments that can't meaningfully
represent typesetting operations.  For example, a font selection escape
sequence has no meaning in a hyphenation pattern file name ('hpf') or a
diagnostic message written to the terminal ('tm').

   The complement of copy mode--a 'roff' formatter's behavior when not
defining or appending to a macro, string, or diversion--where all macros
are interpolated, requests invoked, and valid escape sequences processed
immediately upon recognition, can be termed "interpretation mode".
--end snip---

And for those who don't have all the escape sequences memorized, here
are the ones that get interpreted even in copy mode.

---snip groff(7)---
    \n[reg]
            Interpolate contents of register with arbitrarily long
            name reg.
    \g[reg]
            Interpolate format of register with arbitrarily long name
            reg.
    \$[nnn]
            Interpolate macro or string parameter numbered nnn (nnn≥1).
    \*[string arg ...]
            Interpolate string with name string (of arbitrary length),
            taking arg ... as arguments.
    \V[env]
            Interpolate contents of environment variable with
            arbitrarily long name env.
    \?anything\?
            Transparently embed anything, read in copy mode, in a
            diversion, or unformatted as an output comparand in a
            conditional expression.  Ignored in the top‐level diversion.
---end snip---

Regards,
Branden

Attachment: signature.asc
Description: PGP signature

Reply via email to