;;; nnmail.el --- mail support functions for the Gnus mail backends
-;; Copyright (C) 1995-2011 Free Software Foundation, Inc.
+;; Copyright (C) 1995-2015 Free Software Foundation, Inc.
;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
;; Keywords: news, mail
;;; Code:
-;; For Emacs <22.2 and XEmacs.
-(eval-and-compile
- (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
-
(eval-when-compile (require 'cl))
(require 'gnus) ; for macro gnus-kill-buffer, at least
(autoload 'gnus-add-buffer "gnus")
(autoload 'gnus-kill-buffer "gnus")
+(autoload 'mail-send-and-exit "sendmail" nil t)
(defgroup nnmail nil
"Reading mail with Gnus."
else, you could do something like this:
(setq nnmail-split-methods
- '((\"mail.4ad\" \"From:.*4ad\")
+ \\='((\"mail.4ad\" \"From:.*4ad\")
(\"mail.junk\" \"From:.*Lars\\\\|Subject:.*buy\")
(\"mail.misc\" \"\")))
many days an article can be stored before it is considered \"old\".
It can also return the values `never' and `immediate'.
-Eg.:
+E.g.:
\(setq nnmail-expiry-wait-function
(lambda (newsgroup)
(cond ((string-match \"private\" newsgroup) 31)
((string-match \"junk\" newsgroup) 1)
- ((string-match \"important\" newsgroup) 'never)
+ ((string-match \"important\" newsgroup) \\='never)
(t 7))))"
:group 'nnmail-expire
:type '(choice (const :tag "nnmail-expiry-wait" nil)
Example:
\(setq nnmail-fancy-expiry-targets
- '((to-from \"boss\" \"nnfolder:Work\")
+ \\='((to-from \"boss\" \"nnfolder:Work\")
(\"Subject\" \"IMPORTANT\" \"nnfolder:IMPORTANT.%Y.%b\")
(\"from\" \".*\" \"nnfolder:Archive-%Y\")))
emptied, and can be used to call any mail box programs you have
running (\"xwatch\", etc.)
-Eg.
+E.g.:
-\(add-hook 'nnmail-read-incoming-hook
+\(add-hook \\='nnmail-read-incoming-hook
(lambda ()
(call-process \"/local/bin/mailsend\" nil nil nil
\"read\"
If you use `display-time', you could use something like this:
-\(add-hook 'nnmail-read-incoming-hook
+\(add-hook \\='nnmail-read-incoming-hook
(lambda ()
;; Update the displayed time, since that will clear out
;; the flag that says you have mail.
- (when (eq (process-status \"display-time\") 'run)
+ (when (eq (process-status \"display-time\") \\='run)
(display-time-filter display-time-process \"\"))))"
:group 'nnmail-prepare
:type 'hook)
(number :tag "count")))
(define-widget 'nnmail-lazy 'default
- "Base widget for recursive datastructures.
+ "Base widget for recursive data structures.
This is copy of the `lazy' widget in Emacs 22.1 provided for compatibility."
:format "%{%t%}: %v"
junk: Mail will be deleted. Use with care! Do not submerge in water!
Example:
(setq nnmail-split-fancy
- '(| (\"Subject\" \"MAKE MONEY FAST\" junk)
+ \\='(| (\"Subject\" \"MAKE MONEY FAST\" junk)
...other.rules.omitted...))
FIELD must match a complete field name. VALUE must match a complete
Example:
-\(setq nnmail-split-methods 'nnmail-split-fancy
+\(setq nnmail-split-methods \\='nnmail-split-fancy
nnmail-split-fancy
;; Messages from the mailer daemon are not crossposted to any of
;; the ordinary groups. Warnings are put in a separate group
;; from real errors.
- '(| (\"from\" mail (| (\"subject\" \"warn.*\" \"mail.warning\")
+ \\='(| (\"from\" mail (| (\"subject\" \"warn.*\" \"mail.warning\")
\"mail.misc\"))
;; Non-error messages are crossposted to all relevant
;; groups, but we don't crosspost between the group for the
(const warn)
(const delete)))
-(defcustom nnmail-extra-headers '(To Newsgroups)
- "*Extra headers to parse."
- :version "21.1"
+(defcustom nnmail-extra-headers '(To Newsgroups Cc)
+ "Extra headers to parse.
+In addition to the standard headers, these extra headers will be
+included in NOV headers (and the like) when backends parse headers."
+ :version "24.3"
:group 'nnmail
:type '(repeat symbol))
(setq nnmail-split-trace nil))
(if (or (and (symbolp nnmail-split-methods)
(fboundp nnmail-split-methods))
+ (not (consp (car-safe nnmail-split-methods)))
(and (listp nnmail-split-methods)
;; Not a regular split method, so it has to be a
;; fancy one.
;; This is the final group, which is used as a
;; catch-all.
(when (and (not group-art)
- (not nnmail-inhibit-default-split-group))
+ (or (equal "" (nth 1 method))
+ (not nnmail-inhibit-default-split-group)))
(setq group-art
(list (cons (car method)
(funcall func (car method))))))))
((stringp split)
(when nnmail-split-tracing
(push split nnmail-split-trace))
- (list (nnmail-expand-newtext split)))
+ (list (nnmail-expand-newtext split t)))
;; Junk the message.
((eq split 'junk)
;; Check the cache for the regexp for this split.
((setq cached-pair (assq split nnmail-split-cache))
(let (split-result
+ match-data
(end-point (point-max))
(value (nth 1 split)))
(if (symbolp value)
(setq value (cdr (assq value nnmail-split-abbrev-alist))))
(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))
(let ((split-rest (cddr split))
(setq split-rest (cddr split-rest))))
(when split-rest
(goto-char end)
- (let ((value (nth 1 split)))
- (if (symbolp value)
- (setq value (cdr (assq value nnmail-split-abbrev-alist))))
- ;; Someone might want to do a \N sub on this match, so get the
- ;; correct match positions.
- (re-search-backward value start-of-value))
+ ;; Someone might want to do a \N sub on this match, so
+ ;; restore the match data.
+ (set-match-data match-data)
(dolist (sp (nnmail-split-it (car split-rest)))
(unless (member sp split-result)
(push sp split-result))))))
;; on the same split, which will find it immediately in the cache.
(nnmail-split-it split))))))
-(defun nnmail-expand-newtext (newtext)
+(defun nnmail-expand-newtext (newtext &optional fancyp)
(let ((len (length newtext))
(pos 0)
c expanded beg N did-expand)
(if (= c ?\&)
(setq N 0)
(setq N (- c ?0)))
+ ;; We wrapped the searches in parentheses, so we have to
+ ;; add some parentheses here...
+ (when fancyp
+ (setq N (+ N 3)))
(when (match-beginning N)
(push (if nnmail-split-lowercase-expanded
(downcase (buffer-substring (match-beginning N)
(i 0)
(new 0)
(total 0)
- incoming incomings source)
+ source)
(when (and (nnmail-get-value "%s-get-new-mail" method)
sources)
(while (setq source (pop sources))
;; and fetch the mail from each.
(while (setq source (pop fetching-sources))
(when (setq new
- (mail-source-fetch
- source
- (gnus-byte-compile
- `(lambda (file orig-file)
- (nnmail-split-incoming
- file ',(intern (format "%s-save-mail" method))
- ',spool-func
- (or in-group
- (if (equal file orig-file)
- nil
- (nnmail-get-split-group orig-file ',source)))
- ',(intern (format "%s-active-number" method)))))))
+ (condition-case cond
+ (mail-source-fetch
+ source
+ (gnus-byte-compile
+ `(lambda (file orig-file)
+ (nnmail-split-incoming
+ file ',(intern (format "%s-save-mail" method))
+ ',spool-func
+ (or in-group
+ (if (equal file orig-file)
+ nil
+ (nnmail-get-split-group orig-file
+ ',source)))
+ ',(intern (format "%s-active-number" method))))))
+ ((error quit)
+ (message "Mail source %s failed: %s" source cond)
+ 0)))
(incf total new)
(incf i)))
;; If we did indeed read any incoming spools, we save all info.
(when (functionp target)
(setq target (funcall target group)))
(unless (eq target 'delete)
- (when (or (gnus-request-group target)
+ (when (or (gnus-request-group target nil nil (gnus-get-info target))
(gnus-request-create-group target))
(let ((group-art (gnus-request-accept-article target nil nil t)))
(when (and (consp group-art)
((and (equal header 'to-from)
(or (string-match (cadr regexp-target-pair) from)
(and (string-match (cadr regexp-target-pair) to)
- (let ((rmail-dont-reply-to-names
- (message-dont-reply-to-names)))
- (equal (rmail-dont-reply-to from) "")))))
+ (let* ((mail-dont-reply-to-names
+ (message-dont-reply-to-names))
+ (rmail-dont-reply-to-names ; obsolete since 24.1
+ mail-dont-reply-to-names))
+ (equal (if (fboundp 'rmail-dont-reply-to)
+ (rmail-dont-reply-to from)
+ (mail-dont-reply-to from)) "")))))
(setq target (format-time-string (caddr regexp-target-pair) date)))
((and (not (equal header 'to-from))
(string-match (cadr regexp-target-pair)