Mercurial > emacs
annotate lisp/mail/mspools.el @ 82924:95004fac3361
(c-constant-kwds): Add java: null, true, false.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Tue, 28 Aug 2007 02:49:48 +0000 |
parents | 0092d723fe35 |
children | de499b20517a 786d3a985758 424b655804ca |
rev | line source |
---|---|
38436
b174db545cfd
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
23996
diff
changeset
|
1 ;;; mspools.el --- show mail spools waiting to be read |
17905 | 2 |
74509 | 3 ;; Copyright (C) 1997, 2001, 2002, 2003, 2004, 2005, |
75347 | 4 ;; 2006, 2007 Free Software Foundation, Inc. |
17905 | 5 |
41161
e72cd74733bb
Change maintainer email address.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
6 ;; Author: Stephen Eglen <stephen@gnu.org> |
e72cd74733bb
Change maintainer email address.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
7 ;; Maintainer: Stephen Eglen <stephen@gnu.org> |
17905 | 8 ;; Created: 22 Jan 1997 |
18929 | 9 ;; Keywords: mail |
23785
ef0150f917c9
Update author email and web page.
Stephen Eglen <stephen@gnu.org>
parents:
21537
diff
changeset
|
10 ;; location: http://www.anc.ed.ac.uk/~stephen/emacs/ |
17905 | 11 |
19042
e50604c01474
Update distribution terms.
Richard M. Stallman <rms@gnu.org>
parents:
19041
diff
changeset
|
12 ;; This file is part of GNU Emacs. |
e50604c01474
Update distribution terms.
Richard M. Stallman <rms@gnu.org>
parents:
19041
diff
changeset
|
13 |
e50604c01474
Update distribution terms.
Richard M. Stallman <rms@gnu.org>
parents:
19041
diff
changeset
|
14 ;; GNU Emacs is free software; you can redistribute it and/or modify |
17905 | 15 ;; it under the terms of the GNU General Public License as published by |
78232
8e27d63c45eb
Switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents:
75347
diff
changeset
|
16 ;; the Free Software Foundation; either version 3, or (at your option) |
17905 | 17 ;; any later version. |
18 | |
19042
e50604c01474
Update distribution terms.
Richard M. Stallman <rms@gnu.org>
parents:
19041
diff
changeset
|
19 ;; GNU Emacs is distributed in the hope that it will be useful, |
17905 | 20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
22 ;; GNU General Public License for more details. | |
23 | |
24 ;; You should have received a copy of the GNU General Public License | |
25 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
64085 | 26 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
27 ;; Boston, MA 02110-1301, USA. | |
17905 | 28 |
29 ;;; Commentary: | |
30 | |
31 ;; If you use a mail filter (e.g. procmail, filter) to put mail messages in | |
32 ;; folders, this file will let you see which folders have mail waiting | |
33 ;; to be read in them. It assumes that new mail for the file `folder' | |
34 ;; is written by the filter to a file called `folder.spool'. (If the | |
35 ;; file writes directly to `folder' you may lose mail if new mail | |
36 ;; arrives whilst you are reading the folder in emacs, hence the use | |
37 ;; of a spool file.) For example, the following procmail recipe puts | |
38 ;; any mail with `emacs' in the subject line into the spool file | |
19041
036cc3196550
(mspools-using-vm): Better handling of VM initialization.
Richard M. Stallman <rms@gnu.org>
parents:
19034
diff
changeset
|
39 ;; `emacs.spool', ready to go into the folder `emacs'. |
17905 | 40 ;:0: |
41 ;* ^Subject.*emacs | |
42 ;emacs.spool | |
43 | |
44 ;; It also assumes that all of your spool files and mail folders live | |
45 ;; in the directory pointed to by `mspools-folder-directory', so you must | |
46 ;; set this (see Installation). | |
47 | |
48 ;; When you run `mspools-show', it creates a *spools* buffer containing | |
49 ;; all of the spools in the folder directory that are waiting to be | |
50 ;; read. On each line is the spool name and its size in bytes. Move | |
51 ;; to the line of the folder that you would like to read, and then | |
52 ;; press return or space. The mailer (VM or RMAIL) should then read | |
53 ;; that folder and get the new mail for you. When you return to the | |
54 ;; *spools* buffer, you will either see "*" to indicate that the spool | |
55 ;; has been read, or the remaining unread spools, depending on the | |
56 ;; value of `mspools-update'. | |
57 | |
58 ;; This file should work with both VM and RMAIL. See the variable | |
59 ;; `mspools-using-vm' for details. | |
60 | |
20807
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
61 ;;; Basic installation. |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
62 ;; (autoload 'mspools-show "mspools" "Show outstanding mail spools." t) |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
63 ;; (setq mspools-folder-directory "~/MAIL/") |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
64 ;; |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
65 ;; If you use VM, mspools-folder-directory will default to vm-folder-directory |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
66 ;; unless you have already given it a value. |
17905 | 67 |
20807
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
68 ;; Extras. |
21537
4a716088f0b4
(mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents:
20807
diff
changeset
|
69 ;; |
20807
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
70 ;; (global-set-key '[S-f1] 'mspools-show) ;Bind mspools-show to Shift F1. |
21537
4a716088f0b4
(mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents:
20807
diff
changeset
|
71 ;; (setq mspools-update t) ;Automatically update buffer. |
17905 | 72 |
20807
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
73 ;; Interface with the mail filter. |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
74 ;; We assume that the mail filter drops new mail into the spool |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
75 ;; `folder.spool'. If your spool files are something like folder.xyz |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
76 ;; for inbox `folder', then do: |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
77 ;; (setq mspools-suffix "xyz") |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
78 ;; If you use other conventions for your spool files, this code will |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
79 ;; need rewriting. |
17905 | 80 |
20807
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
81 ;; Warning for VM users |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
82 ;; Don't use if you are not sure what you are doing. The value of |
17905 | 83 ;; vm-spool-files is altered, so you may not be able to read incoming |
84 ;; mail with VM if this is incorrectly set. | |
85 | |
86 ;; Useful settings for VM | |
20807
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
87 ;; vm-auto-get-new-mail should be t (the default). |
17905 | 88 |
20807
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
89 ;; Acknowledgements |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
90 ;; Thanks to jond@mitre.org (Jonathan Doughty) for help with code for |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
91 ;; setting up vm-spool-files. |
17905 | 92 |
93 ;;; TODO | |
94 | |
95 ;; What if users have mail spools in more than one directory? Extend | |
20807
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
96 ;; mspools-folder-directory to be a list of directories? Currently, |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
97 ;; if mail spools are in other directories, the way to read them is to |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
98 ;; put a symbolic link to the spool into the mspools-folder-directory. |
17905 | 99 |
100 ;; I was going to add mouse support so that you could click on a line | |
101 ;; to visit the buffer. Tell me if you want it, and I can put the | |
20807
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
102 ;; code in (I don't use the mouse much, so I haven't bothered with it |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
103 ;; so far). |
17905 | 104 |
105 ;; Rather than showing size in bytes, could we see the number of msgs | |
106 ;; waiting? (Could be more time demanding / system dependent). | |
107 ;; Maybe just call a perl script to do all the hard work, and | |
108 ;; visualise the results in the buffer. | |
109 | |
110 ;; Shrink wrap the buffer to remove excess white-space? | |
111 | |
20807
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
112 ;;; Code: |
17905 | 113 |
65211
7dba2c5465c6
(rmail-inbox-list, vm-crash-box, vm-folder-directory, vm-init-file,
Juanma Barranquero <lekktu@gmail.com>
parents:
64754
diff
changeset
|
114 (defvar rmail-inbox-list) |
7dba2c5465c6
(rmail-inbox-list, vm-crash-box, vm-folder-directory, vm-init-file,
Juanma Barranquero <lekktu@gmail.com>
parents:
64754
diff
changeset
|
115 (defvar vm-crash-box) |
7dba2c5465c6
(rmail-inbox-list, vm-crash-box, vm-folder-directory, vm-init-file,
Juanma Barranquero <lekktu@gmail.com>
parents:
64754
diff
changeset
|
116 (defvar vm-folder-directory) |
7dba2c5465c6
(rmail-inbox-list, vm-crash-box, vm-folder-directory, vm-init-file,
Juanma Barranquero <lekktu@gmail.com>
parents:
64754
diff
changeset
|
117 (defvar vm-init-file) |
7dba2c5465c6
(rmail-inbox-list, vm-crash-box, vm-folder-directory, vm-init-file,
Juanma Barranquero <lekktu@gmail.com>
parents:
64754
diff
changeset
|
118 (defvar vm-init-file-loaded) |
7dba2c5465c6
(rmail-inbox-list, vm-crash-box, vm-folder-directory, vm-init-file,
Juanma Barranquero <lekktu@gmail.com>
parents:
64754
diff
changeset
|
119 (defvar vm-primary-inbox) |
7dba2c5465c6
(rmail-inbox-list, vm-crash-box, vm-folder-directory, vm-init-file,
Juanma Barranquero <lekktu@gmail.com>
parents:
64754
diff
changeset
|
120 (defvar vm-spool-files) |
7dba2c5465c6
(rmail-inbox-list, vm-crash-box, vm-folder-directory, vm-init-file,
Juanma Barranquero <lekktu@gmail.com>
parents:
64754
diff
changeset
|
121 |
17905 | 122 ;;; User Variables |
123 | |
20807
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
124 (defgroup mspools nil |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
125 "Show mail spools waiting to be read." |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
126 :group 'mail |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
127 :link '(emacs-commentary-link :tag "Commentary" "mspools.el") |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
128 ) |
17905 | 129 |
20807
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
130 (defcustom mspools-update nil |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
131 "*Non-nil means update *spools* buffer after visiting any folder." |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
132 :type 'boolean |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
133 :group 'mspools) |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
134 |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
135 (defcustom mspools-suffix "spool" |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
136 "*Extension used for spool files (not including full stop)." |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
137 :type 'string |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
138 :group 'mspools) |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
139 |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
140 (defcustom mspools-using-vm (fboundp 'vm) |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
141 "*Non-nil if VM is used as mail reader, otherwise RMAIL is used." |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
142 :type 'boolean |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
143 :group 'mspools) |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
144 |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
145 (defcustom mspools-folder-directory |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
146 (if (boundp 'vm-folder-directory) |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
147 vm-folder-directory |
21537
4a716088f0b4
(mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents:
20807
diff
changeset
|
148 "~/MAIL/") |
20807
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
149 "*Directory where mail folders are kept. Ensure it has a trailing /. |
21537
4a716088f0b4
(mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents:
20807
diff
changeset
|
150 Defaults to `vm-folder-directory' if bound else to ~/MAIL/." |
20807
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
151 :type 'directory |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
152 :group 'mspools) |
17905 | 153 |
23996
aa6eab250ce8
(mspools-vm-system-mail): Provide an alternative value based on
Stephen Eglen <stephen@gnu.org>
parents:
23785
diff
changeset
|
154 (defcustom mspools-vm-system-mail (or (getenv "MAIL") |
aa6eab250ce8
(mspools-vm-system-mail): Provide an alternative value based on
Stephen Eglen <stephen@gnu.org>
parents:
23785
diff
changeset
|
155 (concat rmail-spool-directory |
aa6eab250ce8
(mspools-vm-system-mail): Provide an alternative value based on
Stephen Eglen <stephen@gnu.org>
parents:
23785
diff
changeset
|
156 (user-login-name))) |
21537
4a716088f0b4
(mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents:
20807
diff
changeset
|
157 "*Spool file for main mailbox. Only used by VM. |
4a716088f0b4
(mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents:
20807
diff
changeset
|
158 This needs to be set to your primary mail spool - mspools will not run |
4a716088f0b4
(mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents:
20807
diff
changeset
|
159 without it. By default this will be set to the environment variable |
23996
aa6eab250ce8
(mspools-vm-system-mail): Provide an alternative value based on
Stephen Eglen <stephen@gnu.org>
parents:
23785
diff
changeset
|
160 $MAIL. Otherwise it will use `rmail-spool-directory' to guess where |
aa6eab250ce8
(mspools-vm-system-mail): Provide an alternative value based on
Stephen Eglen <stephen@gnu.org>
parents:
23785
diff
changeset
|
161 your primary spool is. If this fails, set it to something like |
aa6eab250ce8
(mspools-vm-system-mail): Provide an alternative value based on
Stephen Eglen <stephen@gnu.org>
parents:
23785
diff
changeset
|
162 /usr/spool/mail/login-name." |
21537
4a716088f0b4
(mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents:
20807
diff
changeset
|
163 :type 'file |
4a716088f0b4
(mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents:
20807
diff
changeset
|
164 :group 'mspools) |
17905 | 165 |
21537
4a716088f0b4
(mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents:
20807
diff
changeset
|
166 ;;; Internal Variables |
17905 | 167 |
168 (defvar mspools-files nil | |
169 "List of entries (SPOOL . SIZE) giving spool name and file size.") | |
170 | |
171 (defvar mspools-files-len nil | |
172 "Length of `mspools-files' list.") | |
173 | |
174 (defvar mspools-buffer "*spools*" | |
175 "Name of buffer for displaying spool info.") | |
176 | |
177 (defvar mspools-mode-map nil | |
178 "Keymap for the *spools* buffer.") | |
179 | |
180 ;;; Code | |
181 | |
182 ;;; VM Specific code | |
183 (if mspools-using-vm | |
19041
036cc3196550
(mspools-using-vm): Better handling of VM initialization.
Richard M. Stallman <rms@gnu.org>
parents:
19034
diff
changeset
|
184 ;; set up vm if not already loaded. |
036cc3196550
(mspools-using-vm): Better handling of VM initialization.
Richard M. Stallman <rms@gnu.org>
parents:
19034
diff
changeset
|
185 (progn |
036cc3196550
(mspools-using-vm): Better handling of VM initialization.
Richard M. Stallman <rms@gnu.org>
parents:
19034
diff
changeset
|
186 (require 'vm-vars) |
21537
4a716088f0b4
(mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents:
20807
diff
changeset
|
187 (if (and (not vm-init-file-loaded) (file-readable-p vm-init-file)) |
19041
036cc3196550
(mspools-using-vm): Better handling of VM initialization.
Richard M. Stallman <rms@gnu.org>
parents:
19034
diff
changeset
|
188 (load-file vm-init-file)) |
036cc3196550
(mspools-using-vm): Better handling of VM initialization.
Richard M. Stallman <rms@gnu.org>
parents:
19034
diff
changeset
|
189 (if (not mspools-folder-directory) |
036cc3196550
(mspools-using-vm): Better handling of VM initialization.
Richard M. Stallman <rms@gnu.org>
parents:
19034
diff
changeset
|
190 (setq mspools-folder-directory vm-folder-directory)) |
036cc3196550
(mspools-using-vm): Better handling of VM initialization.
Richard M. Stallman <rms@gnu.org>
parents:
19034
diff
changeset
|
191 )) |
17905 | 192 |
193 (defun mspools-set-vm-spool-files () | |
194 "Set value of `vm-spool-files'. Only needed for VM." | |
23996
aa6eab250ce8
(mspools-vm-system-mail): Provide an alternative value based on
Stephen Eglen <stephen@gnu.org>
parents:
23785
diff
changeset
|
195 (if (not (file-readable-p mspools-vm-system-mail)) |
21537
4a716088f0b4
(mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents:
20807
diff
changeset
|
196 (error "Need to set mspools-vm-system-mail to the spool for primary inbox")) |
4a716088f0b4
(mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents:
20807
diff
changeset
|
197 (if (null mspools-folder-directory) |
4a716088f0b4
(mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents:
20807
diff
changeset
|
198 (error "Set `mspools-folder-directory' to where the spool files are")) |
4a716088f0b4
(mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents:
20807
diff
changeset
|
199 (setq |
4a716088f0b4
(mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents:
20807
diff
changeset
|
200 vm-spool-files |
17905 | 201 (append |
202 (list | |
203 ;; Main mailbox | |
204 (list vm-primary-inbox | |
21537
4a716088f0b4
(mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents:
20807
diff
changeset
|
205 mspools-vm-system-mail ; your mailbox |
4a716088f0b4
(mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents:
20807
diff
changeset
|
206 vm-crash-box ;crash for mailbox |
17905 | 207 )) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
41161
diff
changeset
|
208 |
17905 | 209 ;; Mailing list inboxes |
19041
036cc3196550
(mspools-using-vm): Better handling of VM initialization.
Richard M. Stallman <rms@gnu.org>
parents:
19034
diff
changeset
|
210 ;; must have VM already loaded to get vm-folder-directory. |
17905 | 211 (mapcar '(lambda (s) |
212 "make the appropriate entry for vm-spool-files" | |
213 (list | |
21537
4a716088f0b4
(mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents:
20807
diff
changeset
|
214 (concat mspools-folder-directory s) |
4a716088f0b4
(mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents:
20807
diff
changeset
|
215 (concat mspools-folder-directory s "." mspools-suffix) |
4a716088f0b4
(mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents:
20807
diff
changeset
|
216 (concat mspools-folder-directory s ".crash"))) |
17905 | 217 ;; So I create a vm-spool-files entry for each of those mail drops |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
41161
diff
changeset
|
218 (mapcar 'file-name-sans-extension |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
41161
diff
changeset
|
219 (directory-files mspools-folder-directory nil |
17905 | 220 (format "^[^.]+\\.%s" mspools-suffix))) |
221 )) | |
222 )) | |
223 | |
224 ;;; MSPOOLS-SHOW -- the main function | |
21537
4a716088f0b4
(mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents:
20807
diff
changeset
|
225 (defun mspools-show ( &optional noshow) |
17905 | 226 "Show the list of non-empty spool files in the *spools* buffer. |
227 Buffer is not displayed if SHOW is non-nil." | |
228 (interactive) | |
229 (if (get-buffer mspools-buffer) | |
230 ;; buffer exists | |
231 (progn | |
21537
4a716088f0b4
(mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents:
20807
diff
changeset
|
232 (set-buffer mspools-buffer) |
4a716088f0b4
(mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents:
20807
diff
changeset
|
233 (setq buffer-read-only nil) |
17905 | 234 (delete-region (point-min) (point-max))) |
20807
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
235 ;; else buffer doesn't exist so create it |
17905 | 236 (get-buffer-create mspools-buffer)) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
41161
diff
changeset
|
237 |
17905 | 238 ;; generate the list of spool files |
239 (if mspools-using-vm | |
240 (mspools-set-vm-spool-files)) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
41161
diff
changeset
|
241 |
17905 | 242 (mspools-get-spool-files) |
243 (if (not noshow) (pop-to-buffer mspools-buffer)) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
41161
diff
changeset
|
244 |
17905 | 245 (setq buffer-read-only t) |
246 (mspools-mode) | |
247 ) | |
248 | |
249 (defun mspools-visit-spool () | |
250 "Visit the folder on the current line of the *spools* buffer." | |
251 (interactive) | |
252 (let ( spool-name folder-name) | |
253 (setq spool-name (mspools-get-spool-name)) | |
20807
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
254 (if (null spool-name) |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
255 (message "No spool on current line") |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
41161
diff
changeset
|
256 |
20807
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
257 (setq folder-name (mspools-get-folder-from-spool spool-name)) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
41161
diff
changeset
|
258 |
20807
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
259 ;; put in a little "*" to indicate spool file has been read. |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
260 (if (not mspools-update) |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
261 (save-excursion |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
262 (setq buffer-read-only nil) |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
263 (beginning-of-line) |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
264 (insert "*") |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
265 (delete-char 1) |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
266 (setq buffer-read-only t) |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
267 )) |
17905 | 268 |
20807
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
269 (message "folder %s spool %s" folder-name spool-name) |
21537
4a716088f0b4
(mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents:
20807
diff
changeset
|
270 (if (eq (count-lines (point-min) |
20807
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
271 (save-excursion |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
272 (end-of-line) |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
273 (point))) |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
274 mspools-files-len) |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
275 (next-line (- 1 mspools-files-len)) ;back to top of list |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
276 ;; else just on to next line |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
277 (next-line 1)) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
41161
diff
changeset
|
278 |
20807
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
279 ;; Choose whether to use VM or RMAIL for reading folder. |
21537
4a716088f0b4
(mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents:
20807
diff
changeset
|
280 (if mspools-using-vm |
20807
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
281 (vm-visit-folder (concat mspools-folder-directory folder-name)) |
21537
4a716088f0b4
(mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents:
20807
diff
changeset
|
282 ;; else using RMAIL |
20807
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
283 (rmail (concat mspools-folder-directory folder-name)) |
21537
4a716088f0b4
(mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents:
20807
diff
changeset
|
284 (setq rmail-inbox-list |
20807
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
285 (list (concat mspools-folder-directory spool-name))) |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
286 (rmail-get-new-mail)) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
41161
diff
changeset
|
287 |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
41161
diff
changeset
|
288 |
20807
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
289 (if mspools-update |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
290 ;; generate new list of spools. |
21537
4a716088f0b4
(mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents:
20807
diff
changeset
|
291 (save-excursion |
20807
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
292 (mspools-show-again 'noshow)))))) |
17905 | 293 |
294 (defun mspools-get-folder-from-spool (name) | |
295 "Return folder name corresponding to the spool file NAME." | |
296 ;; Simply strip of the extension. | |
297 (file-name-sans-extension name)) | |
298 | |
299 ;; Alternative version if you have more complicated mapping of spool name | |
300 ;; to file name. | |
301 ;(defun get-folder-from-spool-safe (name) | |
302 ; "Return the folder name corresponding to the spool file NAME." | |
303 ; (if (string-match "^\\(.*\\)\.spool$" name) | |
304 ; (substring name (match-beginning 1) (match-end 1)) | |
305 ; (error "Could not extract folder name from spool name %s" name))) | |
306 | |
307 ; test | |
308 ;(mspools-get-folder-from-spool "happy.spool") | |
309 ;(mspools-get-folder-from-spool "happy.sp") | |
310 | |
311 (defun mspools-get-spool-name () | |
312 "Return the name of the spool on the current line." | |
313 (let ((line-num (1- (count-lines (point-min) | |
314 (save-excursion | |
315 (end-of-line) | |
316 (point)) | |
317 )))) | |
318 (car (nth line-num mspools-files)))) | |
319 | |
320 ;;; Keymap | |
321 | |
322 (if mspools-mode-map | |
323 () | |
324 (setq mspools-mode-map (make-sparse-keymap)) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
41161
diff
changeset
|
325 |
17905 | 326 (define-key mspools-mode-map "\C-c\C-c" 'mspools-visit-spool) |
327 (define-key mspools-mode-map "\C-m" 'mspools-visit-spool) | |
328 (define-key mspools-mode-map " " 'mspools-visit-spool) | |
329 (define-key mspools-mode-map "?" 'mspools-help) | |
330 (define-key mspools-mode-map "q" 'mspools-quit) | |
21537
4a716088f0b4
(mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents:
20807
diff
changeset
|
331 (define-key mspools-mode-map "n" 'next-line) |
4a716088f0b4
(mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents:
20807
diff
changeset
|
332 (define-key mspools-mode-map "p" 'previous-line) |
17905 | 333 (define-key mspools-mode-map "g" 'revert-buffer)) |
334 | |
21537
4a716088f0b4
(mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents:
20807
diff
changeset
|
335 ;;; Spools mode functions |
17905 | 336 |
337 (defun mspools-revert-buffer (ignore noconfirm) | |
338 "Re-run mspools-show to revert the *spools* buffer." | |
339 (mspools-show 'noshow)) | |
340 | |
341 (defun mspools-show-again (&optional noshow) | |
342 "Update the *spools* buffer. This is useful if mspools-update is | |
343 nil." | |
344 (interactive) | |
345 (mspools-show noshow)) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
41161
diff
changeset
|
346 |
17905 | 347 (defun mspools-help () |
348 "Show help for `mspools-mode'." | |
349 (interactive) | |
350 (describe-function 'mspools-mode)) | |
351 | |
352 (defun mspools-quit () | |
353 "Quit the *spools* buffer." | |
354 (interactive) | |
355 (kill-buffer mspools-buffer)) | |
356 | |
357 (defun mspools-mode () | |
358 "Major mode for output from mspools-show. | |
359 \\<mspools-mode-map>Move point to one of the items in this buffer, then use | |
360 \\[mspools-visit-spool] to go to the spool that the current line refers to. | |
19041
036cc3196550
(mspools-using-vm): Better handling of VM initialization.
Richard M. Stallman <rms@gnu.org>
parents:
19034
diff
changeset
|
361 \\[revert-buffer] to regenerate the list of spools. |
17905 | 362 \\{mspools-mode-map}" |
363 (kill-all-local-variables) | |
364 (make-local-variable 'revert-buffer-function) | |
365 (setq revert-buffer-function 'mspools-revert-buffer) | |
366 (use-local-map mspools-mode-map) | |
367 (setq major-mode 'mspools-mode) | |
368 (setq mode-name "MSpools") | |
63242
58b57765132c
(mspools-mode): Use run-mode-hooks.
Lute Kamstra <lute@gnu.org>
parents:
52401
diff
changeset
|
369 (run-mode-hooks 'mspools-mode-hook)) |
17905 | 370 |
371 (defun mspools-get-spool-files () | |
372 "Find the list of spool files and display them in *spools* buffer." | |
373 (let (folders head spool len beg end any) | |
21537
4a716088f0b4
(mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents:
20807
diff
changeset
|
374 (if (null mspools-folder-directory) |
4a716088f0b4
(mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents:
20807
diff
changeset
|
375 (error "Set `mspools-folder-directory' to where the spool files are")) |
4a716088f0b4
(mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents:
20807
diff
changeset
|
376 (setq folders (directory-files mspools-folder-directory nil |
4a716088f0b4
(mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents:
20807
diff
changeset
|
377 (format "^[^.]+\\.%s$" mspools-suffix))) |
17905 | 378 (setq folders (mapcar 'mspools-size-folder folders)) |
379 (setq folders (delq nil folders)) | |
380 (setq mspools-files folders) | |
381 (setq mspools-files-len (length mspools-files)) | |
382 (set-buffer mspools-buffer) | |
383 (while folders | |
384 (setq any t) | |
385 (setq head (car folders)) | |
386 (setq spool (car head)) | |
387 (setq len (cdr head)) | |
388 (setq folders (cdr folders)) | |
389 (setq beg (point)) | |
390 (insert (format " %10d %s" len spool)) | |
391 (setq end (point)) | |
392 (insert "\n") | |
393 ;;(put-text-property beg end 'mouse-face 'highlight) | |
394 ) | |
395 (if any | |
396 (delete-char -1)) ;delete last RET | |
397 (goto-char (point-min)) | |
398 )) | |
399 | |
400 (defun mspools-size-folder (spool) | |
78477
0092d723fe35
Replace `iff' in doc-strings and comments.
Glenn Morris <rgm@gnu.org>
parents:
78232
diff
changeset
|
401 "Return (SPOOL . SIZE ), if SIZE of spool file is non-zero." |
17905 | 402 ;; 7th file attribute is the size of the file in bytes. |
19041
036cc3196550
(mspools-using-vm): Better handling of VM initialization.
Richard M. Stallman <rms@gnu.org>
parents:
19034
diff
changeset
|
403 (let ((file (concat mspools-folder-directory spool)) |
036cc3196550
(mspools-using-vm): Better handling of VM initialization.
Richard M. Stallman <rms@gnu.org>
parents:
19034
diff
changeset
|
404 size) |
036cc3196550
(mspools-using-vm): Better handling of VM initialization.
Richard M. Stallman <rms@gnu.org>
parents:
19034
diff
changeset
|
405 (setq file (or (file-symlink-p file) file)) |
036cc3196550
(mspools-using-vm): Better handling of VM initialization.
Richard M. Stallman <rms@gnu.org>
parents:
19034
diff
changeset
|
406 (setq size (nth 7 (file-attributes file))) |
20807
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
407 ;; size could be nil if the sym-link points to a non-existent file |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
408 ;; so check this first. |
498136447303
File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents:
19042
diff
changeset
|
409 (if (and size (> size 0)) |
17905 | 410 (cons spool size) |
411 ;; else SPOOL is empty | |
412 nil))) | |
413 | |
414 (provide 'mspools) | |
38436
b174db545cfd
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
23996
diff
changeset
|
415 |
52401 | 416 ;;; arch-tag: 8990b3ee-68c8-4892-98f1-51a735c8bac6 |
19041
036cc3196550
(mspools-using-vm): Better handling of VM initialization.
Richard M. Stallman <rms@gnu.org>
parents:
19034
diff
changeset
|
417 ;;; mspools.el ends here |