From: Felipe Contreras <felipe.contreras@gmail.com>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>, git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
"Felipe Contreras" <felipe.contreras@gmail.com>,
"Jeff King" <peff@peff.net>,
"Phillip Wood" <phillip.wood123@gmail.com>,
"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: RE: [PATCH v7] help: colorize man pages if man.color=true under less(1)
Date: Mon, 21 Jun 2021 10:59:24 -0500 [thread overview]
Message-ID: <60d0b75c80635_105b452089b@natae.notmuch> (raw)
In-Reply-To: <patch-1.1-a950ef49e28-20210621T083254Z-avarab@gmail.com>
Ævar Arnfjörð Bjarmason wrote:
> From: Felipe Contreras <felipe.contreras@gmail.com>
>
> We already colorize tools traditionally not colorized by default, like
> diff and grep. Let's do the same for man, but only if `color.man` is
> explicitly set to "true".
>
> Unlike other `color.*` output this colorization is not enabled by
> `color.ui` being true, the user needs to explicitly set the
> `color.man` variable to `true.
>
> When it was proposed to treat `color.man` like any other `color.*`
> variable some thought that git opting in coloring for an external
> program such as man(1) was a step too far[1], even if the user invoked
> it via the "git help <topic>" wrapper.
>
> So let's make this explicitly opt-in for now. As noted in the
> documentation we're leaving ourselves an out to turn this on by
> default in the future, or e.g. putting it under the
> feature.experimental umbrella. We probably won't, but let's not
> promise users that `color.man` will forever be a special-case.
>
> As for what this actually does the effect of having this enabled is
> that a documentation blurb like (some parts elided with "[...]"):
>
> NAME
> ----
> git-config - Get and set [...]
>
> SYNOPSIS
> --------
> [...]
> 'git config' [<file-option>] [...]
> [...]
> The `--type=<type>` option instructs 'git config' to ensure [...]
>
> Will have "NAME" and "SECTION" shown as BOLD RED instead of BOLD, "git
> config" and other '-quoted parts in BLUE UNDERLINE instead of
> UNDERLINE, and `--type=<type>` and other `-quoted parts in RED BOLD
> instead of BOLD. The "Standout" setting is then used for the user's
> own search bar (invoked with "/") and prompt. See [2] for more
> examples
>
> Normally check_auto_color() would check the value of `color.pager`, but
> in this particular case it's not git the one executing the pager, but
> man. Therefore we need to check pager_use_color ourselves.
>
> We do not need to support `color.man` being set to `always`; The `git
> help` command is always run for a tty (it would be very strange for a
> user to do `git help $page > output`, but in fact, that works anyway,
> we don't even need to check if stdout is a tty, but just to be
> consistent we do). So it's simply a boolean in our case.
>
> So, in order for this change to have any effect:
>
> 1. color.man=true must be set in the config
> 2. The user must use less
> 3. Not have the same LESS_TERMCAP variables set (we call setenv(3) with overwrite=0)
> 4. Have color.ui enabled
> 5. Not have color.pager disabled
> 6. Not have git with stdout directed to a file
>
> 1. https://lore.kernel.org/git/87tun1qp91.fsf@evledraar.gmail.com/
> 2. https://unix.stackexchange.com/questions/119/colors-in-man-pages/147
>
> Suggested-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Looks good to me.
--
Felipe Contreras
next prev parent reply other threads:[~2021-06-21 15:59 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-23 5:44 [PATCH v6] help: colorize man pages Felipe Contreras
2021-05-24 13:13 ` Phillip Wood
2021-05-24 16:56 ` Felipe Contreras
2021-06-08 12:35 ` Ævar Arnfjörð Bjarmason
2021-06-08 13:57 ` Junio C Hamano
2021-06-08 17:48 ` Felipe Contreras
2021-06-21 8:34 ` [PATCH v7] help: colorize man pages if man.color=true under less(1) Ævar Arnfjörð Bjarmason
2021-06-21 10:17 ` Phillip Wood
2021-06-21 10:28 ` Junio C Hamano
2021-06-21 18:41 ` Felipe Contreras
2021-06-21 19:08 ` Ævar Arnfjörð Bjarmason
2021-06-23 23:58 ` Jeff King
2021-06-24 1:03 ` Felipe Contreras
2021-06-28 17:37 ` Junio C Hamano
2021-06-28 18:05 ` Felipe Contreras
2021-06-21 15:59 ` Felipe Contreras [this message]
2021-06-24 0:08 ` Jeff King
2021-06-29 1:42 ` Junio C Hamano
2021-06-29 1:48 ` Felipe Contreras
2021-06-24 1:44 ` [PATCH v6] help: colorize man pages Felipe Contreras
2021-06-26 2:50 ` [PATCH v8] help: add option to colorize man pages under less Felipe Contreras
2021-06-26 14:49 ` Ævar Arnfjörð Bjarmason
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=60d0b75c80635_105b452089b@natae.notmuch \
--to=felipe.contreras@gmail.com \
--cc=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=peff@peff.net \
--cc=phillip.wood123@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).