annotate lisp/mail/mspools.el @ 19035:0b4c1d43cb95

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