-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mless: doesn't work on OpenBSD 7.6 due to lack of LESSOPEN #266
Comments
That might result in performance problems for large sequences. I've just gotten around it by piping a message with the preamble into |
One approach could be to drive less in a loop, and use exit codes to switch between files, only starting less with one mail rendered every time. |
Hrm, I'm assuming that this would have different keybindings than I looked at the source for So, 0 for success, 1 for error, and 2 for interrupt. Not a whole lot of wiggle room to switch between specific files. Unless there's something I'm missing? |
e.g. add Works on OpenBSD 7.6. |
Is something like this what you had in mind? diff --git a/mless b/mless
index ddead98..51bd361 100755
--- a/mless
+++ b/mless
@@ -85,10 +85,26 @@ elif [ -f "$HOME/.mblaze/mless" ]; then
elif [ -f "$HOME/.mless" ]; then
export LESSKEY="$HOME/.mless"
fi
+scan=0
while :; do
- LESSOPEN="|$0 --filter %s" \
- less -Ps"mless %f?m (message %i of %m).." -R \
- "+:e $(mscan -n .)$nl" //scan $(mscan -n :)
+ local cur=$(mscan -n .)
+ local total=$(mscan -n : | tail -1)
+
+ if [ $scan -ne 0 ]
+ then
+ cur="//scan"
+ local status="mless.."
+ else
+ local status="mless $cur (message $cur of $total).."
+ fi
+
+ {
+ case $cur in
+ [0-9]*) $0 --filter $cur;;
+ *) $0 --filter //scan;;
+ esac
+ } | less -Ps"$status" -R
+
case "$?" in
0|1) exit $?;;
36) # $ goto end
@@ -111,6 +127,21 @@ while :; do
72) # H toggle HTML mode
MLESS_HTML=$((1-$MLESS_HTML))
;;
+ 91) # [ prev file
+ case $cur in
+ 1) scan=1;;
+ *) mseq -C '.-1' 2>/dev/null;;
+ esac
+ ;;
+ 93) # ] next file
+ if [ $scan -eq 0 ]
+ then
+ mseq -C '.+1' 2>/dev/null
+ else
+ scan=0
+ mseq -C 1 2>/dev/null
+ fi
+ ;;
94) # ^ goto parent
mseq -C '.^' 2>/dev/null
;;
diff --git a/mlesskey.example b/mlesskey.example
index be82e1d..90d69af 100644
--- a/mlesskey.example
+++ b/mlesskey.example
@@ -4,8 +4,8 @@
# When using less >=590: copy this file to ~/.mlesskey
Q quit \1
:cq quit \1
-[ prev-file
-] next-file
+[ quit [
+] quit ]
{ noaction E1\n
} quit $
$ quit $
|
LESSOPEN support was removed in OpenBSD in openbsd/src@c74702f
I'm not sure how we can have something like mless without this feature... one would need to pre-render the whole sequence perhaps?
The text was updated successfully, but these errors were encountered: