Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 935729 - >=sys-apps/less-643 using dev-python/pygments-2.17.2: slow coloring
Summary: >=sys-apps/less-643 using dev-python/pygments-2.17.2: slow coloring
Status: UNCONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-07-08 05:39 UTC by Tom
Modified: 2024-11-20 15:45 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
new lesspipe script (lesspipe.tar.gz,16.96 KB, application/gzip)
2024-07-08 05:39 UTC, Tom
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tom 2024-07-08 05:39:59 UTC
Created attachment 897312 [details]
new lesspipe script

Hello,

since sys-apps/less-643-r[12] is using dev-python/pygments-2.17.2 for color
output, viewing files without a suffix needs up to a second before they are
displayed, but colors would be nice...

Just try
        less /usr/share/misc/magic/*
and walk through the list of files using :n and :p

While having a look at /usr/bin/lesspipe, I've decided to re-write most parts
of this script, in order to:
- fix the problem with slow execution,
- support many more suffixes, not only for colorization,
- fully handle compressed files.

I've tried to find some nice looking colors, but they aren't as nice as
those used by vim...

The new lesspipe script is heavily commented, so please RTFS.
All my added comments are marked with (ThMO) in order to distinguish them from
the original comments.

Notice: I'm working on a 80x25 terminal console, therefore my lines do not
exceed 80 columns - furthermore I never use tabs at the beginning of a line,
for obvious reasons.

So please execute  :se ts=2  inside vim for proper indentation.
If you're willing to accept my changes, please feel free to:
- re-indent as you like it,
- remove comments at your will.

THX for listening so far.

CU Tom
Comment 1 Pacho Ramos gentoo-dev 2024-11-08 18:45:43 UTC
Hi Tom

Thanks a lot for the updated script.

I think it would be much better for us to try to split the changes in different commits; maybe using github for that would be easier, as that would also allow easier reviewing of them.
https://github.com/gentoo/gentoo/pulls

From what I have seen:
- I would drop the vim headers and try to keep the indentation as it was.
- Regarding the credits, the commits will contain them; maybe like that, we wouldn't need to specify it directly on the header of the file 🤔
- "reason" section could be dropped from the script and be used for each relevant commit.
- Probably, one commit per change as reported in "short overall changes" would fit nice.
- Regarding "file -b" usage, either we will need to RDEPEND on sys-apps/file when lesspipe is installed, if a fallback should be added too.
- The script should allow to configure the used color (maybe via a ENV flag in line with LESSCOLOR flag.
Comment 2 Tom 2024-11-20 15:45:49 UTC
Hi Pacho,

(In reply to Pacho Ramos from comment #1)
> I think it would be much better for us to try to split the changes in
> different commits; maybe using github for that would be easier, as that
> would also allow easier reviewing of them.

you will surely know best, how to organize the sources...

> From what I have seen:
> - I would drop the vim headers and try to keep the indentation as it was.

Just indent as you prefer it.

> - Regarding the credits, the commits will contain them; maybe like that, we
> wouldn't need to specify it directly on the header of the file 🤔
> - "reason" section could be dropped from the script and be used for each
> relevant commit.
> - Probably, one commit per change as reported in "short overall changes"
> would fit nice.

I've added a lot of comments in order to make it more obvious, what has changed and why.
Almost all comments aren't needed - so remove them, thereby speeding up parsing time by bash. ;)

> - Regarding "file -b" usage, either we will need to RDEPEND on sys-apps/file
> when lesspipe is installed, if a fallback should be added too.

Both sys-apps/file and sys-apps/sed are needed - so a dependancy will be neccessary.

> - The script should allow to configure the used color (maybe via a ENV flag
> in line with LESSCOLOR flag.

This could be called LESSCOLORIZERTERM, since the type of terminal does select the colours:
+ "-f terminal256"          (my preference)
+ "-f terminal -O bg=dark"  (alternative)
+ "-f terminal"             (for those using a light background)

The variable optlex would then be setup as follows:
  optlex="-s -f ${LESSCOLORIZERTERM:-terminal256} -l"

CU Tom