about summary refs log tree commit diff
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2016-07-28 23:46:02 +0200
committerChristian Neukirchen <chneukirchen@gmail.com>2016-07-28 23:46:02 +0200
commit803665b9b2fbd4b131758ebefcb1eb77aa46d00b (patch)
treea1d1b6edbc7ff737bd85f9d0d6eae5b22074b128
parent430bb0d74c9157cdbd1e8ca5619b5c8241ec7fad (diff)
downloadmblaze-803665b9b2fbd4b131758ebefcb1eb77aa46d00b.tar.gz
mblaze-803665b9b2fbd4b131758ebefcb1eb77aa46d00b.tar.xz
mblaze-803665b9b2fbd4b131758ebefcb1eb77aa46d00b.zip
mless: experimental shortcuts
Compile mlesskey.example into ~/.mless to use them.
-rwxr-xr-xmless20
-rw-r--r--mlesskey.example11
2 files changed, 29 insertions, 2 deletions
diff --git a/mless b/mless
index 03f41a1..db0a728 100755
--- a/mless
+++ b/mless
@@ -71,5 +71,21 @@ fi
 
 nl="
 "
-LESSOPEN="|$0 --filter %s" exec less -Ps"mless %f?m (message %i of %m).." -R \
-	"+:e $(mseq -n .)$nl" //scan $(mseq -n :)
+while :; do
+	[ -f $HOME/.mless ] && export LESSKEY=$HOME/.mless
+	LESSOPEN="|$0 --filter %s" \
+		less -Ps"mless %f?m (message %i of %m).." -R \
+			"+:e $(mseq -n .)$nl" //scan $(mseq -n :)
+	case "$?" in
+	0|1) exit $?;;
+	78) # N go to next unsen message
+		mseq -C "$(mseq -r .: |
+			awk -F':2,' '$1 !~ /^</ && $2 !~ /S/ { print; exit }')";;
+	107) # k next thread
+		mseq -C "$(mseq .+1: | grep -m1 '^[^ <]')";;
+	100) # d mark read
+		mflag -S .
+		mseq -f | mseq -S
+		mseq -C +
+	esac
+done
diff --git a/mlesskey.example b/mlesskey.example
new file mode 100644
index 0000000..bfb08b6
--- /dev/null
+++ b/mlesskey.example
@@ -0,0 +1,11 @@
+# mless(1) keybindings
+# to update: lesskey -o ~/.mless ~/.mlesskey
+Q quit \1
+:cq quit \1
+[ prev-file
+] next-file
+S noaction E//scan\n
+` noaction E\#\n
+N quit N
+k quit k
+d quit d