From: Lars Ingebrigtsen Date: Sat, 13 Jul 2019 13:23:38 +0000 (+0200) Subject: Add a way to more conveniently log/debug nnmail splitting X-Git-Tag: emacs-27.0.90~1950 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=b2fd5fbfcc8efd1a5b5ec1e9b494d0a2f9fcf4e1;p=emacs.git Add a way to more conveniently log/debug nnmail splitting * doc/misc/gnus.texi (Fancy Mail Splitting): Mention it. * lisp/gnus/nnmail.el (nnmail-debug-splitting): New variable. * lisp/gnus/nnmail.el (nnmail-log-split): New function. (nnmail-split-it): Use it. --- diff --git a/doc/misc/gnus.texi b/doc/misc/gnus.texi index 5e41ff2e4c8..7c5bc3eee85 100644 --- a/doc/misc/gnus.texi +++ b/doc/misc/gnus.texi @@ -15594,6 +15594,9 @@ outgoing messages are written to an ``outgoing'' group, you could set Otherwise, answers to all your messages would end up in the ``outgoing'' group. +If @code{nnmail-debug-splitting} is non-@code{nil}, the mail splitting +code will log all splitting decisions to the @samp{*nnmail split*} buffer. + @node Group Mail Splitting @subsection Group Mail Splitting diff --git a/lisp/gnus/nnmail.el b/lisp/gnus/nnmail.el index ed3d5712708..0699e818123 100644 --- a/lisp/gnus/nnmail.el +++ b/lisp/gnus/nnmail.el @@ -566,6 +566,12 @@ using different case (i.e. mailing-list@domain vs Mailing-List@Domain)." :group 'nnmail :type 'boolean) +(defcustom nnmail-debug-splitting nil + "If non-nil, record mail splitting actions. +These will be logged to the \"*nnmail split*\" buffer." + :type 'boolean + :version "27.1") + ;;; Internal variables. (defvar nnmail-article-buffer " *nnmail incoming*" @@ -1359,14 +1365,12 @@ See the documentation for the variable `nnmail-split-fancy' for details." ;; A group name. Do the \& and \N subs into the string. ((stringp split) - (when nnmail-split-tracing - (push split nnmail-split-trace)) + (nnmail-log-split split) (list (nnmail-expand-newtext split t))) ;; Junk the message. ((eq split 'junk) - (when nnmail-split-tracing - (push "junk" nnmail-split-trace)) + (nnmail-log-split "junk") (list 'junk)) ;; Builtin & operation. @@ -1383,8 +1387,7 @@ See the documentation for the variable `nnmail-split-fancy' for details." ;; Builtin : operation. ((eq (car split) ':) - (when nnmail-split-tracing - (push split nnmail-split-trace)) + (nnmail-log-split split) (nnmail-split-it (save-excursion (eval (cdr split))))) ;; Builtin ! operation. @@ -1402,8 +1405,7 @@ See the documentation for the variable `nnmail-split-fancy' for details." (while (and (goto-char end-point) (re-search-backward (cdr cached-pair) nil t)) (setq match-data (match-data)) - (when nnmail-split-tracing - (push split nnmail-split-trace)) + (nnmail-log-split split) (let ((split-rest (cddr split)) (end (match-end 0)) ;; The searched regexp is \(\(FIELD\).*\)\(VALUE\). @@ -2052,6 +2054,17 @@ Doesn't change point." (and (nnmail-search-unix-mail-delim-backward) (not (search-forward "\n\n" pos t)))))) +(defun nnmail-log-split (split) + (when nnmail-split-tracing + (push split nnmail-split-trace)) + (when nnmail-debug-splitting + (with-current-buffer (get-buffer-create "*nnmail split*") + (goto-char (point-max)) + (insert (format-time-string "%FT%T") + " " + (format "%S" split) + "\n")))) + (run-hooks 'nnmail-load-hook) (provide 'nnmail)