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