Mercurial > emacs
annotate lisp/net/imap-hash.el @ 110563:5b5c2cab9a6a
Merge changes made in Gnus.tranck
gnus-art.el: Remove useless gnus-treat-translate.
gnus-gravatar.el (gnus-gravatar-transform-address): Use gnus-gravatar-size.
gnus.el: Remove useless gnus-local-domain.
mml-smime.el: Remove useless mml-smime-verbose.
mml2015.el: Remove useless mml2015-verbose.
author | Katsumi Yamaoka <yamaoka@jpl.org> |
---|---|
date | Sat, 25 Sep 2010 12:49:02 +0000 |
parents | 1d1d5d9bd884 |
children | 376148b31b5e |
rev | line source |
---|---|
105223
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
1 ;;; imap-hash.el --- Hashtable-like interface to an IMAP mailbox |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
2 |
106815 | 3 ;; Copyright (C) 2009, 2010 Free Software Foundation, Inc. |
105223
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
4 |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
5 ;; Author: Teodor Zlatanov <tzz@lifelogs.com> |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
6 ;; Keywords: mail |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
7 |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
8 ;; This program is free software; you can redistribute it and/or modify |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
9 ;; it under the terms of the GNU General Public License as published by |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
10 ;; the Free Software Foundation, either version 3 of the License, or |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
11 ;; (at your option) any later version. |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
12 |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
13 ;; This program is distributed in the hope that it will be useful, |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
16 ;; GNU General Public License for more details. |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
17 |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
18 ;; You should have received a copy of the GNU General Public License |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
19 ;; along with this program. If not, see <http://www.gnu.org/licenses/>. |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
20 |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
21 ;;; Commentary: |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
22 |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
23 ;; This module provides hashtable-like functions on top of imap.el |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
24 ;; functionality. All the authentication is handled by auth-source so |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
25 ;; there are no authentication options here, only the server and |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
26 ;; mailbox names are needed. |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
27 |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
28 ;; Create a IHT (imap-hash table) object with `imap-hash-make'. Then |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
29 ;; use it with `imap-hash-map' to map a function across all the |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
30 ;; messages. Use `imap-hash-get' and `imap-hash-rem' to operate on |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
31 ;; individual messages. See the tramp-imap.el library in Tramp if you |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
32 ;; need to see practical examples. |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
33 |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
34 ;; This only works with IMAP4r1. Sorry to everyone without it, but |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
35 ;; the compatibility code is too annoying and it's 2009. |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
36 |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
37 ;; TODO: Use SEARCH instead of FETCH when a test is specified. List |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
38 ;; available mailboxes. Don't select an invalid mailbox. |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
39 |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
40 ;;; Code: |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
41 |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
42 (require 'assoc) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
43 (require 'imap) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
44 (require 'sendmail) ; for mail-header-separator |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
45 (require 'message) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
46 (autoload 'auth-source-user-or-password "auth-source") |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
47 |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
48 ;; retrieve these headers |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
49 (defvar imap-hash-headers |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
50 (append '(Subject From Date Message-Id References In-Reply-To Xref))) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
51 |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
52 ;; from nnheader.el |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
53 (defsubst imap-hash-remove-cr-followed-by-lf () |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
54 (goto-char (point-max)) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
55 (while (search-backward "\r\n" nil t) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
56 (delete-char 1))) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
57 |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
58 ;; from nnheader.el |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
59 (defun imap-hash-ms-strip-cr (&optional string) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
60 "Strip ^M from the end of all lines in current buffer or STRING." |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
61 (if string |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
62 (with-temp-buffer |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
63 (insert string) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
64 (imap-hash-remove-cr-followed-by-lf) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
65 (buffer-string)) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
66 (save-excursion |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
67 (imap-hash-remove-cr-followed-by-lf)))) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
68 |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
69 (defun imap-hash-make (server port mailbox &optional user password ssl) |
106697
ac408704629c
lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents:
105377
diff
changeset
|
70 "Make a new imap-hash object using SERVER, PORT, and MAILBOX. |
ac408704629c
lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents:
105377
diff
changeset
|
71 USER, PASSWORD and SSL are optional. |
105223
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
72 The test is set to t, meaning all messages are considered." |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
73 (when (and server port mailbox) |
106697
ac408704629c
lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents:
105377
diff
changeset
|
74 (list :server server :port port :mailbox mailbox |
ac408704629c
lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents:
105377
diff
changeset
|
75 :ssl ssl :user user :password password |
105223
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
76 :test t))) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
77 |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
78 (defun imap-hash-p (iht) |
106697
ac408704629c
lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents:
105377
diff
changeset
|
79 "Check whether IHT is a valid imap-hash." |
105223
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
80 (and |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
81 (imap-hash-server iht) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
82 (imap-hash-port iht) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
83 (imap-hash-mailbox iht) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
84 (imap-hash-test iht))) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
85 |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
86 (defmacro imap-hash-gather (uid) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
87 `(imap-message-get ,uid 'BODYDETAIL)) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
88 |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
89 (defmacro imap-hash-data-body (details) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
90 `(nth 2 (nth 1 ,details))) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
91 |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
92 (defmacro imap-hash-data-headers (details) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
93 `(nth 2 (nth 0 ,details))) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
94 |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
95 (defun imap-hash-get (key iht &optional refetch) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
96 "Get the value for KEY in the imap-hash IHT. |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
97 Requires either `imap-hash-fetch' to be called beforehand |
106697
ac408704629c
lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents:
105377
diff
changeset
|
98 \(e.g. by `imap-hash-map'), or REFETCH to be t. |
105223
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
99 Returns a list of the headers (an alist, see `imap-hash-map') and |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
100 the body of the message as a string. |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
101 Also see `imap-hash-test'." |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
102 (with-current-buffer (imap-hash-get-buffer iht) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
103 (when refetch |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
104 (imap-hash-fetch iht nil key)) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
105 (let ((details (imap-hash-gather key))) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
106 (list |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
107 (imap-hash-get-headers |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
108 (imap-hash-data-headers details)) |
106697
ac408704629c
lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents:
105377
diff
changeset
|
109 (imap-hash-get-body |
105223
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
110 (imap-hash-data-body details)))))) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
111 |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
112 (defun imap-hash-put (value iht &optional key) |
106697
ac408704629c
lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents:
105377
diff
changeset
|
113 "Put VALUE in the imap-hash IHT. Return the new key. |
105223
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
114 If KEY is given, removes it. |
106697
ac408704629c
lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents:
105377
diff
changeset
|
115 VALUE can be a list of the headers (an alist, see `imap-hash-map') |
105223
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
116 and the body of the message as a string. It can also be a uid, |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
117 in which case `imap-hash-get' will be called to get the value. |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
118 Also see `imap-hash-test'." |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
119 (let ((server-buffer (imap-hash-get-buffer iht)) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
120 (value (if (listp value) value (imap-hash-get value iht))) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
121 newuid) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
122 (when value |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
123 (with-temp-buffer |
106697
ac408704629c
lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents:
105377
diff
changeset
|
124 (funcall 'imap-hash-make-message |
ac408704629c
lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents:
105377
diff
changeset
|
125 (nth 0 value) |
105223
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
126 (nth 1 value) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
127 nil) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
128 (setq newuid (nth 1 (imap-message-append |
106697
ac408704629c
lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents:
105377
diff
changeset
|
129 (imap-hash-mailbox iht) |
105223
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
130 (current-buffer) nil nil server-buffer))) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
131 (when key (imap-hash-rem key iht)))) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
132 newuid)) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
133 |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
134 (defun imap-hash-make-message (headers body &optional overrides) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
135 "Make a message with HEADERS and BODY suitable for `imap-append', |
106697
ac408704629c
lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents:
105377
diff
changeset
|
136 using `message-setup'. |
105223
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
137 Look in the alist OVERRIDES for header overrides as per `imap-hash-headers'." |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
138 ;; don't insert a signature no matter what |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
139 (let (message-signature) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
140 (message-setup |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
141 (append overrides headers)) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
142 (message-generate-headers message-required-mail-headers) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
143 (message-remove-header "X-Draft-From") |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
144 (message-goto-body) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
145 (insert (or (aget overrides 'body) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
146 body |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
147 "")) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
148 (goto-char (point-min)) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
149 ;; TODO: make this search better |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
150 (if (search-forward mail-header-separator nil t) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
151 (delete-region (line-beginning-position) (line-end-position)) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
152 (error "Could not find the body separator in the encoded message!")))) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
153 |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
154 (defun imap-hash-rem (key iht) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
155 "Remove KEY in the imap-hash IHT. |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
156 Also see `imap-hash-test'. Requires `imap-hash-fetch' to have |
106697
ac408704629c
lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents:
105377
diff
changeset
|
157 been called and the imap-hash server buffer to be current, |
105223
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
158 so it's best to use it inside `imap-hash-map'. |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
159 The key will not be found on the next `imap-hash-map' call." |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
160 (with-current-buffer (imap-hash-get-buffer iht) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
161 (imap-message-flags-add |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
162 (imap-range-to-message-set (list key)) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
163 "\\Deleted" 'silent) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
164 (imap-mailbox-expunge t))) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
165 |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
166 (defun imap-hash-clear (iht) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
167 "Remove all keys in the imap-hash IHT. |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
168 Also see `imap-hash-test'." |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
169 (imap-hash-map (lambda (uid b c) (imap-hash-rem uid iht)) iht)) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
170 |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
171 (defun imap-hash-get-headers (text-headers) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
172 (with-temp-buffer |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
173 (insert (or text-headers "")) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
174 (imap-hash-remove-cr-followed-by-lf) |
106697
ac408704629c
lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents:
105377
diff
changeset
|
175 (mapcar (lambda (header) |
105223
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
176 (cons header |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
177 (message-fetch-field (format "%s" header)))) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
178 imap-hash-headers))) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
179 |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
180 (defun imap-hash-get-body (text) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
181 (with-temp-buffer |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
182 (insert (or text "")) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
183 (imap-hash-remove-cr-followed-by-lf) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
184 (buffer-string))) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
185 |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
186 (defun imap-hash-map (function iht &optional headers-only &rest messages) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
187 "Call FUNCTION for all entries in IHT and pass it the message uid, |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
188 the headers (an alist, see `imap-hash-headers'), and the body |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
189 contents as a string. If HEADERS-ONLY is not nil, the body will be nil. |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
190 Returns results of evaluating, as would `mapcar'. |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
191 If MESSAGES are given, iterate only over those UIDs. |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
192 Also see `imap-hash-test'." |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
193 (imap-hash-fetch iht headers-only) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
194 (let ((test (imap-hash-test iht))) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
195 (with-current-buffer (imap-hash-get-buffer iht) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
196 (delq nil |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
197 (imap-message-map (lambda (message ignored-parameter) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
198 (let* ((details (imap-hash-gather message)) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
199 (headers (imap-hash-data-headers details)) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
200 (hlist (imap-hash-get-headers headers)) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
201 (runit (cond |
106697
ac408704629c
lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents:
105377
diff
changeset
|
202 ((stringp test) |
105223
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
203 (string-match |
106697
ac408704629c
lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents:
105377
diff
changeset
|
204 test |
105223
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
205 (format "%s" (aget hlist 'Subject)))) |
106697
ac408704629c
lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents:
105377
diff
changeset
|
206 ((functionp test) |
105223
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
207 (funcall test hlist)) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
208 ;; otherwise, return test itself |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
209 (t test)))) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
210 ;;(debug message headers) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
211 (when runit |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
212 (funcall function |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
213 message |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
214 (imap-hash-get-headers |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
215 headers) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
216 (imap-hash-get-body |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
217 (imap-hash-data-body details)))))) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
218 "UID"))))) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
219 |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
220 (defun imap-hash-count (iht) |
106697
ac408704629c
lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents:
105377
diff
changeset
|
221 "Count the number of messages in the imap-hash IHT. |
105223
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
222 Also see `imap-hash-test'. It uses `imap-hash-map' so just use that |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
223 function if you want to do more than count the elements." |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
224 (length (imap-hash-map (lambda (a b c)) iht t))) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
225 |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
226 (defalias 'imap-hash-size 'imap-hash-count) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
227 |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
228 (defun imap-hash-test (iht) |
106697
ac408704629c
lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents:
105377
diff
changeset
|
229 "Return the test used by `imap-hash-map' for IHT. |
105223
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
230 When the test is t, any key will be a candidate. |
106697
ac408704629c
lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents:
105377
diff
changeset
|
231 When the test is a string, messages will be filtered on that string as a |
ac408704629c
lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents:
105377
diff
changeset
|
232 regexp against the subject. |
ac408704629c
lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents:
105377
diff
changeset
|
233 When the test is a function, messages will be filtered with it. |
105223
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
234 The function is passed the message headers (see `imap-hash-get-headers')." |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
235 (plist-get iht :test)) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
236 |
106697
ac408704629c
lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents:
105377
diff
changeset
|
237 (defun imap-hash-server (iht) |
ac408704629c
lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents:
105377
diff
changeset
|
238 "Return the server used by the imap-hash IHT." |
105223
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
239 (plist-get iht :server)) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
240 |
106697
ac408704629c
lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents:
105377
diff
changeset
|
241 (defun imap-hash-port (iht) |
ac408704629c
lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents:
105377
diff
changeset
|
242 "Return the port used by the imap-hash IHT." |
105223
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
243 (plist-get iht :port)) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
244 |
106697
ac408704629c
lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents:
105377
diff
changeset
|
245 (defun imap-hash-ssl (iht) |
ac408704629c
lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents:
105377
diff
changeset
|
246 "Return the SSL need for the imap-hash IHT." |
105223
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
247 (plist-get iht :ssl)) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
248 |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
249 (defun imap-hash-mailbox (iht) |
106697
ac408704629c
lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents:
105377
diff
changeset
|
250 "Return the mailbox used by the imap-hash IHT." |
105223
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
251 (plist-get iht :mailbox)) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
252 |
106697
ac408704629c
lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents:
105377
diff
changeset
|
253 (defun imap-hash-user (iht) |
ac408704629c
lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents:
105377
diff
changeset
|
254 "Return the username used by the imap-hash IHT." |
105223
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
255 (plist-get iht :user)) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
256 |
106697
ac408704629c
lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents:
105377
diff
changeset
|
257 (defun imap-hash-password (iht) |
ac408704629c
lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents:
105377
diff
changeset
|
258 "Return the password used by the imap-hash IHT." |
105223
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
259 (plist-get iht :password)) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
260 |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
261 (defun imap-hash-open-connection (iht) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
262 "Open the connection used for IMAP interactions with the imap-hash IHT." |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
263 (let* ((server (imap-hash-server iht)) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
264 (port (imap-hash-port iht)) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
265 (ssl-need (imap-hash-ssl iht)) |
106697
ac408704629c
lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents:
105377
diff
changeset
|
266 (auth-need (not (and (imap-hash-user iht) |
105223
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
267 (imap-hash-password iht)))) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
268 ;; this will not be needed if auth-need is t |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
269 (auth-info (when auth-need |
106697
ac408704629c
lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents:
105377
diff
changeset
|
270 (auth-source-user-or-password |
ac408704629c
lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents:
105377
diff
changeset
|
271 '("login" "password") |
105223
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
272 server port))) |
106697
ac408704629c
lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents:
105377
diff
changeset
|
273 (auth-user (or (imap-hash-user iht) |
105223
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
274 (nth 0 auth-info))) |
106697
ac408704629c
lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents:
105377
diff
changeset
|
275 (auth-passwd (or (imap-hash-password iht) |
105223
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
276 (nth 1 auth-info))) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
277 (imap-logout-timeout nil)) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
278 |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
279 ;; (debug "opening server: opened+state" (imap-opened) imap-state) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
280 ;; this is the only place where IMAP vs IMAPS matters |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
281 (if (imap-open server port (if ssl-need 'ssl nil) nil (current-buffer)) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
282 (progn |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
283 ;; (debug "after opening server: opened+state" (imap-opened (current-buffer)) imap-state) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
284 ;; (debug "authenticating" auth-user auth-passwd) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
285 (if (not (imap-capability 'IMAP4rev1)) |
106697
ac408704629c
lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents:
105377
diff
changeset
|
286 (error "IMAP server does not support IMAP4r1, it won't work, sorry") |
105223
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
287 (imap-authenticate auth-user auth-passwd) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
288 (imap-id) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
289 ;; (debug "after authenticating: opened+state" (imap-opened (current-buffer)) imap-state) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
290 (imap-opened (current-buffer)))) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
291 (error "Could not open the IMAP buffer")))) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
292 |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
293 (defun imap-hash-get-buffer (iht) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
294 "Get or create the connection buffer to be used for the imap-hash IHT." |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
295 (let* ((name (imap-hash-buffer-name iht)) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
296 (buffer (get-buffer name))) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
297 (if (and buffer (imap-opened buffer)) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
298 buffer |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
299 (when buffer (kill-buffer buffer)) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
300 (with-current-buffer (get-buffer-create name) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
301 (setq buffer-undo-list t) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
302 (when (imap-hash-open-connection iht) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
303 (current-buffer)))))) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
304 |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
305 (defun imap-hash-buffer-name (iht) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
306 "Get the connection buffer to be used for the imap-hash IHT." |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
307 (when (imap-hash-p iht) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
308 (let ((server (imap-hash-server iht)) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
309 (port (imap-hash-port iht)) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
310 (ssl-text (if (imap-hash-ssl iht) "SSL" "NoSSL"))) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
311 (format "*imap-hash/%s:%s:%s*" server port ssl-text)))) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
312 |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
313 (defun imap-hash-fetch (iht &optional headers-only &rest messages) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
314 "Fetch all the messages for imap-hash IHT. |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
315 Get only the headers if HEADERS-ONLY is not nil." |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
316 (with-current-buffer (imap-hash-get-buffer iht) |
106697
ac408704629c
lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents:
105377
diff
changeset
|
317 (let ((range (if messages |
ac408704629c
lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents:
105377
diff
changeset
|
318 (list |
105223
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
319 (imap-range-to-message-set messages) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
320 (imap-range-to-message-set messages)) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
321 '("1:*" . "1,*:*")))) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
322 |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
323 ;; (with-current-buffer "*imap-debug*" |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
324 ;; (erase-buffer)) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
325 (imap-mailbox-unselect) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
326 (imap-mailbox-select (imap-hash-mailbox iht)) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
327 ;; (debug "after selecting mailbox: opened+state" (imap-opened) imap-state) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
328 ;; (setq imap-message-data (make-vector imap-message-prime 0) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
329 (imap-fetch-safe range |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
330 (concat (format "(UID RFC822.SIZE BODY %s " |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
331 (if headers-only "" "BODY.PEEK[TEXT]")) |
106697
ac408704629c
lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents:
105377
diff
changeset
|
332 (format "BODY.PEEK[HEADER.FIELDS %s])" |
105223
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
333 imap-hash-headers)))))) |
106697
ac408704629c
lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents:
105377
diff
changeset
|
334 |
105223
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
335 (provide 'imap-hash) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
336 ;;; imap-hash.el ends here |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
337 |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
338 ;; ignore, for testing only |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
339 |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
340 ;;; (setq iht (imap-hash-make "yourhosthere.com" "imap" "INBOX.test")) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
341 ;;; (setq iht (imap-hash-make "yourhosthere.com" "imap" "test")) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
342 ;;; (imap-hash-make "server1" "INBOX.mailbox2") |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
343 ;;; (imap-hash-p iht) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
344 ;;; (imap-hash-get 35 iht) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
345 ;;; (imap-hash-get 38 iht) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
346 ;;; (imap-hash-get 37 iht t) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
347 ;;; (mapc (lambda (buffer) (with-current-buffer buffer (erase-buffer))) '("*imap-debug*" "*imap-log*")) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
348 ;;; (imap-hash-put (imap-hash-get 5 iht) iht) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
349 ;;; (with-current-buffer (imap-hash-get-buffer iht) (let ((uid (imap-hash-put (imap-hash-get 5 iht) iht))) (imap-hash-put uid iht uid))) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
350 ;;; (imap-hash-put (imap-hash-get 35 iht) iht) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
351 ;;; (imap-hash-make-message '((Subject . "normal")) "normal body") |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
352 ;;; (imap-hash-make-message '((Subject . "old")) "old body" '((Subject . "new"))) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
353 ;;; (imap-hash-make-message '((Subject . "old")) "old body" '((body . "new body")) (lambda (subject) (concat "overwrite-" subject))) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
354 ;;; (imap-hash-make-message '((Subject . "old")) "old body" '((Subject . "change this")) (lambda (subject) (concat "overwrite-" subject))) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
355 ;;; (imap-hash-make-message '((Subject . "Twelcome")) "body here" nil) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
356 ;; (with-current-buffer (imap-hash-get-buffer iht) (imap-hash-rem (imap-hash-put (imap-hash-get 5 iht) iht) iht)) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
357 ;;; (kill-buffer (imap-hash-buffer-name iht)) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
358 ;;; (imap-hash-map 'debug iht) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
359 ;;; (imap-hash-map 'debug iht t) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
360 ;;;(tramp-imap-handle-file-inode "/imap:yourhosthere.com:/test/welcome") |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
361 ;;;(imap-hash-count iht) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
362 ;;; (mapc (lambda (buffer) (with-current-buffer buffer (erase-buffer))) '("*imap-debug*" "*imap-log*")) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
363 ;;; (kill-buffer (imap-hash-buffer-name iht)) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
364 ;;; this should always return t if the server is up, automatically reopening if needed |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
365 ;;; (imap-opened (imap-hash-get-buffer iht)) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
366 ;;; (imap-hash-buffer-name iht) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
367 ;;; (with-current-buffer (imap-hash-get-buffer iht) (debug "mailbox data, auth and state" imap-mailbox-data imap-auth imap-state)) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
368 ;;;(tramp-imap-handle-file-inode "/imap:yourhosthere.com:/test/welcome") |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
369 ;;; (imap-hash-fetch iht nil) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
370 ;;; (imap-hash-fetch iht t) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
371 ;;; (imap-hash-fetch iht nil 1 2 3) |
95bdce3df18d
* net/imap-hash.el: New library, see NEWS.
Teodor Zlatanov <tzz@lifelogs.com>
parents:
diff
changeset
|
372 ;;; (imap-hash-fetch iht t 1 2 3) |
105377 | 373 |
374 ;; arch-tag: 071410ac-91dc-4e36-b892-18e057d639c5 |