* [PR PATCH] fixes leahneukirchen/mblaze#194
@ 2022-03-22 18:27 mbauhardt
2022-03-22 18:34 ` leahneukirchen
2022-03-23 8:10 ` mbauhardt
0 siblings, 2 replies; 3+ messages in thread
From: mbauhardt @ 2022-03-22 18:27 UTC (permalink / raw)
To: ml
[-- Attachment #1: Type: text/plain, Size: 742 bytes --]
There is a new pull request by mbauhardt against master on the mblaze repository
https://github.com/mbauhardt/mblaze 194
https://github.com/leahneukirchen/mblaze/pull/223
fixes leahneukirchen/mblaze#194
fixes leahneukirchen/mblaze#194
**Why**
Configure the number of lines which are shown on top of `mless` would be nice to have.
**How**
Introduce property `Scan-Lines` available in `$MBLAZE/profile` to configure the number of lines to scan on top of `mless`.
`mless` reads this property and using it. if not set the default value of `6` is used to not break the existing behaviour.
Also updating the man pages for mless and `mblaze-profile`.
A patch file from https://github.com/leahneukirchen/mblaze/pull/223.patch is attached
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-194-223.patch --]
[-- Type: text/x-diff, Size: 2162 bytes --]
From 917516465031fc14eaefc32fe4bfb884f152087a Mon Sep 17 00:00:00 2001
From: Marko Bauhardt <mb@datameer.com>
Date: Tue, 22 Mar 2022 19:17:24 +0100
Subject: [PATCH] fixes leahneukirchen/mblaze#194
---
man/mblaze-profile.5 | 3 +++
man/mless.1 | 3 +++
mless | 14 ++++++++------
3 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/man/mblaze-profile.5 b/man/mblaze-profile.5
index 65d1b3d..3eede3a 100644
--- a/man/mblaze-profile.5
+++ b/man/mblaze-profile.5
@@ -71,6 +71,9 @@ will be used as a default.
.It Li Scan\&-Format\&:
The default format string for
.Xr mscan 1 .
+.It Li Scan\&-Lines\&:
+The number of lines to scan when using
+.Xr mless 1 .
.It Li Sendmail\&:
The program that
.Xr mcom 1
diff --git a/man/mless.1 b/man/mless.1
index d446fdd..120136e 100644
--- a/man/mless.1
+++ b/man/mless.1
@@ -50,6 +50,9 @@ Additional keybindings loaded for convenience.
.It Pa ${MBLAZE:-$HOME/.mblaze}/mless , Pa $HOME/.mless
Additional compiled keybindings loaded for convenience.
(Only needed for less earlier than version 590.)
+.It Pa ${MBLAZE:-$HOME/.mblaze}/profile
+Number of lines/messages to scan which are shown on top.
+If not set, 6 lines are used as the default.
.El
.Sh EXIT STATUS
.Ex -std
diff --git a/mless b/mless
index ddead98..35ce47b 100755
--- a/mless
+++ b/mless
@@ -24,13 +24,15 @@ if [ "$1" = --filter ]; then
mseq -C "$2"
total=$(mscan -n -- -1)
+ linesToScan=$(mhdr -h Scan-Lines "$MBLAZE/profile")
+ linesToScan=${linesToScan:-6}
case $2 in
- 1) mscan .-0:.+5 ;;
- 2) mscan .-1:.+4 ;;
- $((total - 2))) mscan .-3:.+2 ;;
- $((total - 1))) mscan .-4:.+1 ;;
- $total) mscan .-5:.+0 ;;
- *) mscan .-2:.+3 ;;
+ 1) mscan .-0:.+$(expr $linesToScan - 1) ;;
+ 2) mscan .-1:.+$(expr $linesToScan - 2) ;;
+ $((total - 2))) mscan .-3:.+$(expr $linesToScan - 4) ;;
+ $((total - 1))) mscan .-4:.+$(expr $linesToScan - 5) ;;
+ $total) mscan .-5:.+$(expr $linesToScan - 6) ;;
+ *) mscan .-2:.+$(expr $linesToScan - 3) ;;
esac 2>/dev/null | colorscan
echo
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: fixes leahneukirchen/mblaze#194
2022-03-22 18:27 [PR PATCH] fixes leahneukirchen/mblaze#194 mbauhardt
@ 2022-03-22 18:34 ` leahneukirchen
2022-03-23 8:10 ` mbauhardt
1 sibling, 0 replies; 3+ messages in thread
From: leahneukirchen @ 2022-03-22 18:34 UTC (permalink / raw)
To: ml
[-- Attachment #1: Type: text/plain, Size: 348 bytes --]
New comment by leahneukirchen on mblaze repository
https://github.com/leahneukirchen/mblaze/pull/223#issuecomment-1075488709
Comment:
I don't think this will work, as we had the explicit cases exactly for 6 lines by default, you'd need to generalize the algorithm.
Also note that in POSIX sh you can use `$((math))` instead of `$(expr math)`.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: fixes leahneukirchen/mblaze#194
2022-03-22 18:27 [PR PATCH] fixes leahneukirchen/mblaze#194 mbauhardt
2022-03-22 18:34 ` leahneukirchen
@ 2022-03-23 8:10 ` mbauhardt
1 sibling, 0 replies; 3+ messages in thread
From: mbauhardt @ 2022-03-23 8:10 UTC (permalink / raw)
To: ml
[-- Attachment #1: Type: text/plain, Size: 543 bytes --]
New comment by mbauhardt on mblaze repository
https://github.com/leahneukirchen/mblaze/pull/223#issuecomment-1076060531
Comment:
> I don't think this will work, as we had the explicit cases exactly for 6 lines by default, you'd need to generalize the algorithm.
ah. ok. i see. you mean we have to do a loop around https://github.com/leahneukirchen/mblaze/pull/223/files#diff-0f549fd15ac39a405676bb080ab4f082f510f787923824ac807f07b45b86a8e3R30 ?
this make the thing a bit more complicated. i will take a closer look later this week.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-03-23 8:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-22 18:27 [PR PATCH] fixes leahneukirchen/mblaze#194 mbauhardt
2022-03-22 18:34 ` leahneukirchen
2022-03-23 8:10 ` mbauhardt
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).