Computer :(


Gnus Subject Munging for Great Threading

At work, we use Phabricator for code review and task tracking. I use Gnus because of its awesome adaptive scoring, but it would choke on threading the Phabricator mails because they always include the Phabricator application (whether it's a code diff, or a task, or a paste or ...) and the action that changed on it, right in the subject.

Gnu's threading is pretty basic, but it's thankfully easy to change it with a wee-bit of elisp.

Start with injecting a custom substitution in to gnus-simplify-subject-functions; this is a list of functions that every subject line gets run through to filter down in to a string that can be matched for threading.

Our function takes a list of regular-expressions and runs each of them against the string, in series, and finally returns the string at the very end.

(setq gnus-simplify-subject-functions '(rrix/gnus-simplify-phab-headers
      rrix/gnus-simplify-phab-headers-list '("\\[Differential\\]"
                                             "\\[Commented On.*\\]"
                                             "^\ [0-9] "))

(defsubst rrix/gnus-simplify-phab-headers (subject)
  "Remove Phabricator headers from subject lines."
  (let ((transformed-subject subject))
    (dolist (regex rrix/gnus-simplify-phab-headers-list)
              (setq transformed-subject (replace-regexp-in-string regex "" transfsubj)))

Pretty simple stuff, it took me about an hour to find this stuff, and I feel like it may be useful for others going forward.