3 # Strip prefixes in subject
5 # When replying to a reply, Claws Mail strips the "Re: " reply
6 # marker of the subject line before prefixing with its own.
7 # Claws Mail also knows several localized variants from various
8 # mailers, such as "Aw: " (German Outlook), "Odp: " (Polish Outlook)
11 # However, it doesn't know all, and as of 3.8.1, adding new ones
12 # is not possible via a config option.
14 # This function is there to add new markers. It will also strip
15 # an already messed up original subject line, provided that all
16 # prefixes are defined below.
17 # So, for example, replying to a mail with
18 # Subject: R: Re: R: Re: Aw: R: Re: Old topic
20 # Subject: Re: Old topic
22 # This is a slightly adapted version of a script provided
23 # by Michael Gmelin and Slavko on Claws Mail's users mailing list.
24 def strip_subject_prefixes():
25 # A list of prefixes to strip during reply. Add the ones that are
26 # interesting for you here.
27 prefixes = ["Re", "R", "Odp", "Aw"]
29 # Build up regex to match unwanted prefixes
30 prefix_string = "|".join(prefixes)
31 regex_str = r"^(Re|Fwd|Fw):( (%s):)+" % prefix_string
33 # Get a string with those prefixes stripped
34 new_subject = re.sub(regex_str, r"\1:", clawsmail.compose_window.get_subject())
36 # Set this string to be the new subject
37 clawsmail.compose_window.set_subject(new_subject)
39 # Normally, when the subject or body is modified, the mail gets marked
40 # as modified, wich results in a popup dialog when the compose window is
41 # just closed. We don't want to treat the automatic modification of the
42 # subject line from above to trigger such a popup, so we override the
43 # modification marker.
44 # Note that this affects only for the modifications done so far. As
45 # soon as the user starts to modify the mail manually, it will be
47 clawsmail.compose_window.set_modified(False)
50 strip_subject_prefixes()