public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Kyle Lippincott <spectral@google.com>
Cc: Yaakov Smith <Yaakov.Smith@wisetechglobal.com>,
	"git@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: \b character escapes in CLI usage
Date: Wed, 26 Feb 2025 17:06:28 -0500	[thread overview]
Message-ID: <20250226220628.GA600528@coredump.intra.peff.net> (raw)
In-Reply-To: <CAO_smVjC=CWeAEjZjr9PPuBTkyYus59o_J9hfnpJCB-AsBE0HA@mail.gmail.com>

On Wed, Feb 26, 2025 at 08:38:15AM -0800, Kyle Lippincott wrote:

> > In modern versions of less you can get around it with:
> >
> >   LESS="-U --proc-tab"
> >
> > or:
> >
> >   LESS="--PROC-BACKSPACE"
> >
> > but those are new in less 632, from the last year or two. So I don't
> > think we can rely on it in our default variable, but people with recent
> > versions of less should consider setting it.
> 
> From another issue (https://github.com/gwsw/less/issues/557) I learned
> you can do this:
> 
> LESSKEY_CONTENT='#env;#version>=632 LESS=${LESS} --PROC-BACKSPACE'
> 
> I haven't tested it yet, but that might be a decent solution? I don't
> know how composable those are; e.g. if you wanted both
> --PROC-BACKSPACE on >=632 and --no-poll on >=670, I'm *assuming* you
> can do that, but I don't know what the syntax looks like.

Thanks for the pointer, I didn't know about that. I think it is fully
composable, as the "#version" conditional just applies to one line. So:

  LESSKEY_CONTENT='#env;#version>=632 LESS=${LESS} --PROC-BACKSPACE;#version >=670 LESS=${LESS} --no-poll'

However, I couldn't get even the basic version to work. Turns out that
LESSKEY_CONTENT was added in 645, and I'm running 643 from Debian
unstable).

So it kind-of works for our case if we make 645 the minimum (and don't
help versions between 632 and 645 at all). I think we could get even
hackier to support old versions like:

  # probably would be $prefix/share/git/lesskey in a real install
  fn=/tmp/lesskey
  {
	echo "#env"
	echo "#version >= 632 LESS=${LESS} --PROC-BACKSPACE"
  } >"$fn"

  # This works back to less 582. Before that we have to compile it to a
  # binary format with "lesskey" and point to it with $LESSKEY.
  LESSKEYIN=$fn git log

I guess we'd also need to put more details into setup_pager_env(). Right
now its logic is just "do not set $FOO if $FOO is already set". But we'd
probably want rules like "if $LESS is set, do not try to override it
with $LESSKEY_CONTENT".

I'm inclined to punt on it for a while. People can set up $LESS
themselves based on what they have available, and once these features
have been around for a while, we might then consider adding them to our
defaults.

-Peff

  reply	other threads:[~2025-02-26 22:06 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-25 23:44 \b character escapes in CLI usage Yaakov Smith
2025-02-26  7:38 ` Jeff King
2025-02-26  8:09   ` Jeff King
2025-02-26 16:02     ` Junio C Hamano
2025-02-26 16:38     ` Kyle Lippincott
2025-02-26 22:06       ` Jeff King [this message]
2025-02-26 15:59   ` Junio C Hamano
2025-02-26 23:36   ` brian m. carlson
2025-02-26 23:55     ` Junio C Hamano
2025-02-27  0:03     ` Junio C Hamano
2025-02-27 14:06       ` General output formatting (was: Re: \b character escapes in CLI usage) Marc Branchaud
2025-02-27 17:06         ` General output formatting Junio C Hamano
2025-02-27 17:14           ` Marc Branchaud
2025-02-27 18:40             ` Junio C Hamano
2025-02-27 16:26     ` \b character escapes in CLI usage Phillip Wood

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=20250226220628.GA600528@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=Yaakov.Smith@wisetechglobal.com \
    --cc=git@vger.kernel.org \
    --cc=spectral@google.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