groff
[Top][All Lists]
Advanced

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

Re: Proposed: make \X read its argument in copy mode


From: G. Branden Robinson
Subject: Re: Proposed: make \X read its argument in copy mode
Date: Mon, 22 Jan 2024 20:46:50 -0600

[self-follow-up]

> Or: Should device control commands affect the environment?
>
> Recall the definition of the \X escape sequence from CSTR #54 (1992).
>
>   10.7.  Transparent output.  The sequence \X'anything' copies anything
>   to the output, as a device control function of the form x X anything
>   (ยง22).  Escape sequences in anything are processed.
[...]
> I therefore propose to change this, and have the `\X` escape sequence
> read its argument in copy mode.  That will make it work like the
> `device` request in groff 1.23.0 and earlier[1].

It's looking like we _will_ be giving up something with this change:

The ability to use a newline as an escape sequence delimiter with the \X
escape sequence.

I would argue that this change is of vanishingly small impact.

1.  Likely few people knew you could use a newline as a delimiter with
    this escape sequence in the first place.
2.  You couldn't do that in DWB troff anyway.[1]
3.  The opposite problem is of greater interest to practical users:
    _embedding_ newlines inside device control commands.  \X didn't
    support that anyway, neither in DWB troff nor groff.[2]

But we have a bug report about this and a test case (that I just broke),
so I thought I'd mention it.[3]

(Also in NEWS if and when this lands, of course.)

I'm starting to see why the \? escape sequence uses itself as its own
terminating delimiter.  It is, as far as I can tell, the only escape
sequence that reads its argument in copy mode.  When you accept
delimiters that aren't necessarily characters but have been tokenized,
but the whole point of copy mode is to read characters _rather than_
tokens (with a few exceptions), things get interesting.

We haven't heard from Werner in a while.  I wonder if he's out there
getting a chuckle watching me crash into dusty corners and weird warts.

...or if he's trying hard to repress memories of the painful,
Lovecraftian horrors of underspecification I'm blundering into...

:-O

Regards,
Branden

[1]

$ printf '\\X#device: abc#\n.tm all done\n' | DWBHOME=. ./bin/troff \
  | grep -C1 'x X'
all done
V120
x X device: abc
n120 0

[2]

$ printf '\\X#ps: foo\nbar#\n.tm all done\n' | DWBHOME=. ./bin/troff | grep -C1 
'x X'
all done
V240
x X ps: foo
cb

$ printf '\\X#ps: foo\nbar#\n.tm all done\n' | groff -Z | grep -C1 'x X'
all done
DFd
x X ps: foo
wh2500

[3] https://savannah.gnu.org/bugs/?63011
    
https://git.savannah.gnu.org/cgit/groff.git/tree/src/roff/groff/tests/some_escapes_accept_newline_delimiters.sh?h=1.23.0

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]