Prefer directed to neutral quotes
[gnus] / lisp / mail-source.el
1 ;;; mail-source.el --- functions for fetching mail
2
3 ;; Copyright (C) 1999-2015 Free Software Foundation, Inc.
4
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; Keywords: news, mail
7
8 ;; This file is part of GNU Emacs.
9
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation, either version 3 of the License, or
13 ;; (at your option) any later version.
14
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 ;; GNU General Public License for more details.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
22
23 ;;; Commentary:
24
25 ;;; Code:
26
27 (require 'format-spec)
28 (eval-when-compile
29   (require 'cl)
30   (require 'imap))
31 (autoload 'auth-source-search "auth-source")
32 (autoload 'pop3-movemail "pop3")
33 (autoload 'pop3-get-message-count "pop3")
34 (autoload 'nnheader-cancel-timer "nnheader")
35 (require 'mm-util)
36 (require 'message) ;; for `message-directory'
37
38 (defvar display-time-mail-function)
39
40 (defgroup mail-source nil
41   "The mail-fetching library."
42   :version "21.1"
43   :group 'gnus)
44
45 ;; Define these at compile time to avoid dragging in imap always.
46 (defconst mail-source-imap-authenticators
47   (eval-when-compile
48     (mapcar (lambda (a)
49               (list 'const (car a)))
50      imap-authenticator-alist)))
51 (defconst mail-source-imap-streams
52   (eval-when-compile
53     (mapcar (lambda (a)
54               (list 'const (car a)))
55      imap-stream-alist)))
56
57 (defcustom mail-sources '((file))
58   "Where the mail backends will look for incoming mail.
59 This variable is a list of mail source specifiers.
60 See Info node `(gnus)Mail Source Specifiers'."
61   :group 'mail-source
62   :version "24.4"
63   :link '(custom-manual "(gnus)Mail Source Specifiers")
64   :type `(choice
65           (const :tag "None" nil)
66           (repeat :tag "List"
67            (choice :format "%[Value Menu%] %v"
68                    :value (file)
69                    (cons :tag "Group parameter `mail-source'"
70                          (const :format "" group))
71                    (cons :tag "Spool file"
72                          (const :format "" file)
73                          (checklist :tag "Options" :greedy t
74                                     (group :inline t
75                                            (const :format "" :value :path)
76                                            file)))
77                    (cons :tag "Several files in a directory"
78                          (const :format "" directory)
79                          (checklist :tag "Options" :greedy t
80                                     (group :inline t
81                                            (const :format "" :value :path)
82                                            (directory :tag "Path"))
83                                     (group :inline t
84                                            (const :format "" :value :suffix)
85                                            (string :tag "Suffix"))
86                                     (group :inline t
87                                            (const :format "" :value :predicate)
88                                            (function :tag "Predicate"))
89                                     (group :inline t
90                                            (const :format "" :value :prescript)
91                                            (choice :tag "Prescript"
92                                                    :value nil
93                                                    (string :format "%v")
94                                                    (function :format "%v")))
95                                     (group :inline t
96                                            (const :format "" :value :postscript)
97                                            (choice :tag "Postscript"
98                                                    :value nil
99                                                    (string :format "%v")
100                                                    (function :format "%v")))
101                                     (group :inline t
102                                            (const :format "" :value :plugged)
103                                            (boolean :tag "Plugged"))))
104                    (cons :tag "POP3 server"
105                          (const :format "" pop)
106                          (checklist :tag "Options" :greedy t
107                                     (group :inline t
108                                            (const :format "" :value :server)
109                                            (string :tag "Server"))
110                                     (group :inline t
111                                            (const :format "" :value :port)
112                                            (choice :tag "Port"
113                                                    :value "pop3"
114                                                    (integer :format "%v")
115                                                    (string :format "%v")))
116                                     (group :inline t
117                                            (const :format "" :value :user)
118                                            (string :tag "User"))
119                                     (group :inline t
120                                            (const :format "" :value :password)
121                                            (string :tag "Password"))
122                                     (group :inline t
123                                            (const :format "" :value :program)
124                                            (string :tag "Program"))
125                                     (group :inline t
126                                            (const :format "" :value :prescript)
127                                            (choice :tag "Prescript"
128                                                    :value nil
129                                                    (string :format "%v")
130                                                    (function :format "%v")
131                                                    (const :tag "None" nil)))
132                                     (group :inline t
133                                            (const :format "" :value :postscript)
134                                            (choice :tag "Postscript"
135                                                    :value nil
136                                                    (string :format "%v")
137                                                    (function :format "%v")
138                                                    (const :tag "None" nil)))
139                                     (group :inline t
140                                            (const :format "" :value :function)
141                                            (function :tag "Function"))
142                                     (group :inline t
143                                            (const :format ""
144                                                   :value :authentication)
145                                            (choice :tag "Authentication"
146                                                    :value apop
147                                                    (const password)
148                                                    (const apop)))
149                                     (group :inline t
150                                            (const :format "" :value :plugged)
151                                            (boolean :tag "Plugged"))
152                                     (group :inline t
153                                            (const :format "" :value :stream)
154                                            (choice :tag "Stream"
155                                                    :value nil
156                                                    (const :tag "Clear" nil)
157                                                    (const starttls)
158                                                    (const :tag "SSL/TLS" ssl)))
159                                     (group :inline t
160                                            (const :format "" :value :leave)
161                                            (choice :format "\
162 %{Leave mail on server%}:\n\t\t%[Value Menu%] %v"
163                                                    :value nil
164                                                    (const :tag "\
165 Don't leave mails" nil)
166                                                    (const :tag "\
167 Leave all mails" t)
168                                                    (number :tag "\
169 Leave mails for this many days" :value 14)))))
170                    (cons :tag "Maildir (qmail, postfix...)"
171                          (const :format "" maildir)
172                          (checklist :tag "Options" :greedy t
173                                     (group :inline t
174                                            (const :format "" :value :path)
175                                            (directory :tag "Path"))
176                                     (group :inline t
177                                            (const :format "" :value :plugged)
178                                            (boolean :tag "Plugged"))))
179                    (cons :tag "IMAP server"
180                          (const :format "" imap)
181                          (checklist :tag "Options" :greedy t
182                                     (group :inline t
183                                            (const :format "" :value :server)
184                                            (string :tag "Server"))
185                                     (group :inline t
186                                            (const :format "" :value :port)
187                                            (choice :tag "Port"
188                                                    :value 143
189                                                    integer string))
190                                     (group :inline t
191                                            (const :format "" :value :user)
192                                            (string :tag "User"))
193                                     (group :inline t
194                                            (const :format "" :value :password)
195                                            (string :tag "Password"))
196                                     (group :inline t
197                                            (const :format "" :value :stream)
198                                            (choice :tag "Stream"
199                                                    :value network
200                                                    ,@mail-source-imap-streams))
201                                     (group :inline t
202                                            (const :format "" :value :program)
203                                            (string :tag "Program"))
204                                     (group :inline t
205                                            (const :format ""
206                                                   :value :authenticator)
207                                            (choice :tag "Authenticator"
208                                                    :value login
209                                                    ,@mail-source-imap-authenticators))
210                                     (group :inline t
211                                            (const :format "" :value :mailbox)
212                                            (string :tag "Mailbox"
213                                                    :value "INBOX"))
214                                     (group :inline t
215                                            (const :format "" :value :predicate)
216                                            (string :tag "Predicate"
217