Idiomdrottning’s homepage

Re: SV: Re: SV: Re: SV: Your misbehaved email

This is something for Emacs’ message-mode that I made years and years ago but forgot to publish. It’s just been working so well that I forgot about it until now.

When dealing with Scandinavian or Icelandic people they often have misbehaved email clients that add “SV:” to a subject even if there is already a “Re:”. And then if your own client is also misbehaved, it’ll add another Re back on there, resulting in a ridic subject with a long chain of alternating Re and SV.

Obviously the fault is with the Scandinavian clients for not being aware of basics of RFC 5322, which specifies Re:.

When used in a reply, the field body MAY start with the string “Re: “ (an abbreviation of the Latin “in re”, meaning “in the matter of”) followed by the contents of the “Subject:” field body of the original message. If this is done, only one instance of the literal string “Re:” ought to be used since use of other strings or more than one instance can lead to undesirable consequences.

Them localizing is fine, localization is a good thing, but they should then be aware of “Re:” and be responsible for cleaning up the chains. But OK. We have Lisp so let’s be the adult in the room.

Obvs for German, sub in AW instead of SV etc.

(defun svolternet ()
  (interactive)
  (save-excursion
   (goto-char (point-min))
   (while (save-excursion (re-search-forward "^subject:\\\( re:\\\| sv:\\\)\\\{2,\\\}" nil t))
          (save-excursion
           (goto-char (point-min))
           (while (re-search-forward "^subject:\\\( re:\\\| sv:\\\) re:" nil t)
                  (replace-match "Subject: Re:" nil nil)))
          (save-excursion
           (goto-char (point-min))
           (while (re-search-forward "^subject:\\\( re:\\\| sv:\\\) sv:" nil t)
                  (replace-match "Subject: SV:" nil nil))))))

(add-hook 'message-mode-hook
          (lambda () (add-hook 'first-change-hook 'svolternet nil 'make-it-local)))