git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Junio C Hamano <gitster@pobox.com>
Date
May 18, 2021, 01:27 UTC
Message-ID
<xmqqim3g4ys5.fsf@gitster.g>
In-Reply-To
<60a2f1c4cab0d_13c3702083a@natae.notmuch>
Felipe Contreras <felipe.contreras@gmail.com> writes:
Show 15 quoted lines
> Junio C Hamano wrote:
>> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
>> 
>> > This looks much better.
>> >
>> > I wonder a good follow-up (hint, hint! :) would be to have
>> > exec_man_man() and exec_man_cmd() in builtin/help.c set this depending
>> > on color.ui (so we'd do it by default with "auto").
>> >
>> > Then e.g. "git help git" would look prettier than "man git".
>> 
>> As long as color.man.ui can be used to override the blanket
>> color.ui, I think it is a good idea.
>
> Why not use color.pager?

I dug a bit to refresh my memory and it turns out that the reason we should not do so is because it means something totally different.

color.[ch] defines want_color() that applications like "diff" and "log" can use to see if the application is configured to paint its output in colors.

When that layer says for that particular application it should be decided automatically, then we call into color.c::check_auto_color() which is the only user of pager_use_color (which is set from the color.pager configuration variable). The purpose of that call is to ask if the pager is capable of colors.

So in short, the color.pager is about "is the pager capable of colors?" and the color.ui (and color.<cmd>) is about "does the user wants output from <cmd> in color?" We need to use color.help or something that controls whether the user wants help/man in colors, and perhaps default it to "auto" like color.ui defaults to, which then in turn would consult "color.pager". Tying it directly to "color.pager" is wrong.

Previous: Felipe ContrerasNext: Felipe Contreras
Message 7 of 15 in “Man pages have colors? A deep dive into groff”
  1. Felipe ContrerasMay 15, 2021
  2. Ævar Arnfjörð BjarmasonMay 17, 2021
  3. Junio C HamanoMay 17, 2021
  4. Felipe ContrerasMay 17, 2021
  5. Randall S. BeckerMay 17, 2021
  6. Felipe ContrerasMay 17, 2021
  7. Junio C HamanoMay 18, 2021
  8. Felipe ContrerasMay 18, 2021
  9. Jeff KingMay 18, 2021
  10. Felipe ContrerasMay 18, 2021
  11. Junio C HamanoMay 18, 2021
  12. brian m. carlsonMay 18, 2021
  13. Junio C HamanoMay 18, 2021
  14. Felipe ContrerasMay 18, 2021
  15. Felipe ContrerasMay 18, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.