emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master b2fd5fb: Add a way to more conveniently log/debug n


From: Lars Ingebrigtsen
Subject: [Emacs-diffs] master b2fd5fb: Add a way to more conveniently log/debug nnmail splitting
Date: Sat, 13 Jul 2019 09:23:48 -0400 (EDT)

branch: master
commit b2fd5fbfcc8efd1a5b5ec1e9b494d0a2f9fcf4e1
Author: Lars Ingebrigtsen <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>

    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.
---
 doc/misc/gnus.texi  |  3 +++
 lisp/gnus/nnmail.el | 29 +++++++++++++++++++++--------
 2 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/doc/misc/gnus.texi b/doc/misc/gnus.texi
index 5e41ff2..7c5bc3e 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 ed3d571..0699e81 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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]