[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: unrecognized X command 'sgr 0' ignored (was: early adopters of groff
From: |
G. Branden Robinson |
Subject: |
Re: unrecognized X command 'sgr 0' ignored (was: early adopters of groff 1.23.0) |
Date: |
Fri, 7 Jul 2023 22:33:06 -0500 |
Hi Alexis,
I think I found the problem.
At 2023-07-06T19:27:44-0500, G. Branden Robinson wrote:
> At 2023-07-06T23:34:20+0200, Alexis wrote:
[...]
> > Folks reviewing said PR have reported potentially related man-db
> > test failures caused by:
> >
> > grotty:<standard input>:(<standard input>):9: warning:
> > unrecognized X command 'sgr 0' ignored
[...]
> To get back to the problem you reported, that's mysterious to me. I
> don't see anything in man-db explicitly constructing device control
> command escape sequences that would cause this "unrecognized X command
> 'sgr 0' ignored" warning.
I found something that _was_ injecting device control escape sequences.
It's not in groff or man-db, but in one of NixOS's patches.
https://github.com/NixOS/nixpkgs/blob/nixos-23.05/pkgs/tools/text/groff/site.tmac
Long story short, you can't do that anymore. There are still two ways
of forcing SGR escape sequences off in the grotty(1) output driver, as
its man page documents.
You can arrange to have to grotty called with the `-c` option. One
challenge to this is getting the system's man librarian to pass it.
Colin Watson's man-db man(1) has long supported a $MANROFFOPT
environment variable for this purpose.
Alternatively, you can set the GROFF_NO_SGR environment variable (to any
value).
Populating either of these automatically may require modification of
users' shell startup files.
Nevertheless I would discourage doing so; turning of SGR escape
sequences defeats one of the headline features of groff 1.23.0, and
makes another less useful.[1]
I see that every release of NixOS ships a less(1) pager later than
version 566,[2] so not only should you be able to support this feature,
you can enable the OSC escape sequences it uses by default, by patching
man.local to include the following.
.\" Ensure hyperlinks are enabled for terminals.
.nr U 1
Regards,
Branden
[1] NEWS:
o The an (man) macro package can now produce clickable hyperlinks within
terminal emulators, using the OSC 8 support added to grotty(1) (see
below). The groff man(7) extension macros `UR` and `MT`, present
since 2007, expose this feature. At present the feature is disabled
by default in `man.local` pending more widespread recognition of OSC 8
sequences in pager programs. The package now recognizes a `U`
register to enable hyperlinks in any output driver supporting them.
Use a command like
printf '\033]8;;man:grotty(1)\033\\grotty(1)\033]8;;\033\\\n' | more
to check your terminal and pager for OSC 8 support. If you see
"grotty(1)" and no additional garbage characters, then you may wish to
edit "man.local" to remove the lines that disable this feature.
o The an (man) macro package supports a new macro, `MR`, intended for
use by man page cross references in preference to the font style
alternation macros historically used. Where before you would write
.BR ls (1).
or
.IR ls (1).
you should now write
.MR ls 1 .
(the third argument, typically used for trailing punctuation, is
optional). Because the macro semantically identifies a man page, it
can create a clickable hyperlink ("man:ls(1)" for the above example)
on supporting devices. Furthermore, a new string, `MF`, defines the
font to be used for setting the man page topic (the first argument to
`MR` and `TH`), permitting configuration by distributions, sites, and
users.
Inclusion of the `MR` macro was prompted by its introduction to
Plan 9 from User Space's troff in August 2020. Its purpose is to
ameliorate several long-standing problems with man page cross
references: (1) the package's lack of inherent hyperlink support for
them; (2) false-positive identification of strings resembling man page
cross references (as can happen with "exit(1)", "while(1)",
"sleep(5)", "time(0)" and others) by terminal emulators and other
programs; (3) the unwanted intrusion of hyphens into man page topics,
which frustrates copy-and-paste operations (this problem has always
been avoidable through use of the \% escape sequence, but cross
references are frequent in man pages and some page authors are
inexpert *roff users); and (4) deep divisions in man page maintenance
communities over which typeface should be used to set the man page
topic (italics, roman, or bold).
[2] https://repology.org/project/less/versions
signature.asc
Description: PGP signature