[Commits] compose_any NONE 1.1.2.1
holger at claws-mail.org
holger at claws-mail.org
Sun Aug 12 03:13:24 CEST 2012
Update of /home/claws-mail/plugins/python/examples/auto
In directory srv:/tmp/cvs-serv20672/examples/auto
Added Files:
Tag: gtk2
compose_any
Log Message:
2012-08-12 [holger] 0.10cvs4
* examples/README.examples
* examples/auto/compose_any
Add compose_any script to strip subject reply prefixes.
This has been suggested by Michael Gmelin and Slavko on
Users ML
--- NEW FILE: compose_any ---
import re
# Strip prefixes in subject
#
# When replying to a reply, Claws Mail strips the "Re: " reply
# marker of the subject line before prefixing with its own.
# Claws Mail also knows several localized variants from various
# mailers, such as "Aw: " (German Outlook), "Odp: " (Polish Outlook)
# and so on.
#
# However, it doesn't know all, and as of 3.8.1, adding new ones
# is not possible via a config option.
#
# This function is there to add new markers. It will also strip
# an already messed up original subject line, provided that all
# prefixes are defined below.
# So, for example, replying to a mail with
# Subject: R: Re: R: Re: Aw: R: Re: Old topic
# will result in
# Subject: Re: Old topic
#
# This is a slightly adapted version of a script provided
# by Michael Gmelin and Slavko on Claws Mail's users mailing list.
def strip_subject_prefixes():
# A list of prefixes to strip during reply. Add the ones that are
# interesting for you here.
prefixes = ["Re", "R", "Odp", "Aw"]
# Build up regex to match unwanted prefixes
prefix_string = "|".join(prefixes)
regex_str = r"^(Re|Fwd|Fw):( (%s):)+" % prefix_string
# Get a string with those prefixes stripped
new_subject = re.sub(regex_str, r"\1:", clawsmail.compose_window.get_subject())
# Set this string to be the new subject
clawsmail.compose_window.set_subject(new_subject)
# Normally, when the subject or body is modified, the mail gets marked
# as modified, wich results in a popup dialog when the compose window is
# just closed. We don't want to treat the automatic modification of the
# subject line from above to trigger such a popup, so we override the
# modification marker.
# Note that this affects only for the modifications done so far. As
# soon as the user starts to modify the mail manually, it will be
# set again.
clawsmail.compose_window.set_modified(False)
strip_subject_prefixes()
More information about the Commits
mailing list