From: mineeyescyou <mineeyescyou@users.noreply.github.com>
To: ml@inbox.vuxu.org
Subject: [PR PATCH] contrib: add mco/mfw/mbn, a more interactive wrapper for mcom/mfwd/mbnc
Date: Tue, 29 Mar 2022 12:52:10 +0200 [thread overview]
Message-ID: <gh-mailinglist-notifications-fa6558a0-26e0-48f6-803f-f5a8af34f6a8-mblaze-225@inbox.vuxu.org> (raw)
[-- 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" "$@"
reply other threads:[~2022-03-29 10:52 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=gh-mailinglist-notifications-fa6558a0-26e0-48f6-803f-f5a8af34f6a8-mblaze-225@inbox.vuxu.org \
--to=mineeyescyou@users.noreply.github.com \
--cc=ml@inbox.vuxu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).