From: pdmef Date: Mon, 14 Mar 2005 19:25:35 +0000 (+0000) Subject: Rocco Rutte: X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=commitdiff_plain;h=d54f22568520826c1bba146bf291637d019147a4 Rocco Rutte: implemented $strip_was and $strip_was_regex git-svn-id: svn://svn.berlios.de/mutt-ng/trunk@179 e385b8ad-14ed-0310-8656-cc95a2468c6d --- diff --git a/UPGRADING b/UPGRADING index 41a1117..fcf7009 100644 --- a/UPGRADING +++ b/UPGRADING @@ -14,6 +14,12 @@ Note: as development goes fast and as documentation is way behind it, this still likely is incomplete. Please report missing items to +2005-03-14 + + New Configuration Variables: + - $strip_was + - $strip_was_regex + 2005-03-10 New Configuration Command (based on CD's ifdef Patch): diff --git a/init.h b/init.h index 0512ca8..ce13643 100644 --- a/init.h +++ b/init.h @@ -3224,6 +3224,19 @@ struct option_t MuttVars[] = { ** personal mailbox where you might have several unrelated messages with ** the subject ``hi'' which will get grouped together. */ + { "strip_was", DT_BOOL, R_NONE, OPTSTRIPWAS, 0 }, + /** + ** .pp + ** When \fIset\fP, mutt-ng will remove the trailing part of the ``Subject'' + ** line which matches $$strip_was_regex when replying. + **/ + { "strip_was_regex", DT_RX, R_NONE, UL &StripWasRegexp, UL "\\([Ww][Aa][RrSs]: .*\\)[ ]*$" }, + /** + ** .pp + ** When non-empty and $$strip_was is \fIset\fP, mutt-ng will remove this + ** trailing part of the ``Subject'' line when replying if it won't be empty + ** afterwards. + **/ { "stuff_quoted", DT_BOOL, R_BOTH, OPTSTUFFQUOTED, 0 }, /* ** .pp diff --git a/mutt.h b/mutt.h index 53b2456..6a009a3 100644 --- a/mutt.h +++ b/mutt.h @@ -461,6 +461,7 @@ enum OPTSTATUSONTOP, OPTSTRICTMIME, OPTSTRICTTHREADS, + OPTSTRIPWAS, OPTSTUFFQUOTED, OPTSUSPEND, OPTTEXTFLOWED, diff --git a/mutt_regex.h b/mutt_regex.h index 0f37d9d..da047c5 100644 --- a/mutt_regex.h +++ b/mutt_regex.h @@ -51,5 +51,6 @@ WHERE REGEXP QuoteRegexp; WHERE REGEXP ReplyRegexp; WHERE REGEXP Smileys; WHERE REGEXP GecosMask; +WHERE REGEXP StripWasRegexp; #endif /* MUTT_REGEX_H */ diff --git a/send.c b/send.c index 8309545..c687492 100644 --- a/send.c +++ b/send.c @@ -227,6 +227,7 @@ static int edit_envelope (ENVELOPE *en, int flags) { char buf[HUGE_STRING]; LIST *uh = UserHeader; + regmatch_t pat_match[1]; #ifdef USE_NNTP if (option (OPTNEWSSEND)) @@ -291,7 +292,19 @@ static int edit_envelope (ENVELOPE *en, int flags) } } } - + + if ((flags & (SENDREPLY)) && option (OPTSTRIPWAS) && StripWasRegexp.rx && + regexec (StripWasRegexp.rx, buf, 1, pat_match, 0) == 0) { + unsigned int pos = pat_match->rm_so; + if (ascii_strncasecmp (buf, "re: ", pos) != 0) { + buf[pos] = '\0'; /* kill match */ + while (pos-- && buf[pos] == ' ') + buf[pos] = '\0'; /* remove trailing spaces */ + } else { + mutt_error (_("Ignoring $strip_was: Subject would be empty.")); + sleep (2); + } + } if (mutt_get_field ("Subject: ", buf, sizeof (buf), 0) != 0 || (!buf[0] && query_quadoption (OPT_SUBJECT, _("No subject, abort?")) != M_NO)) {