\(& SPLIT...): Process each SPLIT expression.
FIELD must match a complete field name. VALUE must match a complete
-word according to the fundamental mode syntax table. You can use .*
-in the regexps to match partial field names or words.
+word according to the `nnmail-split-fancy-syntax-table' syntax table.
+You can use .* in the regexps to match partial field names or words.
FIELD and VALUE can also be lisp symbols, in that case they are expanded
as specified in `nnmail-split-abbrev-alist'.
;;; Internal variables.
+(defvar nnmail-split-fancy-syntax-table
+ (copy-syntax-table (standard-syntax-table))
+ "Syntax table used by `nnmail-split-fancy'.")
+
\f
(defconst nnmail-version "nnmail 1.0"
(erase-buffer)
(while group-assoc
(setq group (pop group-assoc))
- (insert (format "%s %d %d y\n" (car group) (cdr (car (cdr group)) )
- (car (car (cdr group))))))
+ (insert (format "%s %d %d y\n" (car group) (cdadr group)
+ (caadr group))))
(unless (file-exists-p (file-name-directory file-name))
(make-directory (file-name-directory file-name) t))
(write-region 1 (point-max) (expand-file-name file-name) nil 'nomesg)
found)
(while (not found)
(if (re-search-forward delim nil t)
- (when (looking-at "[^ :]+:")
+ (when (or (looking-at "[^\n :]+ *:")
+ (looking-at delim)
+ (looking-at (concat ">" rmail-unix-mail-delimiter)))
(forward-line -1)
(setq found 'yes))
(setq found 'no)))
(goto-char (point-max))
(widen)
(setq head-end (point))
- ;; We try the Content-Length value.
+ ;; We try the Content-Length value. The idea: skip over the header
+ ;; separator, then check what happens content-length bytes into the
+ ;; message body. This should be either the end ot the buffer, the
+ ;; message separator or a blank line followed by the separator.
+ ;; The blank line should probably be deleted. If neither of the
+ ;; three is met, the content-length header is probably invalid.
(when content-length
(forward-line 1)
(setq skip (+ (point) content-length))
- (when (or (= skip (point-max))
- (and (< skip (point-max))
- (goto-char skip)
- (looking-at delim)))
- (setq end skip)))
+ (goto-char skip)
+ (cond ((or (= skip (point-max))
+ (= (1+ skip) (point-max)))
+ (setq end (point-max)))
+ ((looking-at delim)
+ (setq end skip))
+ ((looking-at
+ (concat "[ \t]*\n\\(" delim "\\)"))
+ (setq end (match-beginning 1)))
+ (t (setq end nil))))
(if end
(goto-char end)
;; No Content-Length, so we find the beginning of the next
nnmail-use-procmail)
(not nnmail-resplit-incoming))
(list (list group ""))
- nnmail-split-methods))
- start end do-search message-id)
+ nnmail-split-methods)))
(save-excursion
- ;; Open the message-id cache.
- (nnmail-cache-open)
;; Insert the incoming file.
(set-buffer (get-buffer-create " *nnmail incoming*"))
(buffer-disable-undo (current-buffer))
(erase-buffer)
(insert-file-contents incoming)
- (goto-char (point-min))
- (save-excursion (run-hooks 'nnmail-prepare-incoming-hook))
- ;; Handle both babyl, MMDF and unix mail formats, since movemail will
- ;; use the former when fetching from a mailbox, the latter when
- ;; fetches from a file.
- (cond ((or (looking-at "\^L")
- (looking-at "BABYL OPTIONS:"))
- (nnmail-process-babyl-mail-format func))
- ((looking-at "\^A\^A\^A\^A")
- (nnmail-process-mmdf-mail-format func))
- (t
- (nnmail-process-unix-mail-format func)))
- ;; Close the message-id cache.
- (nnmail-cache-close)
+ (unless (zerop (buffer-size))
+ (goto-char (point-min))
+ (save-excursion (run-hooks 'nnmail-prepare-incoming-hook))
+ ;; Handle both babyl, MMDF and unix mail formats, since movemail will
+ ;; use the former when fetching from a mailbox, the latter when
+ ;; fetches from a file.
+ (cond ((or (looking-at "\^L")
+ (looking-at "BABYL OPTIONS:"))
+ (nnmail-process-babyl-mail-format func))
+ ((looking-at "\^A\^A\^A\^A")
+ (nnmail-process-mmdf-mail-format func))
+ (t
+ (nnmail-process-unix-mail-format func))))
(if exit-func (funcall exit-func))
(kill-buffer (current-buffer)))))
;; If there is only just one group to put everything in, we
;; just return a list with just this one method in.
(setq group-art
- (list (cons (car (car methods))
- (funcall func (car (car methods))))))
+ (list (cons (caar methods) (funcall func (caar methods)))))
;; We do actual comparison.
(save-excursion
;; Find headers.
(when (and
(condition-case ()
(if (stringp (nth 1 method))
- (re-search-backward (car (cdr method)) nil t)
+ (re-search-backward (cadr method) nil t)
;; Function to say whether this is a match.
(funcall (nth 1 method) (car method)))
(error nil))
(progn (forward-line 1) (point))))
(insert (format "Xref: %s" (system-name)))
(while group-alist
- (insert (format " %s:%d" (car (car group-alist))
- (cdr (car group-alist))))
+ (insert (format " %s:%d" (caar group-alist) (cdar group-alist)))
(setq group-alist (cdr group-alist)))
(insert "\n"))))
(defun nnmail-split-fancy ()
"Fancy splitting method.
See the documentation for the variable `nnmail-split-fancy' for documentation."
- (nnmail-split-it nnmail-split-fancy))
+ (let ((syntab (syntax-table)))
+ (unwind-protect
+ (progn
+ (set-syntax-table nnmail-split-fancy-syntax-table)
+ (nnmail-split-it nnmail-split-fancy))
+ (set-syntax-table syntab))))
(defvar nnmail-split-cache nil)
;; Alist of split expressions their equivalent regexps.
(buffer-disable-undo (current-buffer))
(and (file-exists-p nnmail-message-id-cache-file)
(insert-file-contents nnmail-message-id-cache-file))
+ (set-buffer-modified-p nil)
(current-buffer))))
(defun nnmail-cache-close ()
nnmail-message-id-cache-file nil 'silent)
(set-buffer-modified-p nil)
(setq nnmail-cache-buffer nil)
- (kill-buffer (current-buffer)))))
+ ;;(kill-buffer (current-buffer))
+ )))
(defun nnmail-cache-insert (id)
(when nnmail-treat-duplicates
(beginning-of-line)
(insert "Original-"))
(beginning-of-line)
- (insert "Message-ID: " newid "\n")
- (insert "Gnus-Warning: This is a duplication of message "
- message-id "\n")
+ (insert
+ "Message-ID: " newid "\n"
+ "Gnus-Warning: This is a duplicate of message " message-id "\n")
(nnmail-cache-insert newid)
(funcall func)))
(t
(nnmail-activate method)
;; Allow the user to hook.
(run-hooks 'nnmail-pre-get-new-mail-hook)
+ ;; Open the message-id cache.
+ (nnmail-cache-open)
;; The we go through all the existing spool files and split the
;; mail from each.
(while spools
(funcall exit-func))
(run-hooks 'nnmail-read-incoming-hook)
(nnheader-message 3 "%s: Reading incoming mail...done" method))
+ ;; Close the message-id cache.
+ (nnmail-cache-close)
;; Allow the user to hook.
(run-hooks 'nnmail-post-get-new-mail-hook)
;; Delete all the temporary files.