🏠 Go home.

Gnus Subject Munging for Great Threading

Published on

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
                                        gnus-simplify-subject-re
                                        gnus-simplify-subject-fuzzy
                                        gnus-simplify-whitespace
                                        gnus-simplify-all-whitespace)
      rrix/gnus-simplify-phab-headers-list '("\\[Differential\\]"
                                             "\\[Maniphest\\]"
                                             "\\[Updated.*\\]"
                                             "\\[Request.*\\]"
                                             "\\[Commented On.*\\]"
                                             "\\[Commandeered.*\\]"
                                             "\\[Accepted.*\\]"
                                             "\\[Planned.*\\]"
                                             "\\[Closed.*\\]"
                                             "\\[Resigned.*\\]"
                                             "^\ [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)))
    transformed-subject))

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.

Respond to this note:

Ryan Rix is a privacy rights advocate and net-art wannabe. Reach him on the Fediverse as @rrix@cybre.space, twitter as @rrrrrrrix, via email to ryan@whatthefuck.computer or on Facebook or on Matrix as @rrix:whatthefuck.computer.