annotate lisp/gnus/mail-source.el @ 43655:1ae60187a39d

fixed parens in the last patch
author Sam Steingold <sds@gnu.org>
date Sun, 03 Mar 2002 16:09:28 +0000
parents fa370bd262ee
children 7782e54757bb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1 ;;; mail-source.el --- functions for fetching mail
43421
a949c187ce13 * mail-source.el (mail-source-fetch-directory): Run scripts.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 38413
diff changeset
2 ;; Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
3
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
5 ;; Keywords: news, mail
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
6
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
7 ;; This file is part of GNU Emacs.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
8
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
10 ;; it under the terms of the GNU General Public License as published by
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
11 ;; the Free Software Foundation; either version 2, or (at your option)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
12 ;; any later version.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
13
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
14 ;; GNU Emacs is distributed in the hope that it will be useful,
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
17 ;; GNU General Public License for more details.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
18
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
19 ;; You should have received a copy of the GNU General Public License
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
22 ;; Boston, MA 02111-1307, USA.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
23
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
24 ;;; Commentary:
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
25
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
26 ;;; Code:
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
27
32918
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
28 (eval-when-compile
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
29 (require 'cl)
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
30 (require 'imap)
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
31 (eval-when-compile (defvar display-time-mail-function)))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
32 (eval-and-compile
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
33 (autoload 'pop3-movemail "pop3")
32918
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
34 (autoload 'pop3-get-message-count "pop3")
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
35 (autoload 'nnheader-cancel-timer "nnheader"))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
36 (require 'format-spec)
32918
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
37 (require 'mm-util)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
38
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
39 (defgroup mail-source nil
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
40 "The mail-fetching library."
31764
54ae1def18cf Merge from Gnus trunk.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
41 :version "21.1"
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
42 :group 'gnus)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
43
32918
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
44 ;; Define these at compile time to avoid dragging in imap always.
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
45 (defconst mail-source-imap-authenticators
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
46 (eval-when-compile
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
47 (mapcar (lambda (a)
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
48 (list 'const (car a)))
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
49 imap-authenticator-alist)))
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
50 (defconst mail-source-imap-streams
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
51 (eval-when-compile
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
52 (mapcar (lambda (a)
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
53 (list 'const (car a)))
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
54 imap-stream-alist)))
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
55
32102
e5f46972a7c8 2000-10-03 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 31784
diff changeset
56 (defcustom mail-sources nil
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
57 "*Where the mail backends will look for incoming mail.
31764
54ae1def18cf Merge from Gnus trunk.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
58 This variable is a list of mail source specifiers.
54ae1def18cf Merge from Gnus trunk.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
59 See Info node `(gnus)Mail Source Specifiers'."
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
60 :group 'mail-source
31764
54ae1def18cf Merge from Gnus trunk.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
61 :type `(repeat
32918
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
62 (choice :format "%[Value Menu%] %v"
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
63 :value (file)
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
64 (cons :tag "Spool file"
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
65 (const :format "" file)
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
66 (checklist :tag "Options" :greedy t
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
67 (group :inline t
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
68 (const :format "" :value :path)
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
69 file)))
31764
54ae1def18cf Merge from Gnus trunk.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
70 (cons :tag "Several files in a directory"
32918
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
71 (const :format "" directory)
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
72 (checklist :tag "Options" :greedy t
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
73 (group :inline t
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
74 (const :format "" :value :path)
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
75 (directory :tag "Path"))
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
76 (group :inline t
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
77 (const :format "" :value :suffix)
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
78 (string :tag "Suffix"))
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
79 (group :inline t
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
80 (const :format "" :value :predicate)
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
81 (function :tag "Predicate"))
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
82 (group :inline t
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
83 (const :format "" :value :prescript)
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
84 (string :tag "Prescript"))
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
85 (group :inline t
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
86 (const :format "" :value :postscript)
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
87 (string :tag "Postscript"))
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
88 (group :inline t
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
89 (const :format "" :value :plugged)
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
90 (boolean :tag "Plugged"))))
31764
54ae1def18cf Merge from Gnus trunk.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
91 (cons :tag "POP3 server"
32918
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
92 (const :format "" pop)
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
93 (checklist :tag "Options" :greedy t
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
94 (group :inline t
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
95 (const :format "" :value :server)
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
96 (string :tag "Server"))
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
97 (group :inline t
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
98 (const :format "" :value :port)
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
99 (choice :tag "Port"
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
100 :value "pop3"
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
101 (number :format "%v")
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
102 (string :format "%v")))
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
103 (group :inline t
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
104 (const :format "" :value :user)
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
105 (string :tag "User"))
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
106 (group :inline t
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
107 (const :format "" :value :password)
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
108 (string :tag "Password"))
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
109 (group :inline t
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
110 (const :format "" :value :program)
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
111 (string :tag "Program"))
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
112 (group :inline t
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
113 (const :format "" :value :prescript)
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
114 (string :tag "Prescript"))
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
115 (group :inline t
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
116 (const :format "" :value :postscript)
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
117 (string :tag "Postscript"))
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
118 (group :inline t
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
119 (const :format "" :value :function)
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
120 (function :tag "Function"))
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
121 (group :inline t
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
122 (const :format ""
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
123 :value :authentication)
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
124 (choice :tag "Authentication"
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
125 :value apop
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
126 (const password)
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
127 (const apop)))
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
128 (group :inline t
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
129 (const :format "" :value :plugged)
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
130 (boolean :tag "Plugged"))))
31764
54ae1def18cf Merge from Gnus trunk.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
131 (cons :tag "Maildir (qmail, postfix...)"
32918
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
132 (const :format "" maildir)
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
133 (checklist :tag "Options" :greedy t
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
134 (group :inline t
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
135 (const :format "" :value :path)
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
136 (directory :tag "Path"))
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
137 (group :inline t
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
138 (const :format "" :value :plugged)
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
139 (boolean :tag "Plugged"))))
31764
54ae1def18cf Merge from Gnus trunk.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
140 (cons :tag "IMAP server"
32918
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
141 (const :format "" imap)
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
142 (checklist :tag "Options" :greedy t
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
143 (group :inline t
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
144 (const :format "" :value :server)
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
145 (string :tag "Server"))
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
146 (group :inline t
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
147 (const :format "" :value :port)
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
148 (choice :tag "Port"
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
149 :value 143
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
150 number string))
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
151 (group :inline t
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
152 (const :format "" :value :user)
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
153 (string :tag "User"))
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
154 (group :inline t
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
155 (const :format "" :value :password)
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
156 (string :tag "Password"))
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
157 (group :inline t
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
158 (const :format "" :value :stream)
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
159 (choice :tag "Stream"
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
160 :value network
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
161 ,@mail-source-imap-streams))
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
162 (group :inline t
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
163 (const :format ""
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
164 :value :authenticator)
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
165 (choice :tag "Authenticator"
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
166 :value login
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
167 ,@mail-source-imap-authenticators))
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
168 (group :inline t
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
169 (const :format "" :value :mailbox)
32961
5357dbf00515 2000-10-26 Simon Josefsson <sj@extundo.com>
Dave Love <fx@gnu.org>
parents: 32918
diff changeset
170 (string :tag "Mailbox"
5357dbf00515 2000-10-26 Simon Josefsson <sj@extundo.com>
Dave Love <fx@gnu.org>
parents: 32918
diff changeset
171 :value "INBOX"))
32918
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
172 (group :inline t
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
173 (const :format "" :value :predicate)
32961
5357dbf00515 2000-10-26 Simon Josefsson <sj@extundo.com>
Dave Love <fx@gnu.org>
parents: 32918
diff changeset
174 (string :tag "Predicate"
5357dbf00515 2000-10-26 Simon Josefsson <sj@extundo.com>
Dave Love <fx@gnu.org>
parents: 32918
diff changeset
175 :value "UNSEEN UNDELETED"))
32918
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
176 (group :inline t
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
177 (const :format "" :value :fetchflag)
32961
5357dbf00515 2000-10-26 Simon Josefsson <sj@extundo.com>
Dave Love <fx@gnu.org>
parents: 32918
diff changeset
178 (string :tag "Fetchflag"
5357dbf00515 2000-10-26 Simon Josefsson <sj@extundo.com>
Dave Love <fx@gnu.org>
parents: 32918
diff changeset
179 :value "\\Deleted"))
32918
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
180 (group :inline t
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
181 (const :format ""
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
182 :value :dontexpunge)
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
183 (boolean :tag "Dontexpunge"))
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
184 (group :inline t
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
185 (const :format "" :value :plugged)
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
186 (boolean :tag "Plugged"))))
31764
54ae1def18cf Merge from Gnus trunk.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
187 (cons :tag "Webmail server"
32918
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
188 (const :format "" webmail)
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
189 (checklist :tag "Options" :greedy t
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
190 (group :inline t
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
191 (const :format "" :value :subtype)
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
192 ;; Should be generated from
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
193 ;; `webmail-type-definition', but we
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
194 ;; can't require webmail without W3.
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
195 (choice :tag "Subtype"
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
196 :value hotmail
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
197 (const hotmail)
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
198 (const yahoo)
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
199 (const netaddress)
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
200 (const netscape)
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
201 (const my-deja)))
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
202 (group :inline t
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
203 (const :format "" :value :user)
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
204 (string :tag "User"))
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
205 (group :inline t
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
206 (const :format "" :value :password)
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
207 (string :tag "Password"))
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
208 (group :inline t
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
209 (const :format ""
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
210 :value :dontexpunge)
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
211 (boolean :tag "Dontexpunge"))
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
212 (group :inline t
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
213 (const :format "" :value :plugged)
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
214 (boolean :tag "Plugged")))))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
215
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
216 (defcustom mail-source-primary-source nil
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
217 "*Primary source for incoming mail.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
218 If non-nil, this maildrop will be checked periodically for new mail."
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
219 :group 'mail-source
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
220 :type 'sexp)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
221
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
222 (defcustom mail-source-crash-box "~/.emacs-mail-crash-box"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
223 "File where mail will be stored while processing it."
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
224 :group 'mail-source
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
225 :type 'file)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
226
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
227 (defcustom mail-source-directory "~/Mail/"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
228 "Directory where files (if any) will be stored."
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
229 :group 'mail-source
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
230 :type 'directory)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
231
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
232 (defcustom mail-source-default-file-modes 384
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
233 "Set the mode bits of all new mail files to this integer."
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
234 :group 'mail-source
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
235 :type 'integer)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
236
31784
33d474f4b866 (mail-source-delete-incoming): Set to t, assuming
Dave Love <fx@gnu.org>
parents: 31764
diff changeset
237 (defcustom mail-source-delete-incoming t
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
238 "*If non-nil, delete incoming files after handling."
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
239 :group 'mail-source
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
240 :type 'boolean)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
241
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
242 (defcustom mail-source-incoming-file-prefix "Incoming"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
243 "Prefix for file name for storing incoming mail"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
244 :group 'mail-source
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
245 :type 'string)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
246
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
247 (defcustom mail-source-report-new-mail-interval 5
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
248 "Interval in minutes between checks for new mail."
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
249 :group 'mail-source
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
250 :type 'number)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
251
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
252 (defcustom mail-source-idle-time-delay 5
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
253 "Number of idle seconds to wait before checking for new mail."
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
254 :group 'mail-source
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
255 :type 'number)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
256
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
257 ;;; Internal variables.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
258
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
259 (defvar mail-source-string ""
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
260 "A dynamically bound string that says what the current mail source is.")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
261
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
262 (defvar mail-source-new-mail-available nil
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
263 "Flag indicating when new mail is available.")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
264
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
265 (eval-and-compile
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
266 (defvar mail-source-common-keyword-map
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
267 '((:plugged))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
268 "Mapping from keywords to default values.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
269 Common keywords should be listed here.")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
270
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
271 (defvar mail-source-keyword-map
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
272 '((file
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
273 (:prescript)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
274 (:prescript-delay)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
275 (:postscript)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
276 (:path (or (getenv "MAIL")
32918
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
277 (expand-file-name (user-login-name) rmail-spool-directory))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
278 (directory
43422
fa370bd262ee Patched a wrong location.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 43421
diff changeset
279 (:prescript)
fa370bd262ee Patched a wrong location.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 43421
diff changeset
280 (:prescript-delay)
fa370bd262ee Patched a wrong location.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 43421
diff changeset
281 (:postscript)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
282 (:path)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
283 (:suffix ".spool")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
284 (:predicate identity))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
285 (pop
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
286 (:prescript)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
287 (:prescript-delay)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
288 (:postscript)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
289 (:server (getenv "MAILHOST"))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
290 (:port 110)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
291 (:user (or (user-login-name) (getenv "LOGNAME") (getenv "USER")))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
292 (:program)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
293 (:function)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
294 (:password)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
295 (:authentication password))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
296 (maildir
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
297 (:path (or (getenv "MAILDIR") "~/Maildir/"))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
298 (:subdirs ("new" "cur"))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
299 (:function))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
300 (imap
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
301 (:server (getenv "MAILHOST"))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
302 (:port)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
303 (:stream)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
304 (:authentication)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
305 (:user (or (user-login-name) (getenv "LOGNAME") (getenv "USER")))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
306 (:password)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
307 (:mailbox "INBOX")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
308 (:predicate "UNSEEN UNDELETED")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
309 (:fetchflag "\\Deleted")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
310 (:dontexpunge))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
311 (webmail
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
312 (:subtype hotmail)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
313 (:user (or (user-login-name) (getenv "LOGNAME") (getenv "USER")))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
314 (:password)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
315 (:dontexpunge)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
316 (:authentication password)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
317 "Mapping from keywords to default values.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
318 All keywords that can be used must be listed here."))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
319
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
320 (defvar mail-source-fetcher-alist
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
321 '((file mail-source-fetch-file)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
322 (directory mail-source-fetch-directory)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
323 (pop mail-source-fetch-pop)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
324 (maildir mail-source-fetch-maildir)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
325 (imap mail-source-fetch-imap)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
326 (webmail mail-source-fetch-webmail))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
327 "A mapping from source type to fetcher function.")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
328
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
329 (defvar mail-source-password-cache nil)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
330
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
331 (defvar mail-source-plugged t)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
332
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
333 ;;; Functions
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
334
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
335 (eval-and-compile
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
336 (defun mail-source-strip-keyword (keyword)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
337 "Strip the leading colon off the KEYWORD."
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
338 (intern (substring (symbol-name keyword) 1))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
339
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
340 (eval-and-compile
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
341 (defun mail-source-bind-1 (type)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
342 (let* ((defaults (cdr (assq type mail-source-keyword-map)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
343 default bind)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
344 (while (setq default (pop defaults))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
345 (push (list (mail-source-strip-keyword (car default))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
346 nil)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
347 bind))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
348 bind)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
349
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
350 (defmacro mail-source-bind (type-source &rest body)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
351 "Return a `let' form that binds all variables in source TYPE.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
352 TYPE-SOURCE is a list where the first element is the TYPE, and
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
353 the second variable is the SOURCE.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
354 At run time, the mail source specifier SOURCE will be inspected,
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
355 and the variables will be set according to it. Variables not
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
356 specified will be given default values.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
357
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
358 After this is done, BODY will be executed in the scope
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
359 of the `let' form.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
360
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
361 The variables bound and their default values are described by
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
362 the `mail-source-keyword-map' variable."
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
363 `(let ,(mail-source-bind-1 (car type-source))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
364 (mail-source-set-1 ,(cadr type-source))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
365 ,@body))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
366
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
367 (put 'mail-source-bind 'lisp-indent-function 1)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
368 (put 'mail-source-bind 'edebug-form-spec '(form body))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
369
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
370 (defun mail-source-set-1 (source)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
371 (let* ((type (pop source))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
372 (defaults (cdr (assq type mail-source-keyword-map)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
373 default value keyword)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
374 (while (setq default (pop defaults))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
375 (set (mail-source-strip-keyword (setq keyword (car default)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
376 (if (setq value (plist-get source keyword))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
377 (mail-source-value value)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
378 (mail-source-value (cadr default)))))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
379
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
380 (eval-and-compile
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
381 (defun mail-source-bind-common-1 ()
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
382 (let* ((defaults mail-source-common-keyword-map)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
383 default bind)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
384 (while (setq default (pop defaults))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
385 (push (list (mail-source-strip-keyword (car default))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
386 nil)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
387 bind))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
388 bind)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
389
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
390 (defun mail-source-set-common-1 (source)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
391 (let* ((type (pop source))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
392 (defaults mail-source-common-keyword-map)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
393 (defaults-1 (cdr (assq type mail-source-keyword-map)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
394 default value keyword)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
395 (while (setq default (pop defaults))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
396 (set (mail-source-strip-keyword (setq keyword (car default)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
397 (if (setq value (plist-get source keyword))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
398 (mail-source-value value)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
399 (if (setq value (assq keyword defaults-1))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
400 (mail-source-value (cadr value))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
401 (mail-source-value (cadr default))))))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
402
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
403 (defmacro mail-source-bind-common (source &rest body)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
404 "Return a `let' form that binds all common variables.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
405 See `mail-source-bind'."
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
406 `(let ,(mail-source-bind-common-1)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
407 (mail-source-set-common-1 source)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
408 ,@body))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
409
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
410 (put 'mail-source-bind-common 'lisp-indent-function 1)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
411 (put 'mail-source-bind-common 'edebug-form-spec '(form body))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
412
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
413 (defun mail-source-value (value)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
414 "Return the value of VALUE."
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
415 (cond
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
416 ;; String
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
417 ((stringp value)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
418 value)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
419 ;; Function
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
420 ((and (listp value)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
421 (functionp (car value)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
422 (eval value))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
423 ;; Just return the value.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
424 (t
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
425 value)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
426
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
427 (defun mail-source-fetch (source callback)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
428 "Fetch mail from SOURCE and call CALLBACK zero or more times.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
429 CALLBACK will be called with the name of the file where (some of)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
430 the mail from SOURCE is put.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
431 Return the number of files that were found."
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
432 (mail-source-bind-common source
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
433 (if (or mail-source-plugged plugged)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
434 (save-excursion
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
435 (let ((function (cadr (assq (car source) mail-source-fetcher-alist)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
436 (found 0))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
437 (unless function
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
438 (error "%S is an invalid mail source specification" source))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
439 ;; If there's anything in the crash box, we do it first.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
440 (when (file-exists-p mail-source-crash-box)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
441 (message "Processing mail from %s..." mail-source-crash-box)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
442 (setq found (mail-source-callback
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
443 callback mail-source-crash-box)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
444 (+ found
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
445 (condition-case err
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
446 (funcall function source callback)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
447 (error
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
448 (unless (yes-or-no-p
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
449 (format "Mail source error (%s). Continue? " err))
38413
a26d9b55abb6 Some fixes to follow coding conventions in files from Gnus.
Pavel Janík <Pavel@Janik.cz>
parents: 33342
diff changeset
450 (error "Cannot get new mail"))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
451 0))))))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
452
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
453 (defun mail-source-make-complex-temp-name (prefix)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
454 (let ((newname (make-temp-name prefix))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
455 (newprefix prefix))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
456 (while (file-exists-p newname)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
457 (setq newprefix (concat newprefix "x"))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
458 (setq newname (make-temp-name newprefix)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
459 newname))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
460
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
461 (defun mail-source-callback (callback info)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
462 "Call CALLBACK on the mail file, and then remove the mail file.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
463 Pass INFO on to CALLBACK."
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
464 (if (or (not (file-exists-p mail-source-crash-box))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
465 (zerop (nth 7 (file-attributes mail-source-crash-box))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
466 (progn
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
467 (when (file-exists-p mail-source-crash-box)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
468 (delete-file mail-source-crash-box))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
469 0)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
470 (prog1
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
471 (funcall callback mail-source-crash-box info)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
472 (when (file-exists-p mail-source-crash-box)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
473 ;; Delete or move the incoming mail out of the way.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
474 (if mail-source-delete-incoming
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
475 (delete-file mail-source-crash-box)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
476 (let ((incoming
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
477 (mail-source-make-complex-temp-name
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
478 (expand-file-name
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
479 mail-source-incoming-file-prefix
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
480 mail-source-directory))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
481 (unless (file-exists-p (file-name-directory incoming))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
482 (make-directory (file-name-directory incoming) t))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
483 (rename-file mail-source-crash-box incoming t)))))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
484
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
485 (defun mail-source-movemail (from to)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
486 "Move FROM to TO using movemail."
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
487 (if (not (file-writable-p to))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
488 (error "Can't write to crash box %s. Not moving mail" to)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
489 (let ((to (file-truename (expand-file-name to)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
490 errors result)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
491 (setq to (file-truename to)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
492 from (file-truename from))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
493 ;; Set TO if have not already done so, and rename or copy
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
494 ;; the file FROM to TO if and as appropriate.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
495 (cond
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
496 ((file-exists-p to)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
497 ;; The crash box exists already.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
498 t)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
499 ((not (file-exists-p from))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
500 ;; There is no inbox.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
501 (setq to nil))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
502 ((zerop (nth 7 (file-attributes from)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
503 ;; Empty file.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
504 (setq to nil))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
505 (t
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
506 ;; If getting from mail spool directory, use movemail to move
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
507 ;; rather than just renaming, so as to interlock with the
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
508 ;; mailer.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
509 (unwind-protect
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
510 (save-excursion
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
511 (setq errors (generate-new-buffer " *mail source loss*"))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
512 (let ((default-directory "/"))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
513 (setq result
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
514 (apply
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
515 'call-process
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
516 (append
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
517 (list
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
518 (expand-file-name "movemail" exec-directory)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
519 nil errors nil from to)))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
520 (when (file-exists-p to)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
521 (set-file-modes to mail-source-default-file-modes))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
522 (if (and (not (buffer-modified-p errors))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
523 (zerop result))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
524 ;; No output => movemail won.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
525 t
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
526 (set-buffer errors)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
527 ;; There may be a warning about older revisions. We
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
528 ;; ignore that.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
529 (goto-char (point-min))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
530 (if (search-forward "older revision" nil t)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
531 t
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
532 ;; Probably a real error.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
533 (subst-char-in-region (point-min) (point-max) ?\n ?\ )
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
534 (goto-char (point-max))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
535 (skip-chars-backward " \t")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
536 (delete-region (point) (point-max))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
537 (goto-char (point-min))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
538 (when (looking-at "movemail: ")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
539 (delete-region (point-min) (match-end 0)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
540 (unless (yes-or-no-p
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
541 (format "movemail: %s (%d return). Continue? "
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
542 (buffer-string) result))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
543 (error "%s" (buffer-string)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
544 (setq to nil)))))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
545 (when (and errors
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
546 (buffer-name errors))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
547 (kill-buffer errors))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
548 ;; Return whether we moved successfully or not.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
549 to)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
550
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
551 (defun mail-source-movemail-and-remove (from to)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
552 "Move FROM to TO using movemail, then remove FROM if empty."
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
553 (or (not (mail-source-movemail from to))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
554 (not (zerop (nth 7 (file-attributes from))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
555 (delete-file from)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
556
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
557 (defvar mail-source-read-passwd nil)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
558 (defun mail-source-read-passwd (prompt &rest args)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
559 "Read a password using PROMPT.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
560 If ARGS, PROMPT is used as an argument to `format'."
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
561 (let ((prompt
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
562 (if args
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
563 (apply 'format prompt args)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
564 prompt)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
565 (unless mail-source-read-passwd
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
566 (if (or (fboundp 'read-passwd) (load "passwd" t))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
567 (setq mail-source-read-passwd 'read-passwd)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
568 (unless (fboundp 'ange-ftp-read-passwd)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
569 (autoload 'ange-ftp-read-passwd "ange-ftp"))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
570 (setq mail-source-read-passwd 'ange-ftp-read-passwd)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
571 (funcall mail-source-read-passwd prompt)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
572
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
573 (defun mail-source-fetch-with-program (program)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
574 (zerop (call-process shell-file-name nil nil nil
31764
54ae1def18cf Merge from Gnus trunk.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
575 shell-command-switch program)))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
576
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
577 (defun mail-source-run-script (script spec &optional delay)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
578 (when script
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
579 (if (and (symbolp script) (fboundp script))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
580 (funcall script)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
581 (mail-source-call-script
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
582 (format-spec script spec))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
583 (when delay
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
584 (sleep-for delay)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
585
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
586 (defun mail-source-call-script (script)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
587 (let ((background nil))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
588 (when (string-match "& *$" script)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
589 (setq script (substring script 0 (match-beginning 0))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
590 background 0))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
591 (call-process shell-file-name nil background nil
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
592 shell-command-switch script)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
593
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
594 ;;;
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
595 ;;; Different fetchers
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
596 ;;;
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
597
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
598 (defun mail-source-fetch-file (source callback)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
599 "Fetcher for single-file sources."
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
600 (mail-source-bind (file source)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
601 (mail-source-run-script
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
602 prescript (format-spec-make ?t mail-source-crash-box)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
603 prescript-delay)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
604 (let ((mail-source-string (format "file:%s" path)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
605 (if (mail-source-movemail path mail-source-crash-box)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
606 (prog1
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
607 (mail-source-callback callback path)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
608 (mail-source-run-script
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
609 postscript (format-spec-make ?t mail-source-crash-box)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
610 0))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
611
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
612 (defun mail-source-fetch-directory (source callback)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
613 "Fetcher for directory sources."
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
614 (mail-source-bind (directory source)
43421
a949c187ce13 * mail-source.el (mail-source-fetch-directory): Run scripts.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 38413
diff changeset
615 (mail-source-run-script
a949c187ce13 * mail-source.el (mail-source-fetch-directory): Run scripts.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 38413
diff changeset
616 prescript (format-spec-make ?t path)
a949c187ce13 * mail-source.el (mail-source-fetch-directory): Run scripts.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 38413
diff changeset
617 prescript-delay)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
618 (let ((found 0)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
619 (mail-source-string (format "directory:%s" path)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
620 (dolist (file (directory-files
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
621 path t (concat (regexp-quote suffix) "$")))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
622 (when (and (file-regular-p file)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
623 (funcall predicate file)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
624 (mail-source-movemail file mail-source-crash-box))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
625 (incf found (mail-source-callback callback file))))
43421
a949c187ce13 * mail-source.el (mail-source-fetch-directory): Run scripts.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 38413
diff changeset
626 (mail-source-run-script
a949c187ce13 * mail-source.el (mail-source-fetch-directory): Run scripts.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 38413
diff changeset
627 postscript (format-spec-make ?t path))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
628 found)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
629
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
630 (defun mail-source-fetch-pop (source callback)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
631 "Fetcher for single-file sources."
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
632 (mail-source-bind (pop source)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
633 (mail-source-run-script
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
634 prescript
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
635 (format-spec-make ?p password ?t mail-source-crash-box
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
636 ?s server ?P port ?u user)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
637 prescript-delay)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
638 (let ((from (format "%s:%s:%s" server user port))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
639 (mail-source-string (format "pop:%s@%s" user server))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
640 result)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
641 (when (eq authentication 'password)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
642 (setq password
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
643 (or password
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
644 (cdr (assoc from mail-source-password-cache))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
645 (mail-source-read-passwd
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
646 (format "Password for %s at %s: " user server)))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
647 (when server
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
648 (setenv "MAILHOST" server))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
649 (setq result
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
650 (cond
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
651 (program
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
652 (mail-source-fetch-with-program
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
653 (format-spec
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
654 program
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
655 (format-spec-make ?p password ?t mail-source-crash-box
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
656 ?s server ?P port ?u user))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
657 (function
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
658 (funcall function mail-source-crash-box))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
659 ;; The default is to use pop3.el.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
660 (t
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
661 (let ((pop3-password password)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
662 (pop3-maildrop user)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
663 (pop3-mailhost server)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
664 (pop3-port port)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
665 (pop3-authentication-scheme
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
666 (if (eq authentication 'apop) 'apop 'pass)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
667 (save-excursion (pop3-movemail mail-source-crash-box))))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
668 (if result
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
669 (progn
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
670 (when (eq authentication 'password)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
671 (unless (assoc from mail-source-password-cache)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
672 (push (cons from password) mail-source-password-cache)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
673 (prog1
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
674 (mail-source-callback callback server)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
675 ;; Update display-time's mail flag, if relevant.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
676 (if (equal source mail-source-primary-source)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
677 (setq mail-source-new-mail-available nil))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
678 (mail-source-run-script
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
679 postscript
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
680 (format-spec-make ?p password ?t mail-source-crash-box
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
681 ?s server ?P port ?u user))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
682 ;; We nix out the password in case the error
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
683 ;; was because of a wrong password being given.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
684 (setq mail-source-password-cache
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
685 (delq (assoc from mail-source-password-cache)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
686 mail-source-password-cache))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
687 0))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
688
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
689 (defun mail-source-check-pop (source)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
690 "Check whether there is new mail."
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
691 (mail-source-bind (pop source)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
692 (let ((from (format "%s:%s:%s" server user port))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
693 (mail-source-string (format "pop:%s@%s" user server))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
694 result)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
695 (when (eq authentication 'password)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
696 (setq password
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
697 (or password
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
698 (cdr (assoc from mail-source-password-cache))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
699 (mail-source-read-passwd
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
700 (format "Password for %s at %s: " user server))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
701 (unless (assoc from mail-source-password-cache)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
702 (push (cons from password) mail-source-password-cache)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
703 (when server
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
704 (setenv "MAILHOST" server))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
705 (setq result
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
706 (cond
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
707 ;; No easy way to check whether mail is waiting for these.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
708 (program)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
709 (function)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
710 ;; The default is to use pop3.el.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
711 (t
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
712 (let ((pop3-password password)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
713 (pop3-maildrop user)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
714 (pop3-mailhost server)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
715 (pop3-port port)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
716 (pop3-authentication-scheme
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
717 (if (eq authentication 'apop) 'apop 'pass)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
718 (save-excursion (pop3-get-message-count))))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
719 (if result
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
720 ;; Inform display-time that we have new mail.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
721 (setq mail-source-new-mail-available (> result 0))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
722 ;; We nix out the password in case the error
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
723 ;; was because of a wrong password being given.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
724 (setq mail-source-password-cache
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
725 (delq (assoc from mail-source-password-cache)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
726 mail-source-password-cache)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
727 result)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
728
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
729 (defun mail-source-new-mail-p ()
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
730 "Handler for `display-time' to indicate when new mail is available."
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
731 ;; Only report flag setting; flag is updated on a different schedule.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
732 mail-source-new-mail-available)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
733
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
734
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
735 (defvar mail-source-report-new-mail nil)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
736 (defvar mail-source-report-new-mail-timer nil)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
737 (defvar mail-source-report-new-mail-idle-timer nil)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
738
32333
963ab34e3e60 (mail-source-fetch-imap): Bind
Dave Love <fx@gnu.org>
parents: 32102
diff changeset
739 (eval-when-compile
963ab34e3e60 (mail-source-fetch-imap): Bind
Dave Love <fx@gnu.org>
parents: 32102
diff changeset
740 (if (featurep 'xemacs)
963ab34e3e60 (mail-source-fetch-imap): Bind
Dave Love <fx@gnu.org>
parents: 32102
diff changeset
741 (require 'itimer)
963ab34e3e60 (mail-source-fetch-imap): Bind
Dave Love <fx@gnu.org>
parents: 32102
diff changeset
742 (require 'timer)))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
743
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
744 (defun mail-source-start-idle-timer ()
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
745 ;; Start our idle timer if necessary, so we delay the check until the
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
746 ;; user isn't typing.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
747 (unless mail-source-report-new-mail-idle-timer
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
748 (setq mail-source-report-new-mail-idle-timer
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
749 (run-with-idle-timer
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
750 mail-source-idle-time-delay
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
751 nil
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
752 (lambda ()
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
753 (setq mail-source-report-new-mail-idle-timer nil)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
754 (mail-source-check-pop mail-source-primary-source))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
755 ;; Since idle timers created when Emacs is already in the idle
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
756 ;; state don't get activated until Emacs _next_ becomes idle, we
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
757 ;; need to force our timer to be considered active now. We do
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
758 ;; this by being naughty and poking the timer internals directly
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
759 ;; (element 0 of the vector is nil if the timer is active).
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
760 (aset mail-source-report-new-mail-idle-timer 0 nil)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
761
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
762 (defun mail-source-report-new-mail (arg)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
763 "Toggle whether to report when new mail is available.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
764 This only works when `display-time' is enabled."
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
765 (interactive "P")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
766 (if (not mail-source-primary-source)
38413
a26d9b55abb6 Some fixes to follow coding conventions in files from Gnus.
Pavel Janík <Pavel@Janik.cz>
parents: 33342
diff changeset
767 (error "Need to set `mail-source-primary-source' to check for new mail"))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
768 (let ((on (if (null arg)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
769 (not mail-source-report-new-mail)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
770 (> (prefix-numeric-value arg) 0))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
771 (setq mail-source-report-new-mail on)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
772 (and mail-source-report-new-mail-timer
32102
e5f46972a7c8 2000-10-03 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 31784
diff changeset
773 (nnheader-cancel-timer mail-source-report-new-mail-timer))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
774 (and mail-source-report-new-mail-idle-timer
32102
e5f46972a7c8 2000-10-03 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 31784
diff changeset
775 (nnheader-cancel-timer mail-source-report-new-mail-idle-timer))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
776 (setq mail-source-report-new-mail-timer nil)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
777 (setq mail-source-report-new-mail-idle-timer nil)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
778 (if on
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
779 (progn
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
780 (require 'time)
31764
54ae1def18cf Merge from Gnus trunk.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
781 ;; display-time-mail-function is an Emacs 21 feature.
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
782 (setq display-time-mail-function #'mail-source-new-mail-p)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
783 ;; Set up the main timer.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
784 (setq mail-source-report-new-mail-timer
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
785 (run-at-time t (* 60 mail-source-report-new-mail-interval)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
786 #'mail-source-start-idle-timer))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
787 ;; When you get new mail, clear "Mail" from the mode line.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
788 (add-hook 'nnmail-post-get-new-mail-hook
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
789 'display-time-event-handler)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
790 (message "Mail check enabled"))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
791 (setq display-time-mail-function nil)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
792 (remove-hook 'nnmail-post-get-new-mail-hook
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
793 'display-time-event-handler)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
794 (message "Mail check disabled"))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
795
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
796 (defun mail-source-fetch-maildir (source callback)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
797 "Fetcher for maildir sources."
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
798 (mail-source-bind (maildir source)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
799 (let ((found 0)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
800 mail-source-string)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
801 (unless (string-match "/$" path)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
802 (setq path (concat path "/")))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
803 (dolist (subdir subdirs)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
804 (when (file-directory-p (concat path subdir))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
805 (setq mail-source-string (format "maildir:%s%s" path subdir))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
806 (dolist (file (directory-files (concat path subdir) t))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
807 (when (and (not (file-directory-p file))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
808 (not (if function
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
809 (funcall function file mail-source-crash-box)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
810 (let ((coding-system-for-write
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
811 mm-text-coding-system)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
812 (coding-system-for-read
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
813 mm-text-coding-system))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
814 (with-temp-file mail-source-crash-box
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
815 (insert-file-contents file)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
816 (goto-char (point-min))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
817 ;;; ;; Unix mail format
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
818 ;;; (unless (looking-at "\n*From ")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
819 ;;; (insert "From maildir "
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
820 ;;; (current-time-string) "\n"))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
821 ;;; (while (re-search-forward "^From " nil t)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
822 ;;; (replace-match ">From "))
32333
963ab34e3e60 (mail-source-fetch-imap): Bind
Dave Love <fx@gnu.org>
parents: 32102
diff changeset
823 ;;; (goto-char (point-max))
963ab34e3e60 (mail-source-fetch-imap): Bind
Dave Love <fx@gnu.org>
parents: 32102
diff changeset
824 ;;; (insert "\n\n")
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
825 ;; MMDF mail format
32333
963ab34e3e60 (mail-source-fetch-imap): Bind
Dave Love <fx@gnu.org>
parents: 32102
diff changeset
826 (insert "\001\001\001\001\n"))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
827 (delete-file file)))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
828 (incf found (mail-source-callback callback file))))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
829 found)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
830
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
831 (eval-and-compile
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
832 (autoload 'imap-open "imap")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
833 (autoload 'imap-authenticate "imap")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
834 (autoload 'imap-mailbox-select "imap")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
835 (autoload 'imap-mailbox-unselect "imap")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
836 (autoload 'imap-mailbox-close "imap")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
837 (autoload 'imap-search "imap")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
838 (autoload 'imap-fetch "imap")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
839 (autoload 'imap-close "imap")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
840 (autoload 'imap-error-text "imap")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
841 (autoload 'imap-message-flags-add "imap")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
842 (autoload 'imap-list-to-message-set "imap")
32102
e5f46972a7c8 2000-10-03 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 31784
diff changeset
843 (autoload 'imap-range-to-message-set "imap")
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
844 (autoload 'nnheader-ms-strip-cr "nnheader"))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
845
32102
e5f46972a7c8 2000-10-03 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 31784
diff changeset
846 (defvar mail-source-imap-file-coding-system 'binary
e5f46972a7c8 2000-10-03 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 31784
diff changeset
847 "Coding system for the crashbox made by `mail-source-fetch-imap'.")
e5f46972a7c8 2000-10-03 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 31784
diff changeset
848
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
849 (defun mail-source-fetch-imap (source callback)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
850 "Fetcher for imap sources."
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
851 (mail-source-bind (imap source)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
852 (let ((from (format "%s:%s:%s" server user port))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
853 (found 0)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
854 (buf (get-buffer-create (generate-new-buffer-name " *imap source*")))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
855 (mail-source-string (format "imap:%s:%s" server mailbox))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
856 remove)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
857 (if (and (imap-open server port stream authentication buf)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
858 (imap-authenticate
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
859 user (or (cdr (assoc from mail-source-password-cache))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
860 password) buf)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
861 (imap-mailbox-select mailbox nil buf))
32918
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
862 (let ((coding-system-for-write mail-source-imap-file-coding-system)
32333
963ab34e3e60 (mail-source-fetch-imap): Bind
Dave Love <fx@gnu.org>
parents: 32102
diff changeset
863 str)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
864 (with-temp-file mail-source-crash-box
32918
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
865 ;; Avoid converting 8-bit chars from inserted strings to
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
866 ;; multibyte.
dd8c5458b624 2000-10-26 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 32333
diff changeset
867 (mm-disable-multibyte)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
868 ;; remember password
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
869 (with-current-buffer buf
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
870 (when (or imap-password
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
871 (assoc from mail-source-password-cache))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
872 (push (cons from imap-password) mail-source-password-cache)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
873 ;; if predicate is nil, use all uids
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
874 (dolist (uid (imap-search (or predicate "1:*") buf))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
875 (when (setq str (imap-fetch uid "RFC822.PEEK" 'RFC822 nil buf))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
876 (push uid remove)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
877 (insert "From imap " (current-time-string) "\n")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
878 (save-excursion
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
879 (insert str "\n\n"))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
880 (while (re-search-forward "^From " nil t)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
881 (replace-match ">From "))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
882 (goto-char (point-max))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
883 (nnheader-ms-strip-cr))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
884 (incf found (mail-source-callback callback server))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
885 (when (and remove fetchflag)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
886 (imap-message-flags-add
32102
e5f46972a7c8 2000-10-03 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 31784
diff changeset
887 (imap-range-to-message-set (gnus-compress-sequence remove))
e5f46972a7c8 2000-10-03 Dave Love <fx@gnu.org>
Dave Love <fx@gnu.org>
parents: 31784
diff changeset
888 fetchflag nil buf))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
889 (if dontexpunge
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
890 (imap-mailbox-unselect buf)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
891 (imap-mailbox-close buf))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
892 (imap-close buf))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
893 (imap-close buf)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
894 ;; We nix out the password in case the error
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
895 ;; was because of a wrong password being given.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
896 (setq mail-source-password-cache
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
897 (delq (assoc from mail-source-password-cache)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
898 mail-source-password-cache))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
899 (error (imap-error-text buf)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
900 (kill-buffer buf)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
901 found)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
902
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
903 (eval-and-compile
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
904 (autoload 'webmail-fetch "webmail"))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
905
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
906 (defun mail-source-fetch-webmail (source callback)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
907 "Fetch for webmail source."
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
908 (mail-source-bind (webmail source)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
909 (let ((mail-source-string (format "webmail:%s:%s" subtype user))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
910 (webmail-newmail-only dontexpunge)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
911 (webmail-move-to-trash-can (not dontexpunge)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
912 (when (eq authentication 'password)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
913 (setq password
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
914 (or password
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
915 (cdr (assoc (format "webmail:%s:%s" subtype user)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
916 mail-source-password-cache))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
917 (mail-source-read-passwd
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
918 (format "Password for %s at %s: " user subtype))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
919 (when (and password
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
920 (not (assoc (format "webmail:%s:%s" subtype user)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
921 mail-source-password-cache)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
922 (push (cons (format "webmail:%s:%s" subtype user) password)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
923 mail-source-password-cache)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
924 (webmail-fetch mail-source-crash-box subtype user password)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
925 (mail-source-callback callback (symbol-name subtype)))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
926
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
927 (provide 'mail-source)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
928
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
929 ;;; mail-source.el ends here