jj icon indicating copy to clipboard operation
jj copied to clipboard

cli: Provide better flags for the "less" pager than default

Open benbrittain opened this issue 5 months ago • 5 comments

Checklist

If applicable:

  • [ ] I have updated CHANGELOG.md
  • [ ] I have updated the documentation (README.md, docs/, demos/)
  • [ ] I have updated the config schema (cli/src/config-schema.json)
  • [ ] I have added tests to cover my changes

benbrittain avatar Feb 03 '24 18:02 benbrittain

I think this should be documented in https://martinvonz.github.io/jj/v0.13.0/config/#pager. The simplest thing would be to change a sentence to say:

less -FRX is the default pager in the absence of any other setting, or if $PAGER is exactly equal to less.

You could also add footnote about how to disable this behavior.

If it's a chore, this doesn't have to be a blocker; we can do it in a separate PR.

Overall, I think this idea could work; we'll see if anybody gets annoyed by it. I can imagine somebody not liking -FX, but I think these people will be few.

One thing I like about this implementation is that it won't affect people who set PAGER to less --mouse -FRX as I used to do.

ilyagr avatar Feb 03 '24 23:02 ilyagr

Overall, I think this idea could work; we'll see if anybody gets annoyed by it. I can imagine somebody not liking -FX, but I think these people will be few.

I don't like -F, but I'm not strongly against this change. User can always override the default.

fwiw, both git and hg respect $LESS if set.

yuja avatar Feb 04 '24 02:02 yuja

I almost feel like the actual right answer is to have a built-in pager with the defaults jj would prefer, then allow users to set preferring the system pager if they want.

benbrittain avatar Feb 04 '24 15:02 benbrittain

I almost feel like the actual right answer is to have a built-in pager with the defaults jj would prefer, then allow users to set preferring the system pager if they want.

We discussed this a few times, but unfortunately didn't create a bug for it.

https://github.com/markbt/streampager would be a nice option, but it seems no longer maintained. It's what Sapling uses. I think I found a few more Rust pagers, but they seemed very new.

There are some nice Golang pagers (moar and ov), but I don't know how to link them to a Rust program. (They are not perfect; I tried using them instead of less for a while, but there is always some minor issue that made me switch back to less. But they have better defaults).

ilyagr avatar Feb 04 '24 18:02 ilyagr

There are some nice Golang pagers (moar and ov), but I don't know how to link them to a Rust program.

as a last resort, if you really want to distribute jj as a single static binary, you could embed the entire Go binary as static data in the rust binary, and then unpack it at runtime into a binary in the same directory (or run it in-memory with https://docs.rs/memfd-exec). but i know that's kinda hacky.

jyn514 avatar Feb 07 '24 02:02 jyn514

As I commented on the Issue, if you are interesting all of what git does, see https://github.com/epage/git-dive/blob/main/src/git_pager.rs

As for built-in pagers, one I hadn't seen mentioned is https://crates.io/crates/minus.

epage avatar Feb 11 '24 01:02 epage

Right, that's a good one! procs uses minus in exactly the way we would, so we can learn from them.

One annoying limitation is that minus doesn't implement any sort of in-program help.

ilyagr avatar Feb 11 '24 02:02 ilyagr

Closing in favor of #3024 and anything else that will come from that direction of a solution instead of special casing less

benbrittain avatar Feb 11 '24 20:02 benbrittain