Allow nnmail-split-methods to use the fancy splitting syntax directly.
authorLars Magne Ingebrigtsen <larsi@quimbies.gnus.org>
Fri, 1 Oct 2010 19:12:26 +0000 (21:12 +0200)
committerLars Magne Ingebrigtsen <larsi@quimbies.gnus.org>
Fri, 1 Oct 2010 19:12:26 +0000 (21:12 +0200)
lisp/ChangeLog
lisp/nnmail.el
texi/ChangeLog
texi/gnus.texi

index 098cd07..f7b4c6b 100644 (file)
@@ -1,5 +1,8 @@
 2010-10-01  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
+       * nnmail.el (nnmail-article-group): Allow using the fancy split method
+       directly.
+
        * nnimap.el (nnimap-request-group): Low higher than high to signal no
        messages in empty groups.
 
index 23cb604..3669864 100644 (file)
@@ -104,7 +104,9 @@ mail belongs in that group.
 
 The last element should always have \"\" as the regexp.
 
-This variable can also have a function as its value."
+This variable can also have a function as its value, and it can
+also have a fancy split method as its value.  See
+`nnmail-split-fancy' for an explanation of that syntax."
   :group 'nnmail-split
   :type '(choice (repeat :tag "Alist" (group (string :tag "Name")
                                             (choice regexp function)))
@@ -1145,21 +1147,33 @@ FUNC will be called with the group name to determine the article number."
        (run-hooks 'nnmail-split-hook)
        (when (setq nnmail-split-tracing trace)
          (setq nnmail-split-trace nil))
-       (if (and (symbolp nnmail-split-methods)
-                (fboundp nnmail-split-methods))
-           (let ((split
-                  (condition-case error-info
-                      ;; `nnmail-split-methods' is a function, so we
-                      ;; just call this function here and use the
-                      ;; result.
-                      (or (funcall nnmail-split-methods)
-                          (and (not nnmail-inhibit-default-split-group)
-                               '("bogus")))
-                    (error
-                     (nnheader-message
-                      5 "Error in `nnmail-split-methods'; using `bogus' mail group: %S" error-info)
-                     (sit-for 1)
-                     '("bogus")))))
+       (if (or (and (symbolp nnmail-split-methods)
+                    (fboundp nnmail-split-methods))
+               (and (listp ruleset)
+                    ;; Not a regular split method, so it has to be a
+                    ;; fancy one.
+                    (not (let ((top-element (car-safe ruleset)))
+                           (and (= 2 (length top-element))
+                                (stringp (nth 0 top-element))
+                                (stringp (nth 1 top-element)))))))
+           (let* ((method-function
+                   (if (and (symbolp nnmail-split-methods)
+                            (fboundp nnmail-split-methods))
+                       nnmail-split-methods
+                     'nnmail-split-fancy))
+                  (split
+                   (condition-case error-info
+                       ;; `nnmail-split-methods' is a function, so we
+                       ;; just call this function here and use the
+                       ;; result.
+                       (or (funcall method-function)
+                           (and (not nnmail-inhibit-default-split-group)
+                                '("bogus")))
+                     (error
+                      (nnheader-message
+                       5 "Error in `nnmail-split-methods'; using `bogus' mail group: %S" error-info)
+                      (sit-for 1)
+                      '("bogus")))))
              (setq split (mm-delete-duplicates split))
              ;; The article may be "cross-posted" to `junk'.  What
              ;; to do?  Just remove the `junk' spec.  Don't really
index 2b99dce..9772e4f 100644 (file)
@@ -1,3 +1,8 @@
+2010-10-01  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+       * gnus.texi (Splitting Mail): Mention the new fancy splitting
+       function.
+
 2010-09-30  Teodor Zlatanov  <tzz@lifelogs.com>
 
        * gnus.texi (Spam Package Configuration Examples, SpamOracle): Remove
index b2f70f6..564996c 100644 (file)
@@ -15102,6 +15102,9 @@ arguments in a buffer narrowed to the headers of an incoming mail
 message.  The function should return a list of group names that it
 thinks should carry this mail message.
 
+This variable can also be a fancy split method.  See @xref{Fancy Mail
+Splitting} for the syntax.
+
 Note that the mail back ends are free to maul the poor, innocent,
 incoming headers all they want to.  They all add @code{Lines} headers;
 some add @code{X-Gnus-Group} headers; most rename the Unix mbox