diff options
| author | Lars Ingebrigtsen | 2019-07-13 15:23:38 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2019-07-13 15:23:38 +0200 |
| commit | b2fd5fbfcc8efd1a5b5ec1e9b494d0a2f9fcf4e1 (patch) | |
| tree | d42115cdffd0054d7747824a606ec5619aa77387 | |
| parent | 67e2116160bef8ad1cc8ee7c5f5a7bc70cb1a7fb (diff) | |
| download | emacs-b2fd5fbfcc8efd1a5b5ec1e9b494d0a2f9fcf4e1.tar.gz emacs-b2fd5fbfcc8efd1a5b5ec1e9b494d0a2f9fcf4e1.zip | |
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.
| -rw-r--r-- | doc/misc/gnus.texi | 3 | ||||
| -rw-r--r-- | 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 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 | |||
| 15594 | Otherwise, answers to all your messages would end up in the | 15594 | Otherwise, answers to all your messages would end up in the |
| 15595 | ``outgoing'' group. | 15595 | ``outgoing'' group. |
| 15596 | 15596 | ||
| 15597 | If @code{nnmail-debug-splitting} is non-@code{nil}, the mail splitting | ||
| 15598 | code will log all splitting decisions to the @samp{*nnmail split*} buffer. | ||
| 15599 | |||
| 15597 | 15600 | ||
| 15598 | @node Group Mail Splitting | 15601 | @node Group Mail Splitting |
| 15599 | @subsection Group Mail Splitting | 15602 | @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)." | |||
| 566 | :group 'nnmail | 566 | :group 'nnmail |
| 567 | :type 'boolean) | 567 | :type 'boolean) |
| 568 | 568 | ||
| 569 | (defcustom nnmail-debug-splitting nil | ||
| 570 | "If non-nil, record mail splitting actions. | ||
| 571 | These will be logged to the \"*nnmail split*\" buffer." | ||
| 572 | :type 'boolean | ||
| 573 | :version "27.1") | ||
| 574 | |||
| 569 | ;;; Internal variables. | 575 | ;;; Internal variables. |
| 570 | 576 | ||
| 571 | (defvar nnmail-article-buffer " *nnmail incoming*" | 577 | (defvar nnmail-article-buffer " *nnmail incoming*" |
| @@ -1359,14 +1365,12 @@ See the documentation for the variable `nnmail-split-fancy' for details." | |||
| 1359 | 1365 | ||
| 1360 | ;; A group name. Do the \& and \N subs into the string. | 1366 | ;; A group name. Do the \& and \N subs into the string. |
| 1361 | ((stringp split) | 1367 | ((stringp split) |
| 1362 | (when nnmail-split-tracing | 1368 | (nnmail-log-split split) |
| 1363 | (push split nnmail-split-trace)) | ||
| 1364 | (list (nnmail-expand-newtext split t))) | 1369 | (list (nnmail-expand-newtext split t))) |
| 1365 | 1370 | ||
| 1366 | ;; Junk the message. | 1371 | ;; Junk the message. |
| 1367 | ((eq split 'junk) | 1372 | ((eq split 'junk) |
| 1368 | (when nnmail-split-tracing | 1373 | (nnmail-log-split "junk") |
| 1369 | (push "junk" nnmail-split-trace)) | ||
| 1370 | (list 'junk)) | 1374 | (list 'junk)) |
| 1371 | 1375 | ||
| 1372 | ;; Builtin & operation. | 1376 | ;; Builtin & operation. |
| @@ -1383,8 +1387,7 @@ See the documentation for the variable `nnmail-split-fancy' for details." | |||
| 1383 | 1387 | ||
| 1384 | ;; Builtin : operation. | 1388 | ;; Builtin : operation. |
| 1385 | ((eq (car split) ':) | 1389 | ((eq (car split) ':) |
| 1386 | (when nnmail-split-tracing | 1390 | (nnmail-log-split split) |
| 1387 | (push split nnmail-split-trace)) | ||
| 1388 | (nnmail-split-it (save-excursion (eval (cdr split))))) | 1391 | (nnmail-split-it (save-excursion (eval (cdr split))))) |
| 1389 | 1392 | ||
| 1390 | ;; Builtin ! operation. | 1393 | ;; Builtin ! operation. |
| @@ -1402,8 +1405,7 @@ See the documentation for the variable `nnmail-split-fancy' for details." | |||
| 1402 | (while (and (goto-char end-point) | 1405 | (while (and (goto-char end-point) |
| 1403 | (re-search-backward (cdr cached-pair) nil t)) | 1406 | (re-search-backward (cdr cached-pair) nil t)) |
| 1404 | (setq match-data (match-data)) | 1407 | (setq match-data (match-data)) |
| 1405 | (when nnmail-split-tracing | 1408 | (nnmail-log-split split) |
| 1406 | (push split nnmail-split-trace)) | ||
| 1407 | (let ((split-rest (cddr split)) | 1409 | (let ((split-rest (cddr split)) |
| 1408 | (end (match-end 0)) | 1410 | (end (match-end 0)) |
| 1409 | ;; The searched regexp is \(\(FIELD\).*\)\(VALUE\). | 1411 | ;; The searched regexp is \(\(FIELD\).*\)\(VALUE\). |
| @@ -2052,6 +2054,17 @@ Doesn't change point." | |||
| 2052 | (and (nnmail-search-unix-mail-delim-backward) | 2054 | (and (nnmail-search-unix-mail-delim-backward) |
| 2053 | (not (search-forward "\n\n" pos t)))))) | 2055 | (not (search-forward "\n\n" pos t)))))) |
| 2054 | 2056 | ||
| 2057 | (defun nnmail-log-split (split) | ||
| 2058 | (when nnmail-split-tracing | ||
| 2059 | (push split nnmail-split-trace)) | ||
| 2060 | (when nnmail-debug-splitting | ||
| 2061 | (with-current-buffer (get-buffer-create "*nnmail split*") | ||
| 2062 | (goto-char (point-max)) | ||
| 2063 | (insert (format-time-string "%FT%T") | ||
| 2064 | " " | ||
| 2065 | (format "%S" split) | ||
| 2066 | "\n")))) | ||
| 2067 | |||
| 2055 | (run-hooks 'nnmail-load-hook) | 2068 | (run-hooks 'nnmail-load-hook) |
| 2056 | 2069 | ||
| 2057 | (provide 'nnmail) | 2070 | (provide 'nnmail) |