dot/gnus.el: Make `<' and `>' be punctuation when splitting mail.
authorMark Wooding <mdw@distorted.org.uk>
Tue, 14 Apr 2020 17:24:32 +0000 (18:24 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Mon, 20 Apr 2020 12:23:49 +0000 (13:23 +0100)
Email addresses are commonly written between angle brackets in header
lines.  I sometimes want to be able to parse out an entire email
address, or at least a local-part, from a header, as part of a Gnus
split specifier.  But Gnus prepends a `.*' to the split regexp, so one
needs to take special precautions to start in the right place, typically
by using `\_<' to align to the start of a symbol.  But if `<' is a
symbol character, then this won't work.

Worse, Gnus typically also tries to align to a word boundary by sneaking
in `\<'.  But then we have `\<\_<', which rejects an email address
starting enclosed in `<' ... `>' altogether.

Fortunately, the syntax table used by Gnus while splitting email is
configurable, so we can override this silliness.

dot/gnus.el

index 1625542..8b19908 100644 (file)
 ;; bogus.
 (setq gnus-level-unsubscribed 6)
 
+;; Reconfigure the `nnmail-split-fancy' syntax table to be less mad.
+(setq nnmail-split-fancy-syntax-table
+      (let ((table (make-syntax-table)))
+
+       ;; This is from upstream.  I don't know what it's for.
+       (modify-syntax-entry ?% "." table)
+
+       ;; Email addresses are often wrapped in `<...>', so don't consider
+       ;; those to be part of the address.
+       (modify-syntax-entry ?< "(>" table)
+       (modify-syntax-entry ?> ")<" table)
+
+       ;; Done.
+       table))
+
 ;;;--------------------------------------------------------------------------
 ;;; Magic for sending mail the correct way.