annotate lisp/url/url-imap.el @ 108701:126aa20e97d5

Fix C-e when bidi reordering is in effect. simple.el (move-end-of-line): Make sure we are at line beginning before backing up to end of previous line.
author Eli Zaretskii <eliz@gnu.org>
date Wed, 19 May 2010 20:16:07 +0300
parents 1d1d5d9bd884
children 376148b31b5e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
54695
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1 ;;; url-imap.el --- IMAP retrieval routines
57612
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 54770
diff changeset
2
106815
1d1d5d9bd884 Add 2010 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 105829
diff changeset
3 ;; Copyright (C) 1999, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
57612
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 54770
diff changeset
4
54695
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
5 ;; Author: Simon Josefsson <jas@pdc.kth.se>
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
6 ;; Keywords: comm, data, processes
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
7
57612
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 54770
diff changeset
8 ;; This file is part of GNU Emacs.
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 54770
diff changeset
9
94668
8259d0d8e107 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
57612
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 54770
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
94668
8259d0d8e107 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
12 ;; the Free Software Foundation, either version 3 of the License, or
8259d0d8e107 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
13 ;; (at your option) any later version.
57612
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 54770
diff changeset
14
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 54770
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 54770
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 54770
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 54770
diff changeset
18 ;; GNU General Public License for more details.
54695
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
19
57612
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 54770
diff changeset
20 ;; You should have received a copy of the GNU General Public License
94668
8259d0d8e107 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
57612
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 54770
diff changeset
22
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 54770
diff changeset
23 ;;; Commentary:
54695
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
24
57612
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 54770
diff changeset
25 ;; Anyway, here's a teaser. It's quite broken in lots of regards, but at
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 54770
diff changeset
26 ;; least it seem to work. At least a little. At least when called
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 54770
diff changeset
27 ;; manually like this (I've no idea how it's supposed to be called):
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 54770
diff changeset
28
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 54770
diff changeset
29 ;; (url-imap (url-generic-parse-url "imap://cyrus.andrew.cmu.edu/archive.c-client;UID=1021"))
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 54770
diff changeset
30
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 54770
diff changeset
31 ;;; Code:
54695
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
32
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
33 (require 'url-util)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
34 (require 'url-parse)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
35 (require 'nnimap)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
36 (require 'mm-util)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
37
96486
7369ded3b436 Typo and docstring fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 94668
diff changeset
38 (defconst url-imap-default-port 143 "Default IMAP port.")
54695
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
39
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
40 (defun url-imap-open-host (host port user pass)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
41 ;; xxx use user and password
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
42 (if (fboundp 'nnheader-init-server-buffer)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
43 (nnheader-init-server-buffer))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
44 (let ((imap-username user)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
45 (imap-password pass)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
46 (authenticator (if user 'login 'anonymous)))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
47 (nnimap-open-server host
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
48 `((nnimap-server-port ,port)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
49 (nnimap-stream 'network)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
50 (nnimap-authenticator ,authenticator)))))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
51
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
52 (defun url-imap (url)
86950
fed682f20285 (top-level): Don't require cl when compiling.
Glenn Morris <rgm@gnu.org>
parents: 78222
diff changeset
53 (unless (vectorp url)
fed682f20285 (top-level): Don't require cl when compiling.
Glenn Morris <rgm@gnu.org>
parents: 78222
diff changeset
54 (signal 'wrong-type-error (list "Need a pre-parsed URL." url)))
105829
328150f0cf76 * url-util.el (url-insert-entities-in-string):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 100908
diff changeset
55 (with-current-buffer (generate-new-buffer " *url-imap*")
54695
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
56 (mm-disable-multibyte)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
57 (let* ((host (url-host url))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
58 (port (url-port url))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
59 ;; xxx decode mailbox (see rfc2192)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
60 (mailbox (url-filename url))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
61 (coding-system-for-read 'binary))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
62 (and (eq (string-to-char mailbox) ?/)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
63 (setq mailbox (substring mailbox 1)))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
64 (url-imap-open-host host port (url-user url) (url-password url))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
65 (cond ((assoc "TYPE" (url-attributes url))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
66 ;; xxx list mailboxes (start gnus?)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
67 )
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
68 ((assoc "UID" (url-attributes url))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
69 ;; fetch message part
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
70 ;; xxx handle partial fetches
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
71 (insert "Content-type: message/rfc822\n\n")
96486
7369ded3b436 Typo and docstring fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 94668
diff changeset
72 (nnimap-request-article (cdr (assoc "UID" (url-attributes url)))
54695
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
73 mailbox host (current-buffer)))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
74 (t
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
75 ;; xxx list messages in mailbox (start gnus?)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
76 )))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
77 (current-buffer)))
54699
7784ae10206d Resolve CVS conflicts
Miles Bader <miles@gnu.org>
parents: 54695
diff changeset
78
93975
1e3a407766b9 Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
79 ;; arch-tag: 034991ff-5425-48ea-b911-c96c90e6f47d
57612
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 54770
diff changeset
80 ;;; url-imap.el ends here