Mercurial > emacs
annotate lisp/gnus/mail-source.el @ 67418:28264c86d408
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-668
Merge from gnus--rel--5.10
Patches applied:
* gnus--rel--5.10 (patch 157-168)
- Merge from emacs--cvs-trunk--0
- Update from CVS
- Update from CVS: texi/message.texi: Fix default values.
2005-12-08 Reiner Steib <Reiner.Steib@gmx.de>
* lisp/gnus/mm-decode.el (mm-discouraged-alternatives): Fix custom type.
Suggest image/.* in the doc string.
2005-12-07 Katsumi Yamaoka <yamaoka@jpl.org>
* lisp/gnus/mm-decode.el (mm-display-external): Use nametemplate (defined in
RFC1524) if it is in mailcap or add a suffix according to
mailcap-mime-extensions when generating a temp filename; postpone
deleting a temp file for 2 seconds for some wrappers, shell
scripts, and so on, which might exit right after having started a
viewer command as a background job.
2005-12-06 Reiner Steib <Reiner.Steib@gmx.de>
* lisp/gnus/gnus-art.el (gnus-default-article-saver): Add user-defined
`function' to custom type.
2005-12-02 ARISAWA Akihiro <ari@mbf.ocn.ne.jp> (tiny change)
* lisp/gnus/mm-view.el (mm-inline-text-html-render-with-w3m): Fix misplaced
parens.
2005-11-29 Reiner Steib <Reiner.Steib@gmx.de>
* lisp/gnus/gnus-cache.el (gnus-cache-rename-group): Wrap doc strings and
long lines.
(gnus-cache-delete-group): Wrap doc strings.
* lisp/gnus/gnus-agent.el (gnus-agent-rename-group)
(gnus-agent-delete-group): Wrap doc strings.
2005-11-24 Pascal Rigaux <pixel@mandriva.com> (tiny change)
* lisp/gnus/rfc2231.el (rfc2231-parse-string): Support non-ascii chars.
2005-11-22 Katsumi Yamaoka <yamaoka@jpl.org>
* lisp/gnus/nnmail.el (nnmail-fancy-expiry-target): Use current-time instead
of current-time-string.
2005-11-20 Stefan Schimanski <schimmi@debian.org> (tiny change)
* lisp/gnus/nnmail.el (nnmail-fancy-expiry-target): Protect against invalid
date header.
2005-11-16 Boris Samorodov <bsam@ipt.ru> (tiny patch)
* lisp/gnus/imap.el (imap-kerberos4-open): Ignore SSL stuff.
2005-11-14 Kevin Greiner <kevin.greiner@compsol.cc>
* lisp/gnus/gnus-agent.el (gnus-agent-article-alist-save-format): Changed
internal variable to a custom variable. Changed default value
from compressed(2) to uncompressed(1).
(gnus-agent-read-agentview): Reversed revision 7.8 to restore
support for uncompressed agentview files. Taken together, reading
the agentview file should now be 6-7 times faster.
(gnus-agent-long-article,
gnus-agent-short-article, gnus-agent-score): Renamed category
keywords to match gnus-cus.
(gnus-agent-summary-fetch-series): Modified to protect against
gnus-agent-summary-fetch-group clearing processable flags.
(gnus-agent-synchronize-group-flags): Update live group buffer as
synchronization may occur due to the user toggling the plugged
status.
(gnus-agent-braid-nov): Now tests new nov entries
for duplicates which are removed. The invalid sort check then
triggers a rescan after the sort as sorting may have moved
duplicate entries such that they can be cheaply detected.
(gnus-agent-read-local): Trivial fix to format of
error message to display actual error condition.
(gnus-agent-save-local): Avoid saving symbols that are bound to
nil as they simply result in a warning message in
gnus-agent-read-local.
(gnus-agent-fetch-group-1): Clear downloadable flag when article
successfully downloaded.
(gnus-agent-regenerate-group): Use
gnus-agent-synchronize-group-flags to reset read status in both
gnus and server.
* lisp/gnus/nntp.el (nntp-end-of-line): Doc fix.
(nntp-authinfo-rejected): New error condition.
(nntp-wait-for): Use new error condition to signal authentication
error.
(nntp-retrieve-data): Rethrow new error condition to break out of
recursive call to nntp-send-authinfo.
2005-11-13 Katsumi Yamaoka <yamaoka@jpl.org>
* lisp/gnus/gnus-start.el (gnus-dribble-read-file): Use make-local-variable
rather than make-variable-buffer-local for file-precious-flag.
2005-11-13 Katsumi Yamaoka <yamaoka@jpl.org>
* lisp/gnus/gnus-start.el (gnus-dribble-read-file): Quote file-precious-flag.
2005-11-11 Jan Nieuwenhuizen <janneke@gnu.org>
* lisp/gnus/gnus-start.el (gnus-dribble-read-file): Set file-precious-flag,
as a buffer-local variable. This avoids creating truncated
dribble files as a result of a hang up, eg.
2005-11-04 Ken Manheimer <ken.manheimer@gmail.com>
* lisp/gnus/pgg-pgp.el (pgg-pgp-encrypt-region, pgg-pgp-decrypt-region)
(pgg-pgp-encrypt-symmetric-region, pgg-pgp-encrypt-symmetric)
(pgg-pgp-encrypt, pgg-pgp-decrypt-region, pgg-pgp-decrypt)
(pgg-pgp-sign-region, pgg-pgp-sign): Add optional 'passphrase'
argument to all these routines, so the passphrase can be managed
externally and passed in to the system.
(pgg-pgp-decrypt-region, pgg-pgp-sign-region): Use new name for
pgg-add-passphrase-to-cache function.
* lisp/gnus/pgg-pgp5.el (pgg-pgp5-encrypt-region, pgg-pgp5-decrypt-region)
(pgg-pgp5-encrypt-symmetric-region, pgg-pgp5-encrypt-symmetric)
(pgg-pgp5-encrypt, pgg-pgp5-decrypt-region, pgg-pgp5-decrypt)
(pgg-pgp5-sign-region, pgg-pgp5-sign): Add optional 'passphrase'
argument to all these routines, so the passphrase can be managed
externally and passed in to the system.
(pgg-pgp5-sign-region): Use new name of pgg-add-passphrase-to-cache
function.
2005-10-30 Chong Yidong <cyd@stupidchicken.com>
* lisp/gnus/imap.el (imap-open): Handle case where buffer is a buffer
object.
2005-10-29 Ken Manheimer <ken.manheimer@gmail.com>
* lisp/gnus/pgg-gpg.el (pgg-gpg-select-matching-key): Fix: look at the right
part of the decoded armor to find the key-identifier.
(pgg-gpg-lookup-key-owner): New function to return the
human-readable identifier of a key owner.
(pgg-gpg-lookup-id-from-key-owner): Make it easy to identify the
key itself.
(pgg-gpg-decrypt-region): Prompt with the key owner (rather than
the key value) if we have a key and can match it against a secret
key. Also, added a note pointing out fact that the prompt only
indicates the first matching key.
* lisp/gnus/pgg.el (pgg-decrypt): Passing along 'passphrase' in call to
pgg-decrypt-region.
(pgg-pending-timers): A new hash for tracking the passphrase cache
timers, so that new ones supercede old ones.
(pgg-add-passphrase-to-cache): Rename from
`pgg-add-passphrase-cache' to reduce confusion (all callers
changed). Modified to cancel old timers when new ones are added.
(pgg-remove-passphrase-from-cache): Rename from
`pgg-remove-passphrase-cache' to reduce confusion (all callers
changed). Modified to cancel old timers when their keys are
removed from the cache.
(pgg-cancel-timer): In Emacs, an alias for cancel-timer; in
XEmacs, an indirection to delete-itimer.
(pgg-read-passphrase-from-cache, pgg-read-passphrase):
Extract pgg-read-passphrase-from-cache from pgg-read-passphrase so
users can only check cache without risk of prompting. Correct bug in
notruncate behavior.
(pgg-read-passphrase-from-cache, pgg-read-passphrase)
(pgg-add-passphrase-cache, pgg-remove-passphrase-cache):
Add informative docstrings.
(pgg-decrypt): Convey provided passphrase in subordinate call to
pgg-decrypt-region.
2005-10-20 Ken Manheimer <ken.manheimer+emacs@gmail.com>
* lisp/gnus/pgg.el (pgg-encrypt-region, pgg-encrypt-symmetric-region)
(pgg-encrypt-symmetric, pgg-encrypt, pgg-decrypt-region)
(pgg-decrypt, pgg-sign-region, pgg-sign): Add optional
'passphrase' argument, so the passphrase can be managed externally
and then passed in to the system.
* lisp/gnus/pgg.el (pgg-read-passphrase, pgg-add-passphrase-cache)
(pgg-remove-passphrase-cache): Add optional 'notruncate' argument,
so the passphrase cache can be used reliably with identifiers
besides a pgp packet's key id.
* lisp/gnus/pgg-gpg.el (pgg-pgp-encrypt-region)
(pgg-pgp-encrypt-symmetric-region, pgg-pgp-encrypt-symmetric)
(pgg-pgp-encrypt, pgg-pgp-decrypt-region, pgg-pgp-decrypt)
(pgg-pgp-sign-region, pgg-pgp-sign): Add optional 'passphrase'
argument to all these routines, so the passphrase can be managed
externally and passed in to the system.
* lisp/gnus/pgg-gpg.el (pgg-gpg-possibly-cache-passphrase): Add optional
'notruncate' argument, so the passphrase cache can be used
reliably with identifiers besides a pgp packet's key id.
2005-10-29 Sascha Wilde <swilde@sha-bang.de>
* lisp/gnus/pgg-gpg.el (pgg-gpg-encrypt-symmetric-region): New function for
symmetric encryption.
(pgg-gpg-symmetric-key-p): New function to check for an symmetric
encrypted session key.
(pgg-gpg-decrypt-region): When decrypting a symmetric encrypted
message ask for the passphrase in a proper way.
* lisp/gnus/pgg.el (pgg-encrypt-symmetric, pgg-encrypt-symmetric-region):
New user commands for symmetric encryption.
2005-12-05 Katsumi Yamaoka <yamaoka@jpl.org>
* man/pgg.texi (User Commands): Fix description of pgg-verify-region.
(Selecting an implementation): Fix descriptions.
2005-11-30 Katsumi Yamaoka <yamaoka@jpl.org>
* man/message.texi (Various Message Variables): Addition.
2005-11-29 Katsumi Yamaoka <yamaoka@jpl.org>
* man/message.texi: Fix default values.
2005-11-25 Katsumi Yamaoka <yamaoka@jpl.org>
* man/message.texi (Header Commands): Clarify descriptions of
message-cross-post-followup-to, message-reduce-to-to-cc, and
message-insert-wide-reply.
(Various Commands): Fix kindex for message-kill-to-signature;
clarify description of message-tab.
2005-11-22 Katsumi Yamaoka <yamaoka@jpl.org>
* man/message.texi (Mailing Lists): Fix description about MFT.
* man/gnus.texi (Emacs Lisp): Use ~/.gnus.el instead of ~/.emacs.
2005-11-17 Katsumi Yamaoka <yamaoka@jpl.org>
* man/gnus.texi (Slow Terminal Connection): Replace old description
with new one.
2005-11-16 Katsumi Yamaoka <yamaoka@jpl.org>
* man/gnus.texi (Oort Gnus): Use ~/.gnus.el instead of ~/.emacs;
replace X-Draft-Headers with X-Draft-From.
2005-11-14 Katsumi Yamaoka <yamaoka@jpl.org>
* man/gnus.texi (Various Various): Fix the default value of
nnheader-max-head-length.
(Gnus Versions): Fix typo.
author | Miles Bader <miles@gnu.org> |
---|---|
date | Fri, 09 Dec 2005 08:57:58 +0000 |
parents | 01b85ec4a61d |
children | 1077b8039c32 0ca0d9181b5e |
rev | line source |
---|---|
31717 | 1 ;;; mail-source.el --- functions for fetching mail |
64754
fafd692d1e40
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64085
diff
changeset
|
2 |
fafd692d1e40
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64085
diff
changeset
|
3 ;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, |
fafd692d1e40
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64085
diff
changeset
|
4 ;; 2005 Free Software Foundation, Inc. |
31717 | 5 |
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org> | |
7 ;; Keywords: news, mail | |
8 | |
9 ;; This file is part of GNU Emacs. | |
10 | |
11 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
12 ;; it under the terms of the GNU General Public License as published by | |
13 ;; the Free Software Foundation; either version 2, or (at your option) | |
14 ;; any later version. | |
15 | |
16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
64085 | 23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
24 ;; Boston, MA 02110-1301, USA. | |
31717 | 25 |
26 ;;; Commentary: | |
27 | |
28 ;;; Code: | |
29 | |
32918 | 30 (eval-when-compile |
31 (require 'cl) | |
32 (require 'imap) | |
33 (eval-when-compile (defvar display-time-mail-function))) | |
31717 | 34 (eval-and-compile |
35 (autoload 'pop3-movemail "pop3") | |
32918 | 36 (autoload 'pop3-get-message-count "pop3") |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
37 (autoload 'nnheader-cancel-timer "nnheader") |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
38 (autoload 'nnheader-run-at-time "nnheader")) |
31717 | 39 (require 'format-spec) |
32918 | 40 (require 'mm-util) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
41 (require 'message) ;; for `message-directory' |
31717 | 42 |
43 (defgroup mail-source nil | |
44 "The mail-fetching library." | |
31764 | 45 :version "21.1" |
31717 | 46 :group 'gnus) |
47 | |
32918 | 48 ;; Define these at compile time to avoid dragging in imap always. |
49 (defconst mail-source-imap-authenticators | |
50 (eval-when-compile | |
51 (mapcar (lambda (a) | |
52 (list 'const (car a))) | |
53 imap-authenticator-alist))) | |
54 (defconst mail-source-imap-streams | |
55 (eval-when-compile | |
56 (mapcar (lambda (a) | |
57 (list 'const (car a))) | |
58 imap-stream-alist))) | |
59 | |
32102 | 60 (defcustom mail-sources nil |
31717 | 61 "*Where the mail backends will look for incoming mail. |
31764 | 62 This variable is a list of mail source specifiers. |
63 See Info node `(gnus)Mail Source Specifiers'." | |
31717 | 64 :group 'mail-source |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
65 :link '(custom-manual "(gnus)Mail Source Specifiers") |
31764 | 66 :type `(repeat |
32918 | 67 (choice :format "%[Value Menu%] %v" |
68 :value (file) | |
69 (cons :tag "Spool file" | |
70 (const :format "" file) | |
71 (checklist :tag "Options" :greedy t | |
72 (group :inline t | |
73 (const :format "" :value :path) | |
74 file))) | |
31764 | 75 (cons :tag "Several files in a directory" |
32918 | 76 (const :format "" directory) |
77 (checklist :tag "Options" :greedy t | |
78 (group :inline t | |
79 (const :format "" :value :path) | |
80 (directory :tag "Path")) | |
81 (group :inline t | |
82 (const :format "" :value :suffix) | |
83 (string :tag "Suffix")) | |
84 (group :inline t | |
85 (const :format "" :value :predicate) | |
86 (function :tag "Predicate")) | |
87 (group :inline t | |
88 (const :format "" :value :prescript) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
89 (choice :tag "Prescript" |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
90 :value nil |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
91 (string :format "%v") |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
92 (function :format "%v"))) |
32918 | 93 (group :inline t |
94 (const :format "" :value :postscript) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
95 (choice :tag "Postscript" |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
96 :value nil |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
97 (string :format "%v") |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
98 (function :format "%v"))) |
32918 | 99 (group :inline t |
100 (const :format "" :value :plugged) | |
101 (boolean :tag "Plugged")))) | |
31764 | 102 (cons :tag "POP3 server" |
32918 | 103 (const :format "" pop) |
104 (checklist :tag "Options" :greedy t | |
105 (group :inline t | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
44075
diff
changeset
|
106 (const :format "" :value :server) |
32918 | 107 (string :tag "Server")) |
108 (group :inline t | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
44075
diff
changeset
|
109 (const :format "" :value :port) |
32918 | 110 (choice :tag "Port" |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
44075
diff
changeset
|
111 :value "pop3" |
32918 | 112 (number :format "%v") |
113 (string :format "%v"))) | |
114 (group :inline t | |
115 (const :format "" :value :user) | |
116 (string :tag "User")) | |
117 (group :inline t | |
118 (const :format "" :value :password) | |
119 (string :tag "Password")) | |
120 (group :inline t | |
121 (const :format "" :value :program) | |
122 (string :tag "Program")) | |
123 (group :inline t | |
124 (const :format "" :value :prescript) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
125 (choice :tag "Prescript" |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
126 :value nil |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
127 (string :format "%v") |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
128 (function :format "%v"))) |
32918 | 129 (group :inline t |
130 (const :format "" :value :postscript) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
131 (choice :tag "Postscript" |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
132 :value nil |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
133 (string :format "%v") |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
134 (function :format "%v"))) |
32918 | 135 (group :inline t |
136 (const :format "" :value :function) | |
137 (function :tag "Function")) | |
138 (group :inline t | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
44075
diff
changeset
|
139 (const :format "" |
32918 | 140 :value :authentication) |
141 (choice :tag "Authentication" | |
142 :value apop | |
143 (const password) | |
144 (const apop))) | |
145 (group :inline t | |
146 (const :format "" :value :plugged) | |
147 (boolean :tag "Plugged")))) | |
31764 | 148 (cons :tag "Maildir (qmail, postfix...)" |
32918 | 149 (const :format "" maildir) |
150 (checklist :tag "Options" :greedy t | |
151 (group :inline t | |
152 (const :format "" :value :path) | |
153 (directory :tag "Path")) | |
154 (group :inline t | |
155 (const :format "" :value :plugged) | |
156 (boolean :tag "Plugged")))) | |
31764 | 157 (cons :tag "IMAP server" |
32918 | 158 (const :format "" imap) |
159 (checklist :tag "Options" :greedy t | |
160 (group :inline t | |
161 (const :format "" :value :server) | |
162 (string :tag "Server")) | |
163 (group :inline t | |
164 (const :format "" :value :port) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
44075
diff
changeset
|
165 (choice :tag "Port" |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
44075
diff
changeset
|
166 :value 143 |
32918 | 167 number string)) |
168 (group :inline t | |
169 (const :format "" :value :user) | |
170 (string :tag "User")) | |
171 (group :inline t | |
172 (const :format "" :value :password) | |
173 (string :tag "Password")) | |
174 (group :inline t | |
175 (const :format "" :value :stream) | |
176 (choice :tag "Stream" | |
177 :value network | |
178 ,@mail-source-imap-streams)) | |
179 (group :inline t | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
180 (const :format "" :value :program) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
181 (string :tag "Program")) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
182 (group :inline t |
32918 | 183 (const :format "" |
184 :value :authenticator) | |
185 (choice :tag "Authenticator" | |
186 :value login | |
187 ,@mail-source-imap-authenticators)) | |
188 (group :inline t | |
189 (const :format "" :value :mailbox) | |
32961
5357dbf00515
2000-10-26 Simon Josefsson <sj@extundo.com>
Dave Love <fx@gnu.org>
parents:
32918
diff
changeset
|
190 (string :tag "Mailbox" |
5357dbf00515
2000-10-26 Simon Josefsson <sj@extundo.com>
Dave Love <fx@gnu.org>
parents:
32918
diff
changeset
|
191 :value "INBOX")) |
32918 | 192 (group :inline t |
193 (const :format "" :value :predicate) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
44075
diff
changeset
|
194 (string :tag "Predicate" |
32961
5357dbf00515
2000-10-26 Simon Josefsson <sj@extundo.com>
Dave Love <fx@gnu.org>
parents:
32918
diff
changeset
|
195 :value "UNSEEN UNDELETED")) |
32918 | 196 (group :inline t |
197 (const :format "" :value :fetchflag) | |
32961
5357dbf00515
2000-10-26 Simon Josefsson <sj@extundo.com>
Dave Love <fx@gnu.org>
parents:
32918
diff
changeset
|
198 (string :tag "Fetchflag" |
5357dbf00515
2000-10-26 Simon Josefsson <sj@extundo.com>
Dave Love <fx@gnu.org>
parents:
32918
diff
changeset
|
199 :value "\\Deleted")) |
32918 | 200 (group :inline t |
201 (const :format "" | |
202 :value :dontexpunge) | |
203 (boolean :tag "Dontexpunge")) | |
204 (group :inline t | |
205 (const :format "" :value :plugged) | |
206 (boolean :tag "Plugged")))) | |
31764 | 207 (cons :tag "Webmail server" |
32918 | 208 (const :format "" webmail) |
209 (checklist :tag "Options" :greedy t | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
44075
diff
changeset
|
210 (group :inline t |
32918 | 211 (const :format "" :value :subtype) |
212 ;; Should be generated from | |
213 ;; `webmail-type-definition', but we | |
214 ;; can't require webmail without W3. | |
215 (choice :tag "Subtype" | |
216 :value hotmail | |
217 (const hotmail) | |
218 (const yahoo) | |
219 (const netaddress) | |
220 (const netscape) | |
221 (const my-deja))) | |
222 (group :inline t | |
223 (const :format "" :value :user) | |
224 (string :tag "User")) | |
225 (group :inline t | |
226 (const :format "" :value :password) | |
227 (string :tag "Password")) | |
228 (group :inline t | |
229 (const :format "" | |
230 :value :dontexpunge) | |
231 (boolean :tag "Dontexpunge")) | |
232 (group :inline t | |
233 (const :format "" :value :plugged) | |
234 (boolean :tag "Plugged"))))))) | |
31717 | 235 |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
236 (defcustom mail-source-ignore-errors nil |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
237 "*Ignore errors when querying mail sources. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
238 If nil, the user will be prompted when an error occurs. If non-nil, |
57153
497f0d2ca551
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-558
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
239 the error will be ignored." |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
57581
diff
changeset
|
240 :version "22.1" |
57153
497f0d2ca551
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-558
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
241 :group 'mail-source |
497f0d2ca551
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-558
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
242 :type 'boolean) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
243 |
31717 | 244 (defcustom mail-source-primary-source nil |
245 "*Primary source for incoming mail. | |
246 If non-nil, this maildrop will be checked periodically for new mail." | |
247 :group 'mail-source | |
248 :type 'sexp) | |
249 | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
250 (defcustom mail-source-flash t |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
251 "*If non-nil, flash periodically when mail is available." |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
252 :group 'mail-source |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
253 :type 'boolean) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
254 |
31717 | 255 (defcustom mail-source-crash-box "~/.emacs-mail-crash-box" |
256 "File where mail will be stored while processing it." | |
257 :group 'mail-source | |
258 :type 'file) | |
259 | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
260 (defcustom mail-source-directory message-directory |
57581
645f020dcc8a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-626
Miles Bader <miles@gnu.org>
parents:
57153
diff
changeset
|
261 "Directory where incoming mail source files (if any) will be stored." |
31717 | 262 :group 'mail-source |
263 :type 'directory) | |
264 | |
265 (defcustom mail-source-default-file-modes 384 | |
266 "Set the mode bits of all new mail files to this integer." | |
267 :group 'mail-source | |
268 :type 'integer) | |
269 | |
31784
33d474f4b866
(mail-source-delete-incoming): Set to t, assuming
Dave Love <fx@gnu.org>
parents:
31764
diff
changeset
|
270 (defcustom mail-source-delete-incoming t |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
271 "*If non-nil, delete incoming files after handling. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
272 If t, delete immediately, if nil, never delete. If a positive number, delete |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
273 files older than number of days." |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
274 ;; Note: The removing happens in `mail-source-callback', i.e. no old |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
275 ;; incoming files will be deleted, unless you receive new mail. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
276 ;; |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
277 ;; You may also set this to `nil' and call `mail-source-delete-old-incoming' |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
278 ;; from a hook or interactively. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
279 :group 'mail-source |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
280 :type '(choice (const :tag "immediately" t) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
281 (const :tag "never" nil) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
282 (integer :tag "days"))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
283 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
284 (defcustom mail-source-delete-old-incoming-confirm t |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
285 "*If non-nil, ask for for confirmation before deleting old incoming files. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
286 This variable only applies when `mail-source-delete-incoming' is a positive |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
287 number." |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
57581
diff
changeset
|
288 :version "22.1" |
31717 | 289 :group 'mail-source |
290 :type 'boolean) | |
291 | |
292 (defcustom mail-source-incoming-file-prefix "Incoming" | |
293 "Prefix for file name for storing incoming mail" | |
294 :group 'mail-source | |
295 :type 'string) | |
296 | |
297 (defcustom mail-source-report-new-mail-interval 5 | |
298 "Interval in minutes between checks for new mail." | |
299 :group 'mail-source | |
300 :type 'number) | |
301 | |
302 (defcustom mail-source-idle-time-delay 5 | |
303 "Number of idle seconds to wait before checking for new mail." | |
304 :group 'mail-source | |
305 :type 'number) | |
306 | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
307 (defcustom mail-source-movemail-program nil |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
308 "If non-nil, name of program for fetching new mail." |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
57581
diff
changeset
|
309 :version "22.1" |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
310 :group 'mail-source |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
311 :type '(choice (const nil) string)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
312 |
31717 | 313 ;;; Internal variables. |
314 | |
315 (defvar mail-source-string "" | |
316 "A dynamically bound string that says what the current mail source is.") | |
317 | |
318 (defvar mail-source-new-mail-available nil | |
319 "Flag indicating when new mail is available.") | |
320 | |
321 (eval-and-compile | |
322 (defvar mail-source-common-keyword-map | |
323 '((:plugged)) | |
324 "Mapping from keywords to default values. | |
325 Common keywords should be listed here.") | |
326 | |
327 (defvar mail-source-keyword-map | |
328 '((file | |
329 (:prescript) | |
330 (:prescript-delay) | |
331 (:postscript) | |
332 (:path (or (getenv "MAIL") | |
32918 | 333 (expand-file-name (user-login-name) rmail-spool-directory)))) |
31717 | 334 (directory |
43422
fa370bd262ee
Patched a wrong location.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
43421
diff
changeset
|
335 (:prescript) |
fa370bd262ee
Patched a wrong location.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
43421
diff
changeset
|
336 (:prescript-delay) |
fa370bd262ee
Patched a wrong location.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
43421
diff
changeset
|
337 (:postscript) |
31717 | 338 (:path) |
339 (:suffix ".spool") | |
340 (:predicate identity)) | |
341 (pop | |
342 (:prescript) | |
343 (:prescript-delay) | |
344 (:postscript) | |
345 (:server (getenv "MAILHOST")) | |
346 (:port 110) | |
347 (:user (or (user-login-name) (getenv "LOGNAME") (getenv "USER"))) | |
348 (:program) | |
349 (:function) | |
350 (:password) | |
351 (:authentication password)) | |
352 (maildir | |
353 (:path (or (getenv "MAILDIR") "~/Maildir/")) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
354 (:subdirs ("cur" "new")) |
31717 | 355 (:function)) |
356 (imap | |
357 (:server (getenv "MAILHOST")) | |
358 (:port) | |
359 (:stream) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
360 (:program) |
31717 | 361 (:authentication) |
362 (:user (or (user-login-name) (getenv "LOGNAME") (getenv "USER"))) | |
363 (:password) | |
364 (:mailbox "INBOX") | |
365 (:predicate "UNSEEN UNDELETED") | |
366 (:fetchflag "\\Deleted") | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
367 (:prescript) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
368 (:prescript-delay) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
369 (:postscript) |
31717 | 370 (:dontexpunge)) |
371 (webmail | |
372 (:subtype hotmail) | |
373 (:user (or (user-login-name) (getenv "LOGNAME") (getenv "USER"))) | |
374 (:password) | |
375 (:dontexpunge) | |
376 (:authentication password))) | |
377 "Mapping from keywords to default values. | |
378 All keywords that can be used must be listed here.")) | |
379 | |
380 (defvar mail-source-fetcher-alist | |
381 '((file mail-source-fetch-file) | |
382 (directory mail-source-fetch-directory) | |
383 (pop mail-source-fetch-pop) | |
384 (maildir mail-source-fetch-maildir) | |
385 (imap mail-source-fetch-imap) | |
386 (webmail mail-source-fetch-webmail)) | |
387 "A mapping from source type to fetcher function.") | |
388 | |
389 (defvar mail-source-password-cache nil) | |
390 | |
391 (defvar mail-source-plugged t) | |
392 | |
393 ;;; Functions | |
394 | |
395 (eval-and-compile | |
396 (defun mail-source-strip-keyword (keyword) | |
397 "Strip the leading colon off the KEYWORD." | |
398 (intern (substring (symbol-name keyword) 1)))) | |
399 | |
400 (eval-and-compile | |
401 (defun mail-source-bind-1 (type) | |
402 (let* ((defaults (cdr (assq type mail-source-keyword-map))) | |
403 default bind) | |
404 (while (setq default (pop defaults)) | |
405 (push (list (mail-source-strip-keyword (car default)) | |
406 nil) | |
407 bind)) | |
408 bind))) | |
409 | |
410 (defmacro mail-source-bind (type-source &rest body) | |
411 "Return a `let' form that binds all variables in source TYPE. | |
412 TYPE-SOURCE is a list where the first element is the TYPE, and | |
413 the second variable is the SOURCE. | |
414 At run time, the mail source specifier SOURCE will be inspected, | |
415 and the variables will be set according to it. Variables not | |
416 specified will be given default values. | |
417 | |
418 After this is done, BODY will be executed in the scope | |
419 of the `let' form. | |
420 | |
421 The variables bound and their default values are described by | |
422 the `mail-source-keyword-map' variable." | |
423 `(let ,(mail-source-bind-1 (car type-source)) | |
424 (mail-source-set-1 ,(cadr type-source)) | |
425 ,@body)) | |
426 | |
427 (put 'mail-source-bind 'lisp-indent-function 1) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
428 (put 'mail-source-bind 'edebug-form-spec '(sexp body)) |
31717 | 429 |
430 (defun mail-source-set-1 (source) | |
431 (let* ((type (pop source)) | |
432 (defaults (cdr (assq type mail-source-keyword-map))) | |
433 default value keyword) | |
434 (while (setq default (pop defaults)) | |
435 (set (mail-source-strip-keyword (setq keyword (car default))) | |
436 (if (setq value (plist-get source keyword)) | |
437 (mail-source-value value) | |
438 (mail-source-value (cadr default))))))) | |
439 | |
440 (eval-and-compile | |
441 (defun mail-source-bind-common-1 () | |
442 (let* ((defaults mail-source-common-keyword-map) | |
443 default bind) | |
444 (while (setq default (pop defaults)) | |
445 (push (list (mail-source-strip-keyword (car default)) | |
446 nil) | |
447 bind)) | |
448 bind))) | |
449 | |
450 (defun mail-source-set-common-1 (source) | |
451 (let* ((type (pop source)) | |
452 (defaults mail-source-common-keyword-map) | |
453 (defaults-1 (cdr (assq type mail-source-keyword-map))) | |
454 default value keyword) | |
455 (while (setq default (pop defaults)) | |
456 (set (mail-source-strip-keyword (setq keyword (car default))) | |
457 (if (setq value (plist-get source keyword)) | |
458 (mail-source-value value) | |
459 (if (setq value (assq keyword defaults-1)) | |
460 (mail-source-value (cadr value)) | |
461 (mail-source-value (cadr default)))))))) | |
462 | |
463 (defmacro mail-source-bind-common (source &rest body) | |
464 "Return a `let' form that binds all common variables. | |
465 See `mail-source-bind'." | |
466 `(let ,(mail-source-bind-common-1) | |
467 (mail-source-set-common-1 source) | |
468 ,@body)) | |
469 | |
470 (put 'mail-source-bind-common 'lisp-indent-function 1) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
471 (put 'mail-source-bind-common 'edebug-form-spec '(sexp body)) |
31717 | 472 |
473 (defun mail-source-value (value) | |
474 "Return the value of VALUE." | |
475 (cond | |
476 ;; String | |
477 ((stringp value) | |
478 value) | |
479 ;; Function | |
480 ((and (listp value) | |
481 (functionp (car value))) | |
482 (eval value)) | |
483 ;; Just return the value. | |
484 (t | |
485 value))) | |
486 | |
487 (defun mail-source-fetch (source callback) | |
488 "Fetch mail from SOURCE and call CALLBACK zero or more times. | |
489 CALLBACK will be called with the name of the file where (some of) | |
490 the mail from SOURCE is put. | |
491 Return the number of files that were found." | |
492 (mail-source-bind-common source | |
493 (if (or mail-source-plugged plugged) | |
494 (save-excursion | |
495 (let ((function (cadr (assq (car source) mail-source-fetcher-alist))) | |
496 (found 0)) | |
497 (unless function | |
498 (error "%S is an invalid mail source specification" source)) | |
499 ;; If there's anything in the crash box, we do it first. | |
500 (when (file-exists-p mail-source-crash-box) | |
501 (message "Processing mail from %s..." mail-source-crash-box) | |
502 (setq found (mail-source-callback | |
503 callback mail-source-crash-box))) | |
504 (+ found | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
505 (if (or debug-on-quit debug-on-error) |
31717 | 506 (funcall function source callback) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
507 (condition-case err |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
508 (funcall function source callback) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
509 (error |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
510 (if (and (not mail-source-ignore-errors) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
511 (not |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
512 (yes-or-no-p |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
513 (format "Mail source %s error (%s). Continue? " |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
514 (if (memq ':password source) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
515 (let ((s (copy-sequence source))) |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
57581
diff
changeset
|
516 (setcar (cdr (memq ':password s)) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
517 "********") |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
518 s) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
519 source) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
520 (cadr err))))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
521 (error "Cannot get new mail")) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
522 0))))))))) |
31717 | 523 |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
524 (defun mail-source-delete-old-incoming (&optional age confirm) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
525 "Remove incoming files older than AGE days. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
526 If CONFIRM is non-nil, ask for confirmation before removing a file." |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
527 (interactive "P") |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
528 (let* ((high2days (/ 65536.0 60 60 24));; convert high bits to days |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
529 (low2days (/ 1.0 65536.0)) ;; convert low bits to days |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
530 (diff (if (natnump age) age 30));; fallback, if no valid AGE given |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
531 currday files) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
532 (setq files (directory-files |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
533 mail-source-directory t |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
534 (concat mail-source-incoming-file-prefix "*")) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
535 currday (* (car (current-time)) high2days) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
536 currday (+ currday (* low2days (nth 1 (current-time))))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
537 (while files |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
538 (let* ((ffile (car files)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
539 (bfile (gnus-replace-in-string |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
540 ffile "\\`.*/\\([^/]+\\)\\'" "\\1")) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
541 (filetime (nth 5 (file-attributes ffile))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
542 (fileday (* (car filetime) high2days)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
543 (fileday (+ fileday (* low2days (nth 1 filetime))))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
544 (setq files (cdr files)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
545 (when (and (> (- currday fileday) diff) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
546 (gnus-message 8 "File `%s' is older than %s day(s)" |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
547 bfile diff) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
548 (or (not confirm) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
549 (y-or-n-p (concat "Remove file `" bfile "'? ")))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
550 (delete-file ffile)))))) |
31717 | 551 |
552 (defun mail-source-callback (callback info) | |
553 "Call CALLBACK on the mail file, and then remove the mail file. | |
554 Pass INFO on to CALLBACK." | |
555 (if (or (not (file-exists-p mail-source-crash-box)) | |
556 (zerop (nth 7 (file-attributes mail-source-crash-box)))) | |
557 (progn | |
558 (when (file-exists-p mail-source-crash-box) | |
559 (delete-file mail-source-crash-box)) | |
560 0) | |
561 (prog1 | |
562 (funcall callback mail-source-crash-box info) | |
563 (when (file-exists-p mail-source-crash-box) | |
564 ;; Delete or move the incoming mail out of the way. | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
565 (if (eq mail-source-delete-incoming t) |
31717 | 566 (delete-file mail-source-crash-box) |
567 (let ((incoming | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
568 (mm-make-temp-file |
31717 | 569 (expand-file-name |
570 mail-source-incoming-file-prefix | |
571 mail-source-directory)))) | |
572 (unless (file-exists-p (file-name-directory incoming)) | |
573 (make-directory (file-name-directory incoming) t)) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
574 (rename-file mail-source-crash-box incoming t) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
575 ;; remove old incoming files? |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
576 (when (natnump mail-source-delete-incoming) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
577 (mail-source-delete-old-incoming |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
578 mail-source-delete-incoming |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
579 mail-source-delete-old-incoming-confirm)))))))) |
31717 | 580 |
581 (defun mail-source-movemail (from to) | |
582 "Move FROM to TO using movemail." | |
583 (if (not (file-writable-p to)) | |
584 (error "Can't write to crash box %s. Not moving mail" to) | |
585 (let ((to (file-truename (expand-file-name to))) | |
586 errors result) | |
587 (setq to (file-truename to) | |
588 from (file-truename from)) | |
589 ;; Set TO if have not already done so, and rename or copy | |
590 ;; the file FROM to TO if and as appropriate. | |
591 (cond | |
592 ((file-exists-p to) | |
593 ;; The crash box exists already. | |
594 t) | |
595 ((not (file-exists-p from)) | |
596 ;; There is no inbox. | |
597 (setq to nil)) | |
598 ((zerop (nth 7 (file-attributes from))) | |
599 ;; Empty file. | |
600 (setq to nil)) | |
601 (t | |
602 ;; If getting from mail spool directory, use movemail to move | |
603 ;; rather than just renaming, so as to interlock with the | |
604 ;; mailer. | |
605 (unwind-protect | |
606 (save-excursion | |
607 (setq errors (generate-new-buffer " *mail source loss*")) | |
608 (let ((default-directory "/")) | |
609 (setq result | |
610 (apply | |
611 'call-process | |
612 (append | |
613 (list | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
614 (or mail-source-movemail-program |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
615 (expand-file-name "movemail" exec-directory)) |
31717 | 616 nil errors nil from to))))) |
617 (when (file-exists-p to) | |
618 (set-file-modes to mail-source-default-file-modes)) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
619 (if (and (or (not (buffer-modified-p errors)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
620 (zerop (buffer-size errors))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
621 (and (numberp result) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
622 (zerop result))) |
31717 | 623 ;; No output => movemail won. |
624 t | |
625 (set-buffer errors) | |
626 ;; There may be a warning about older revisions. We | |
627 ;; ignore that. | |
628 (goto-char (point-min)) | |
629 (if (search-forward "older revision" nil t) | |
630 t | |
631 ;; Probably a real error. | |
632 (subst-char-in-region (point-min) (point-max) ?\n ?\ ) | |
633 (goto-char (point-max)) | |
634 (skip-chars-backward " \t") | |
635 (delete-region (point) (point-max)) | |
636 (goto-char (point-min)) | |
637 (when (looking-at "movemail: ") | |
638 (delete-region (point-min) (match-end 0))) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
639 ;; Result may be a signal description string. |
31717 | 640 (unless (yes-or-no-p |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
641 (format "movemail: %s (%s return). Continue? " |
31717 | 642 (buffer-string) result)) |
643 (error "%s" (buffer-string))) | |
644 (setq to nil))))))) | |
645 (when (and errors | |
646 (buffer-name errors)) | |
647 (kill-buffer errors)) | |
648 ;; Return whether we moved successfully or not. | |
649 to))) | |
650 | |
651 (defun mail-source-movemail-and-remove (from to) | |
652 "Move FROM to TO using movemail, then remove FROM if empty." | |
653 (or (not (mail-source-movemail from to)) | |
654 (not (zerop (nth 7 (file-attributes from)))) | |
655 (delete-file from))) | |
656 | |
657 (defun mail-source-fetch-with-program (program) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
658 (eq 0 (call-process shell-file-name nil nil nil |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
659 shell-command-switch program))) |
31717 | 660 |
661 (defun mail-source-run-script (script spec &optional delay) | |
662 (when script | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
663 (if (functionp script) |
31717 | 664 (funcall script) |
665 (mail-source-call-script | |
666 (format-spec script spec)))) | |
667 (when delay | |
668 (sleep-for delay))) | |
669 | |
670 (defun mail-source-call-script (script) | |
671 (let ((background nil)) | |
672 (when (string-match "& *$" script) | |
673 (setq script (substring script 0 (match-beginning 0)) | |
674 background 0)) | |
675 (call-process shell-file-name nil background nil | |
676 shell-command-switch script))) | |
677 | |
678 ;;; | |
679 ;;; Different fetchers | |
680 ;;; | |
681 | |
682 (defun mail-source-fetch-file (source callback) | |
683 "Fetcher for single-file sources." | |
684 (mail-source-bind (file source) | |
685 (mail-source-run-script | |
686 prescript (format-spec-make ?t mail-source-crash-box) | |
687 prescript-delay) | |
688 (let ((mail-source-string (format "file:%s" path))) | |
689 (if (mail-source-movemail path mail-source-crash-box) | |
690 (prog1 | |
691 (mail-source-callback callback path) | |
692 (mail-source-run-script | |
693 postscript (format-spec-make ?t mail-source-crash-box))) | |
694 0)))) | |
695 | |
696 (defun mail-source-fetch-directory (source callback) | |
697 "Fetcher for directory sources." | |
698 (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
|
699 (mail-source-run-script |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
700 prescript (format-spec-make ?t path) prescript-delay) |
31717 | 701 (let ((found 0) |
702 (mail-source-string (format "directory:%s" path))) | |
703 (dolist (file (directory-files | |
704 path t (concat (regexp-quote suffix) "$"))) | |
705 (when (and (file-regular-p file) | |
706 (funcall predicate file) | |
707 (mail-source-movemail file mail-source-crash-box)) | |
708 (incf found (mail-source-callback callback file)))) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
709 (mail-source-run-script postscript (format-spec-make ?t path)) |
31717 | 710 found))) |
711 | |
712 (defun mail-source-fetch-pop (source callback) | |
713 "Fetcher for single-file sources." | |
714 (mail-source-bind (pop source) | |
715 (mail-source-run-script | |
716 prescript | |
717 (format-spec-make ?p password ?t mail-source-crash-box | |
718 ?s server ?P port ?u user) | |
719 prescript-delay) | |
720 (let ((from (format "%s:%s:%s" server user port)) | |
721 (mail-source-string (format "pop:%s@%s" user server)) | |
722 result) | |
723 (when (eq authentication 'password) | |
724 (setq password | |
725 (or password | |
726 (cdr (assoc from mail-source-password-cache)) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
727 (read-passwd |
31717 | 728 (format "Password for %s at %s: " user server))))) |
729 (when server | |
730 (setenv "MAILHOST" server)) | |
731 (setq result | |
732 (cond | |
733 (program | |
734 (mail-source-fetch-with-program | |
735 (format-spec | |
736 program | |
737 (format-spec-make ?p password ?t mail-source-crash-box | |
738 ?s server ?P port ?u user)))) | |
739 (function | |
740 (funcall function mail-source-crash-box)) | |
741 ;; The default is to use pop3.el. | |
742 (t | |
66299
01b85ec4a61d
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-615
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
743 (require 'pop3) |
31717 | 744 (let ((pop3-password password) |
745 (pop3-maildrop user) | |
746 (pop3-mailhost server) | |
747 (pop3-port port) | |
748 (pop3-authentication-scheme | |
749 (if (eq authentication 'apop) 'apop 'pass))) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
750 (if (or debug-on-quit debug-on-error) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
751 (save-excursion (pop3-movemail mail-source-crash-box)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
752 (condition-case err |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
753 (save-excursion (pop3-movemail mail-source-crash-box)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
754 (error |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
755 ;; We nix out the password in case the error |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
756 ;; was because of a wrong password being given. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
757 (setq mail-source-password-cache |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
758 (delq (assoc from mail-source-password-cache) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
759 mail-source-password-cache)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
760 (signal (car err) (cdr err))))))))) |
31717 | 761 (if result |
762 (progn | |
763 (when (eq authentication 'password) | |
764 (unless (assoc from mail-source-password-cache) | |
765 (push (cons from password) mail-source-password-cache))) | |
766 (prog1 | |
767 (mail-source-callback callback server) | |
768 ;; Update display-time's mail flag, if relevant. | |
769 (if (equal source mail-source-primary-source) | |
770 (setq mail-source-new-mail-available nil)) | |
771 (mail-source-run-script | |
772 postscript | |
773 (format-spec-make ?p password ?t mail-source-crash-box | |
774 ?s server ?P port ?u user)))) | |
775 ;; We nix out the password in case the error | |
776 ;; was because of a wrong password being given. | |
777 (setq mail-source-password-cache | |
778 (delq (assoc from mail-source-password-cache) | |
779 mail-source-password-cache)) | |
780 0)))) | |
781 | |
782 (defun mail-source-check-pop (source) | |
783 "Check whether there is new mail." | |
784 (mail-source-bind (pop source) | |
785 (let ((from (format "%s:%s:%s" server user port)) | |
786 (mail-source-string (format "pop:%s@%s" user server)) | |
787 result) | |
788 (when (eq authentication 'password) | |
789 (setq password | |
790 (or password | |
791 (cdr (assoc from mail-source-password-cache)) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
792 (read-passwd |
31717 | 793 (format "Password for %s at %s: " user server)))) |
794 (unless (assoc from mail-source-password-cache) | |
795 (push (cons from password) mail-source-password-cache))) | |
796 (when server | |
797 (setenv "MAILHOST" server)) | |
798 (setq result | |
799 (cond | |
800 ;; No easy way to check whether mail is waiting for these. | |
801 (program) | |
802 (function) | |
803 ;; The default is to use pop3.el. | |
804 (t | |
66299
01b85ec4a61d
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-615
Miles Bader <miles@gnu.org>
parents:
64754
diff
changeset
|
805 (require 'pop3) |
31717 | 806 (let ((pop3-password password) |
807 (pop3-maildrop user) | |
808 (pop3-mailhost server) | |
809 (pop3-port port) | |
810 (pop3-authentication-scheme | |
811 (if (eq authentication 'apop) 'apop 'pass))) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
812 (if (or debug-on-quit debug-on-error) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
813 (save-excursion (pop3-get-message-count)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
814 (condition-case err |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
815 (save-excursion (pop3-get-message-count)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
816 (error |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
817 ;; We nix out the password in case the error |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
818 ;; was because of a wrong password being given. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
819 (setq mail-source-password-cache |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
820 (delq (assoc from mail-source-password-cache) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
821 mail-source-password-cache)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
822 (signal (car err) (cdr err))))))))) |
31717 | 823 (if result |
824 ;; Inform display-time that we have new mail. | |
825 (setq mail-source-new-mail-available (> result 0)) | |
826 ;; We nix out the password in case the error | |
827 ;; was because of a wrong password being given. | |
828 (setq mail-source-password-cache | |
829 (delq (assoc from mail-source-password-cache) | |
830 mail-source-password-cache))) | |
831 result))) | |
832 | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
833 (defun mail-source-touch-pop () |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
834 "Open and close a POP connection shortly. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
835 POP server should be defined in `mail-source-primary-source' (which is |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
836 preferred) or `mail-sources'. You may use it for the POP-before-SMTP |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
837 authentication. To do that, you need to set the |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
838 `message-send-mail-function' variable as `message-smtpmail-send-it' |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
839 and put the following line in your ~/.gnus.el file: |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
840 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
841 \(add-hook 'message-send-mail-hook 'mail-source-touch-pop) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
842 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
843 See the Gnus manual for details." |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
844 (let ((sources (if mail-source-primary-source |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
845 (list mail-source-primary-source) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
846 mail-sources))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
847 (while sources |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
848 (if (eq 'pop (car (car sources))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
849 (mail-source-check-pop (car sources))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
850 (setq sources (cdr sources))))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
851 |
31717 | 852 (defun mail-source-new-mail-p () |
853 "Handler for `display-time' to indicate when new mail is available." | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
854 ;; Flash (ie. ring the visible bell) if mail is available. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
855 (if (and mail-source-flash mail-source-new-mail-available) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
856 (let ((visible-bell t)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
857 (ding))) |
31717 | 858 ;; Only report flag setting; flag is updated on a different schedule. |
859 mail-source-new-mail-available) | |
860 | |
861 | |
862 (defvar mail-source-report-new-mail nil) | |
863 (defvar mail-source-report-new-mail-timer nil) | |
864 (defvar mail-source-report-new-mail-idle-timer nil) | |
865 | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
44075
diff
changeset
|
866 (eval-when-compile |
32333 | 867 (if (featurep 'xemacs) |
60696
7503b2a24a3c
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-187
Miles Bader <miles@gnu.org>
parents:
59996
diff
changeset
|
868 (require 'timer-funcs) |
32333 | 869 (require 'timer))) |
31717 | 870 |
871 (defun mail-source-start-idle-timer () | |
872 ;; Start our idle timer if necessary, so we delay the check until the | |
873 ;; user isn't typing. | |
874 (unless mail-source-report-new-mail-idle-timer | |
875 (setq mail-source-report-new-mail-idle-timer | |
876 (run-with-idle-timer | |
877 mail-source-idle-time-delay | |
878 nil | |
879 (lambda () | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
880 (unwind-protect |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
881 (mail-source-check-pop mail-source-primary-source) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
882 (setq mail-source-report-new-mail-idle-timer nil))))) |
31717 | 883 ;; Since idle timers created when Emacs is already in the idle |
884 ;; state don't get activated until Emacs _next_ becomes idle, we | |
885 ;; need to force our timer to be considered active now. We do | |
886 ;; this by being naughty and poking the timer internals directly | |
887 ;; (element 0 of the vector is nil if the timer is active). | |
888 (aset mail-source-report-new-mail-idle-timer 0 nil))) | |
889 | |
890 (defun mail-source-report-new-mail (arg) | |
891 "Toggle whether to report when new mail is available. | |
892 This only works when `display-time' is enabled." | |
893 (interactive "P") | |
894 (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
|
895 (error "Need to set `mail-source-primary-source' to check for new mail")) |
31717 | 896 (let ((on (if (null arg) |
897 (not mail-source-report-new-mail) | |
898 (> (prefix-numeric-value arg) 0)))) | |
899 (setq mail-source-report-new-mail on) | |
900 (and mail-source-report-new-mail-timer | |
32102 | 901 (nnheader-cancel-timer mail-source-report-new-mail-timer)) |
31717 | 902 (and mail-source-report-new-mail-idle-timer |
32102 | 903 (nnheader-cancel-timer mail-source-report-new-mail-idle-timer)) |
31717 | 904 (setq mail-source-report-new-mail-timer nil) |
905 (setq mail-source-report-new-mail-idle-timer nil) | |
906 (if on | |
907 (progn | |
908 (require 'time) | |
31764 | 909 ;; display-time-mail-function is an Emacs 21 feature. |
31717 | 910 (setq display-time-mail-function #'mail-source-new-mail-p) |
911 ;; Set up the main timer. | |
912 (setq mail-source-report-new-mail-timer | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
913 (nnheader-run-at-time |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
914 (* 60 mail-source-report-new-mail-interval) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
915 (* 60 mail-source-report-new-mail-interval) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
916 #'mail-source-start-idle-timer)) |
31717 | 917 ;; When you get new mail, clear "Mail" from the mode line. |
918 (add-hook 'nnmail-post-get-new-mail-hook | |
919 'display-time-event-handler) | |
920 (message "Mail check enabled")) | |
921 (setq display-time-mail-function nil) | |
922 (remove-hook 'nnmail-post-get-new-mail-hook | |
923 'display-time-event-handler) | |
924 (message "Mail check disabled")))) | |
925 | |
926 (defun mail-source-fetch-maildir (source callback) | |
927 "Fetcher for maildir sources." | |
928 (mail-source-bind (maildir source) | |
929 (let ((found 0) | |
930 mail-source-string) | |
931 (unless (string-match "/$" path) | |
932 (setq path (concat path "/"))) | |
933 (dolist (subdir subdirs) | |
934 (when (file-directory-p (concat path subdir)) | |
935 (setq mail-source-string (format "maildir:%s%s" path subdir)) | |
936 (dolist (file (directory-files (concat path subdir) t)) | |
937 (when (and (not (file-directory-p file)) | |
938 (not (if function | |
939 (funcall function file mail-source-crash-box) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
44075
diff
changeset
|
940 (let ((coding-system-for-write |
31717 | 941 mm-text-coding-system) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
44075
diff
changeset
|
942 (coding-system-for-read |
31717 | 943 mm-text-coding-system)) |
944 (with-temp-file mail-source-crash-box | |
945 (insert-file-contents file) | |
946 (goto-char (point-min)) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
947 ;;; ;; Unix mail format |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
948 ;;; (unless (looking-at "\n*From ") |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
949 ;;; (insert "From maildir " |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
950 ;;; (current-time-string) "\n")) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
951 ;;; (while (re-search-forward "^From " nil t) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
952 ;;; (replace-match ">From ")) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
953 ;;; (goto-char (point-max)) |
32333 | 954 ;;; (insert "\n\n") |
31717 | 955 ;; MMDF mail format |
32333 | 956 (insert "\001\001\001\001\n")) |
31717 | 957 (delete-file file))))) |
958 (incf found (mail-source-callback callback file)))))) | |
959 found))) | |
960 | |
961 (eval-and-compile | |
962 (autoload 'imap-open "imap") | |
963 (autoload 'imap-authenticate "imap") | |
964 (autoload 'imap-mailbox-select "imap") | |
965 (autoload 'imap-mailbox-unselect "imap") | |
966 (autoload 'imap-mailbox-close "imap") | |
967 (autoload 'imap-search "imap") | |
968 (autoload 'imap-fetch "imap") | |
969 (autoload 'imap-close "imap") | |
970 (autoload 'imap-error-text "imap") | |
971 (autoload 'imap-message-flags-add "imap") | |
972 (autoload 'imap-list-to-message-set "imap") | |
32102 | 973 (autoload 'imap-range-to-message-set "imap") |
31717 | 974 (autoload 'nnheader-ms-strip-cr "nnheader")) |
975 | |
32102 | 976 (defvar mail-source-imap-file-coding-system 'binary |
977 "Coding system for the crashbox made by `mail-source-fetch-imap'.") | |
978 | |
31717 | 979 (defun mail-source-fetch-imap (source callback) |
980 "Fetcher for imap sources." | |
981 (mail-source-bind (imap source) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
982 (mail-source-run-script |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
983 prescript (format-spec-make ?p password ?t mail-source-crash-box |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
984 ?s server ?P port ?u user) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
985 prescript-delay) |
31717 | 986 (let ((from (format "%s:%s:%s" server user port)) |
987 (found 0) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
988 (buf (generate-new-buffer " *imap source*")) |
31717 | 989 (mail-source-string (format "imap:%s:%s" server mailbox)) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
990 (imap-shell-program (or (list program) imap-shell-program)) |
31717 | 991 remove) |
992 (if (and (imap-open server port stream authentication buf) | |
993 (imap-authenticate | |
994 user (or (cdr (assoc from mail-source-password-cache)) | |
995 password) buf) | |
996 (imap-mailbox-select mailbox nil buf)) | |
32918 | 997 (let ((coding-system-for-write mail-source-imap-file-coding-system) |
32333 | 998 str) |
31717 | 999 (with-temp-file mail-source-crash-box |
32918 | 1000 ;; Avoid converting 8-bit chars from inserted strings to |
1001 ;; multibyte. | |
1002 (mm-disable-multibyte) | |
31717 | 1003 ;; remember password |
1004 (with-current-buffer buf | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
1005 (when (and imap-password |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
1006 (not (assoc from mail-source-password-cache))) |
31717 | 1007 (push (cons from imap-password) mail-source-password-cache))) |
1008 ;; if predicate is nil, use all uids | |
1009 (dolist (uid (imap-search (or predicate "1:*") buf)) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
1010 (when (setq str |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
1011 (if (imap-capability 'IMAP4rev1 buf) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
1012 (caddar (imap-fetch uid "BODY.PEEK[]" |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
1013 'BODYDETAIL nil buf)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
1014 (imap-fetch uid "RFC822.PEEK" 'RFC822 nil buf))) |
31717 | 1015 (push uid remove) |
1016 (insert "From imap " (current-time-string) "\n") | |
1017 (save-excursion | |
1018 (insert str "\n\n")) | |
1019 (while (re-search-forward "^From " nil t) | |
1020 (replace-match ">From ")) | |
1021 (goto-char (point-max)))) | |
1022 (nnheader-ms-strip-cr)) | |
1023 (incf found (mail-source-callback callback server)) | |
1024 (when (and remove fetchflag) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
1025 (setq remove (nreverse remove)) |
31717 | 1026 (imap-message-flags-add |
32102 | 1027 (imap-range-to-message-set (gnus-compress-sequence remove)) |
1028 fetchflag nil buf)) | |
31717 | 1029 (if dontexpunge |
1030 (imap-mailbox-unselect buf) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
1031 (imap-mailbox-close nil buf)) |
31717 | 1032 (imap-close buf)) |
1033 (imap-close buf) | |
1034 ;; We nix out the password in case the error | |
1035 ;; was because of a wrong password being given. | |
1036 (setq mail-source-password-cache | |
1037 (delq (assoc from mail-source-password-cache) | |
1038 mail-source-password-cache)) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
1039 (error "IMAP error: %s" (imap-error-text buf))) |
31717 | 1040 (kill-buffer buf) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
1041 (mail-source-run-script |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
1042 postscript |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
1043 (format-spec-make ?p password ?t mail-source-crash-box |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
1044 ?s server ?P port ?u user)) |
31717 | 1045 found))) |
1046 | |
1047 (eval-and-compile | |
1048 (autoload 'webmail-fetch "webmail")) | |
1049 | |
1050 (defun mail-source-fetch-webmail (source callback) | |
1051 "Fetch for webmail source." | |
1052 (mail-source-bind (webmail source) | |
1053 (let ((mail-source-string (format "webmail:%s:%s" subtype user)) | |
1054 (webmail-newmail-only dontexpunge) | |
1055 (webmail-move-to-trash-can (not dontexpunge))) | |
1056 (when (eq authentication 'password) | |
1057 (setq password | |
1058 (or password | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
44075
diff
changeset
|
1059 (cdr (assoc (format "webmail:%s:%s" subtype user) |
31717 | 1060 mail-source-password-cache)) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
1061 (read-passwd |
31717 | 1062 (format "Password for %s at %s: " user subtype)))) |
1063 (when (and password | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
44075
diff
changeset
|
1064 (not (assoc (format "webmail:%s:%s" subtype user) |
31717 | 1065 mail-source-password-cache))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
44075
diff
changeset
|
1066 (push (cons (format "webmail:%s:%s" subtype user) password) |
31717 | 1067 mail-source-password-cache))) |
1068 (webmail-fetch mail-source-crash-box subtype user password) | |
1069 (mail-source-callback callback (symbol-name subtype))))) | |
1070 | |
1071 (provide 'mail-source) | |
1072 | |
52401 | 1073 ;;; arch-tag: 72948025-1d17-4d6c-bb12-ef1aa2c490fd |
31717 | 1074 ;;; mail-source.el ends here |