From 57c899814e74bdf9adec4c7d8211fc25d6b39697 Mon Sep 17 00:00:00 2001 From: "martin f. krafft" Date: Sat, 15 Jun 2013 21:02:40 +0200 Subject: [PATCH] New functionality: reusing messages --- .mutt/keybindings | 7 ++++--- .mutt/reuse-message | 30 ++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 3 deletions(-) create mode 100755 .mutt/reuse-message diff --git a/.mutt/keybindings b/.mutt/keybindings index 5a2109c..0fe8867 100644 --- a/.mutt/keybindings +++ b/.mutt/keybindings @@ -14,9 +14,6 @@ macro index p "" "do nothing" macro index S "=store" "save messages to store" macro pager S "=store" "save message to store" -macro index \er '=resubmit' "resubmit messages" -macro pager \er '=resubmit' "resubmit message" - macro index,pager E 'source "$my_confdir/supersede-header X-Tickle get-timestamp|"push \er' "schedule messages with tickler" macro index,pager \ex 'source "$my_confdir/remove-header X-Postponed|"' "release postponed messages" @@ -72,6 +69,10 @@ macro index,pager e 'set my_editor="$editor"set my_editor="$editor"source "$my_confdir/batch-subject-editor|"set editor="$my_editor"' "change message subject" +macro index,pager \er 'set my_editor="$editor"set editor="~/.mutt/reuse-message $my_editor"set editor="$my_editor"' "invoke normal editor to edit message" +macro index,pager \eg 'set my_editor="$editor"set editor="~/.mutt/reuse-message $my_editor"set editor="$my_editor"' "invoke normal editor to edit message" +macro index,pager \el 'set my_editor="$editor"set editor="~/.mutt/reuse-message $my_editor"set editor="$my_editor"' "invoke normal editor to edit message" + macro index "unset wait_key~/.mutt/mutt-notmuch --prompt search~/.cache/mutt_results" "search mail (using notmuch)" macro index "unset wait_key~/.mutt/mutt-notmuch thread~/.cache/mutt_resultsset wait_key" "search and reconstruct owning thread (using notmuch)" diff --git a/.mutt/reuse-message b/.mutt/reuse-message new file mode 100755 index 0000000..c833bd3 --- /dev/null +++ b/.mutt/reuse-message @@ -0,0 +1,30 @@ +#!/bin/sh +set -eu + +eval mailfile="\${$#}" +for i in "$@"; do + # strip last argument from editor, yuk + case "$i" in + ($mailfile) break;; + (*) editor="${editor:+$editor }$i";; + esac +done + +tmpfile=$(tempfile -p reuse) +cleanup() { rm -f "$tmpfile"; trap - 1 2 3 4 5 6 7 8 10 11 12 13 14 15; } +trap cleanup 1 2 3 4 5 6 7 8 10 11 12 13 14 15 + +formail -I Subject: < "$mailfile" | \ + formail -I In-Reply-To: | \ + sed -e '/^$/,/^-- /d' | \ + sed -e '/^Bcc:/aSubject: ' > "$tmpfile" +cat "$tmpfile" > "$mailfile" + +if [ -n "$editor" ]; then + eval exec "$editor" "$mailfile" +elif [ -n "$VISUAL" ]; then + eval exec "$VISUAL" "$mailfile" +elif [ -n "$EDITOR" ]; then + eval exec "$EDITOR" "$mailfile" +fi +exec /usr/bin/editor "$mailfile" -- 2.39.2