Re: Man pages have colors? A deep dive into groff

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

 



On Mon, May 17, 2021 at 11:27:23PM -0500, Felipe Contreras wrote:

> > So in short, the color.pager is about "is the pager capable of
> > colors?"
> 
> That's not the case.
> 
> Even the documentation says so:
> 
>   color.pager::
>     A boolean to enable/disable colored output when the pager is in
>     use (default is true).

I think that documentation misses the reason you'd want to use it.
Likewise, the commit message introducing it (aa086eb813d) sucks, but the
motivation (from [0]) was:

  When I use a pager that escapes the escape character or highlights the
  content itself the output of git diff without the pager should have
  colors but not with the pager.  For example using git diff with a
  pathspec is quite short most of the time.  For git diff I have to
  enable paging manually and run git diff | $PAGER usually but git log
  uses the pager automatically and should not use colors with it.

For a more concrete example, my pager _does_ understand colors, and I
would not want to set pager.color to "false" (because then "git log",
etc, would not show me any colors). But I don't like the man colors you
are suggesting. I want to be able to turn them off by setting
"color.man" or similar to false, not by disabling color for everything
that is paged.

So color.pager being true is _necessary_ for showing colors in paged
outputs, but by itself is not sufficient. We have other per-context
color options (color.diff, color.branch, and so on).

And so likewise, we would want to avoid turning on colors if the user
has set color.pager=false. Usually this is done automatically because
want_color() checks, which knows if we are using the pager or not. But
if we are going to call out to "man" which will invoke another pager,
that caller would have to check pager_use_color themselves (it's yet
another question of whether "the pager can handle color" applies equally
to the pager that Git will run versus the one that man will run).

-Peff

[0] https://lore.kernel.org/git/E1G6zPH-00062L-Je@xxxxxxxxxxxx/



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux