From d215fb8c4bb24685149e374ced9ab2fa5c2fd21e Mon Sep 17 00:00:00 2001 From: "martin f. krafft" Date: Wed, 21 May 2008 14:19:31 +0200 Subject: [PATCH 1/1] add ability to change message subjects --- .mutt/batch-subject-editor | 25 +++++++++++++++++++++++++ .mutt/keybindings | 4 +++- 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100755 .mutt/batch-subject-editor diff --git a/.mutt/batch-subject-editor b/.mutt/batch-subject-editor new file mode 100755 index 0000000..ad12bef --- /dev/null +++ b/.mutt/batch-subject-editor @@ -0,0 +1,25 @@ +#!/bin/sh +# +# batch-subject-editor - helper script to change subject lines with mutt +# +# Based on an idea by David Champion +# +# Copyright © 2008 martin f. krafft +# Released under the terms of the Artistic Licence 2.0 +# +set -eu + +printf 'Enter new subject: ' >/dev/tty +read subj &2 + exit 1 +fi + +RE_REPLY='(re([[(]?[[:digit:]]+[)]]?)?|aw|antwort):[[:space:]]*' +RE_SUBJ_PREFIX="^Subject:[[:space:]]*(${RE_REPLY})?" +RE_SUBJ='.*' +EDITOR="sed -i -re \"s,(${RE_SUBJ_PREFIX})${RE_SUBJ},\\\1$subj,i\"" + +printf "set editor='${EDITOR} %s'\n" diff --git a/.mutt/keybindings b/.mutt/keybindings index 35a1d59..758e971 100644 --- a/.mutt/keybindings +++ b/.mutt/keybindings @@ -46,6 +46,8 @@ macro index F '~L ' "search for correspondents" #TODO this is a hack until switch-profile does not readd headers. macro compose e ':set my_editor="$editor":set editor=sensible-editor:set editor="$my_editor"' "invoke normal editor to edit message" -macro index,pager e ':set my_editor="$editor":set editor=sensible-editor:set editor="$my_editor"' "invoke normal editor to edit message" +macro index,pager e ':set my_editor="$editor":set editor=sensible-editor:set editor="$my_editor"' "invoke normal editor to edit message" + +macro index,pager \ej ':set my_editor="$editor":source "$my_confdir/batch-subject-editor|":set editor="$my_editor"' "change message subject" # vim:sw=12:noet:sts=12:ts=12:ft=muttrc -- 2.39.5