Github messages for mblaze
 help / color / mirror / Atom feed
* [PR PATCH] contrib: add mco/mfw/mbn, a more interactive wrapper for mcom/mfwd/mbnc
@ 2022-03-29 10:52 mineeyescyou
  0 siblings, 0 replies; only message in thread
From: mineeyescyou @ 2022-03-29 10:52 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 920 bytes --]

There is a new pull request by mineeyescyou against master on the mblaze repository

https://github.com/mineeyescyou/mblaze master
https://github.com/leahneukirchen/mblaze/pull/225

contrib: add mco/mfw/mbn, a more interactive wrapper for mcom/mfwd/mbnc
This is a somewhat complicated (i.e. takes more than 5 minutes of which 4 are
for reading mans to write) script that does two things: allows aliases like in
some other mail clients, and prompts the user for addresses and subject before
launching mcom under one of its names.

There are a few reasons why I made it. Firstly, of course, to have aliases.
Secondly, to save typing when I am in interactive shell (rather than sending
mail via scripts etc.). Finally I had a problem of forgetting to specify some
important headers before that, and I doubt I am the only one. :)

A patch file from https://github.com/leahneukirchen/mblaze/pull/225.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-master-225.patch --]
[-- Type: text/x-diff, Size: 2880 bytes --]

From 1771a8d23bed76c9c636d07142af87de844d1d8b Mon Sep 17 00:00:00 2001
From: Alexander Arkhipov <scm_2022@mineeyes.cyou>
Date: Tue, 29 Mar 2022 13:18:48 +0300
Subject: [PATCH] contrib: add mco/mfw/mbn, a more interactive wrapper for
 mcom/mfwd/mbnc

---
 contrib/mco | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 66 insertions(+)
 create mode 100755 contrib/mco

diff --git a/contrib/mco b/contrib/mco
new file mode 100755
index 0000000..23e0763
--- /dev/null
+++ b/contrib/mco
@@ -0,0 +1,66 @@
+#!/bin/sh
+
+# mco, mfw and mbn are slightly more interactive variants of mcom(1), mfwd(1) 
+# and mbnc(1). There is no need for an equivalent of mrep(1) because it already 
+# inserts all the necessary headers. These scripts read aliases from 
+# ${MBLAZE:-$HOME/.mblaze}/aliases, which is similar in structure to profile. 
+# That is on the left side of the colon is an alias, and on the right its actual 
+# value. Note that *all* values passed to the "To" prompt are comma-separated 
+# with optional whitespace after the comma. That includes the optional "-cc" and 
+# "-bcc". "-resent-cc" and "-resent-bcc" are not recognised, instead if the 
+# script is called as mbn, -cc and -bcc are automatically converted to their 
+# -resent-* equivalents. Each time there may be only a single "-cc" and a single 
+# "-bcc" further ones are rejected. Should I state that the values the "To" 
+# prompt accepts prior to "-*cc" go to To, while the values after the respective 
+# options to Cc and Bcc?
+#
+# To use these scripts place mco somewhere in the $PATH and then symlink mbn and
+# mfw to it.
+
+ALIASES="${MBLAZE:-$HOME/.mlbaze}/aliases"
+SELF="${0##*/}"
+
+IFS='
+'
+printf %s 'From: '; read -r FROM
+printf %s 'To (comma-separated + one or less of each: -cc, -bcc): '; read -r TO
+[ "$SELF" = mco ] && { printf %s 'Subject: '; read -r SUBJECT; }
+
+set --
+[ "$SELF" != "mbn" ] && set -- "$@" "-from" || set -- "$@" "-resent-from"
+temp="$(mhdr -h "$(printf "$FROM")" "$ALIASES")"
+[ -n "$temp" ] && set -- "$@" "$temp" || set -- "$@" "$FROM"
+[ "$SELF" = "mco" ] && set -- "$@" "-subject" && set -- "$@" "$SUBJECT"
+
+IFS=,
+CC=
+BCC=
+[ "$SELF" != "mbn" ] && set -- "$@" "-to" || set -- "$@" "-resent-to"
+for i in $TO; do
+	# Forgive whitespace after comma.
+	i="$(printf %s "$i" | sed 's/^[[:blank:]]*//')"
+	if [ "$i" = "-cc" ]; then
+		if [ -z "$CC" ]; then
+			CC=1
+			[ "$SELF" != "mbn" ] && set -- "$@" "-cc" ||
+				set -- "$@" "-resent-cc"
+		fi
+	elif [ "$i" = "-bcc" ]; then
+		if [ -z "$BCC" ]; then
+			BCC=1
+			[ "$SELF" != "mbn" ] && set -- "$@" "-bcc" ||
+				set -- "$@" "-resent-bcc"
+		fi
+	else
+		temp="$(mhdr -h "$(printf "$i")" "$ALIASES")"
+		[ -n "$temp" ] && set -- "$@" "$temp" || set "$@" "$i"
+	fi
+done
+
+case "$SELF" in
+mco) CMD=mcom ;;
+mbn) CMD=mbnc ;;
+mfw) CMD=mfwd ;;
+*)   CMD=mcom ;;
+esac
+"$CMD" "$@"

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-03-29 10:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-29 10:52 [PR PATCH] contrib: add mco/mfw/mbn, a more interactive wrapper for mcom/mfwd/mbnc mineeyescyou

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).