annotate lisp/mail/mspools.el @ 37308:bcbc0628e2e5

*** empty log message ***
author Gerd Moellmann <gerd@gnu.org>
date Tue, 10 Apr 2001 16:13:33 +0000
parents aa6eab250ce8
children b174db545cfd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4
23785
ef0150f917c9 Update author email and web page.
Stephen Eglen <stephen@gnu.org>
parents: 21537
diff changeset
5 ;; Author: Stephen Eglen <stephen@anc.ed.ac.uk>
ef0150f917c9 Update author email and web page.
Stephen Eglen <stephen@gnu.org>
parents: 21537
diff changeset
6 ;; Maintainer: Stephen Eglen <stephen@anc.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
23785
ef0150f917c9 Update author email and web page.
Stephen Eglen <stephen@gnu.org>
parents: 21537
diff changeset
9 ;; location: http://www.anc.ed.ac.uk/~stephen/emacs/
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10
19042
e50604c01474 Update distribution terms.
Richard M. Stallman <rms@gnu.org>
parents: 19041
diff changeset
11 ;; This file is part of GNU Emacs.
e50604c01474 Update distribution terms.
Richard M. Stallman <rms@gnu.org>
parents: 19041
diff changeset
12
e50604c01474 Update distribution terms.
Richard M. Stallman <rms@gnu.org>
parents: 19041
diff changeset
13 ;; GNU Emacs is free software; you can redistribute it and/or modify
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 ;; 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
15 ;; the Free Software Foundation; either version 2, or (at your option)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 ;; any later version.
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17
19042
e50604c01474 Update distribution terms.
Richard M. Stallman <rms@gnu.org>
parents: 19041
diff changeset
18 ;; GNU Emacs is distributed in the hope that it will be useful,
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 ;; GNU General Public License for more details.
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23 ;; You should have received a copy of the GNU General Public License
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24 ;; 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
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26 ;; Boston, MA 02111-1307, USA.
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 ;;; Commentary:
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30 ;; 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
31 ;; folders, this file will let you see which folders have mail waiting
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32 ;; 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
33 ;; 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
34 ;; file writes directly to `folder' you may lose mail if new mail
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 ;; arrives whilst you are reading the folder in emacs, hence the use
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 ;; of a spool file.) For example, the following procmail recipe puts
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37 ;; 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
38 ;; `emacs.spool', ready to go into the folder `emacs'.
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 ;:0:
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 ;* ^Subject.*emacs
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 ;emacs.spool
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43 ;; 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
44 ;; in the directory pointed to by `mspools-folder-directory', so you must
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 ;; set this (see Installation).
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47 ;; When you run `mspools-show', it creates a *spools* buffer containing
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48 ;; 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
49 ;; 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
50 ;; 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
51 ;; press return or space. The mailer (VM or RMAIL) should then read
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52 ;; 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
53 ;; *spools* buffer, you will either see "*" to indicate that the spool
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54 ;; has been read, or the remaining unread spools, depending on the
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55 ;; value of `mspools-update'.
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 ;; This file should work with both VM and RMAIL. See the variable
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 ;; `mspools-using-vm' for details.
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66
20807
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
67 ;; Extras.
21537
4a716088f0b4 (mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents: 20807
diff changeset
68 ;;
20807
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.
21537
4a716088f0b4 (mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents: 20807
diff changeset
70 ;; (setq mspools-update t) ;Automatically update buffer.
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 ;; 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
83 ;; mail with VM if this is incorrectly set.
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
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
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
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99 ;; 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
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
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 ;; 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
105 ;; waiting? (Could be more time demanding / system dependent).
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 ;; 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
107 ;; visualise the results in the buffer.
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 ;; Shrink wrap the buffer to remove excess white-space?
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110
20807
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
111 ;;; Code:
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 ;;; User Variables
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
131 (defcustom mspools-using-vm (fboundp 'vm)
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
132 "*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
133 :type 'boolean
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
134 :group 'mspools)
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
135
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
136 (defcustom mspools-folder-directory
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
137 (if (boundp 'vm-folder-directory)
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
138 vm-folder-directory
21537
4a716088f0b4 (mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents: 20807
diff changeset
139 "~/MAIL/")
20807
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
140 "*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
141 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
142 :type 'directory
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
143 :group 'mspools)
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144
23996
aa6eab250ce8 (mspools-vm-system-mail): Provide an alternative value based on
Stephen Eglen <stephen@gnu.org>
parents: 23785
diff changeset
145 (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
146 (concat rmail-spool-directory
aa6eab250ce8 (mspools-vm-system-mail): Provide an alternative value based on
Stephen Eglen <stephen@gnu.org>
parents: 23785
diff changeset
147 (user-login-name)))
21537
4a716088f0b4 (mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents: 20807
diff changeset
148 "*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
149 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
150 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
151 $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
152 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
153 /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
154 :type 'file
4a716088f0b4 (mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents: 20807
diff changeset
155 :group 'mspools)
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156
21537
4a716088f0b4 (mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents: 20807
diff changeset
157 ;;; Internal Variables
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
158
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159 (defvar mspools-files nil
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160 "List of entries (SPOOL . SIZE) giving spool name and file size.")
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
161
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
162 (defvar mspools-files-len nil
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
163 "Length of `mspools-files' list.")
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165 (defvar mspools-buffer "*spools*"
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166 "Name of buffer for displaying spool info.")
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
167
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
168 (defvar mspools-mode-map nil
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
169 "Keymap for the *spools* buffer.")
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
170
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
171 ;;; Code
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
172
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
173 ;;; VM Specific code
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
174 (if mspools-using-vm
19041
036cc3196550 (mspools-using-vm): Better handling of VM initialization.
Richard M. Stallman <rms@gnu.org>
parents: 19034
diff changeset
175 ;; 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
176 (progn
036cc3196550 (mspools-using-vm): Better handling of VM initialization.
Richard M. Stallman <rms@gnu.org>
parents: 19034
diff changeset
177 (require 'vm-vars)
21537
4a716088f0b4 (mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents: 20807
diff changeset
178 (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
179 (load-file vm-init-file))
036cc3196550 (mspools-using-vm): Better handling of VM initialization.
Richard M. Stallman <rms@gnu.org>
parents: 19034
diff changeset
180 (if (not mspools-folder-directory)
036cc3196550 (mspools-using-vm): Better handling of VM initialization.
Richard M. Stallman <rms@gnu.org>
parents: 19034
diff changeset
181 (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
182 ))
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184 (defun mspools-set-vm-spool-files ()
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 "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
186 (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
187 (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
188 (if (null mspools-folder-directory)
4a716088f0b4 (mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents: 20807
diff changeset
189 (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
190 (setq
4a716088f0b4 (mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents: 20807
diff changeset
191 vm-spool-files
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192 (append
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
193 (list
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194 ;; Main mailbox
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195 (list vm-primary-inbox
21537
4a716088f0b4 (mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents: 20807
diff changeset
196 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
197 vm-crash-box ;crash for mailbox
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198 ))
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200 ;; Mailing list inboxes
19041
036cc3196550 (mspools-using-vm): Better handling of VM initialization.
Richard M. Stallman <rms@gnu.org>
parents: 19034
diff changeset
201 ;; must have VM already loaded to get vm-folder-directory.
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
202 (mapcar '(lambda (s)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
203 "make the appropriate entry for vm-spool-files"
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
204 (list
21537
4a716088f0b4 (mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents: 20807
diff changeset
205 (concat mspools-folder-directory s)
4a716088f0b4 (mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents: 20807
diff changeset
206 (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
207 (concat mspools-folder-directory s ".crash")))
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
208 ;; 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
209 (mapcar 'file-name-sans-extension
21537
4a716088f0b4 (mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents: 20807
diff changeset
210 (directory-files mspools-folder-directory nil
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
211 (format "^[^.]+\\.%s" mspools-suffix)))
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 ))
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
215 ;;; 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
216 (defun mspools-show ( &optional noshow)
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
217 "Show the list of non-empty spool files in the *spools* buffer.
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218 Buffer is not displayed if SHOW is non-nil."
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219 (interactive)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220 (if (get-buffer mspools-buffer)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221 ;; buffer exists
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
222 (progn
21537
4a716088f0b4 (mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents: 20807
diff changeset
223 (set-buffer mspools-buffer)
4a716088f0b4 (mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents: 20807
diff changeset
224 (setq buffer-read-only nil)
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
225 (delete-region (point-min) (point-max)))
20807
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
226 ;; else buffer doesn't exist so create it
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
227 (get-buffer-create mspools-buffer))
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
228
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
229 ;; generate the list of spool files
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
230 (if mspools-using-vm
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
231 (mspools-set-vm-spool-files))
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
232
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
233 (mspools-get-spool-files)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
234 (if (not noshow) (pop-to-buffer mspools-buffer))
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
235
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
236 (setq buffer-read-only t)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
237 (mspools-mode)
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 (defun mspools-visit-spool ()
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
241 "Visit the folder on the current line of the *spools* buffer."
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
242 (interactive)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
243 (let ( spool-name folder-name)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
244 (setq spool-name (mspools-get-spool-name))
20807
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
245 (if (null spool-name)
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
246 (message "No spool on current line")
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
247
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
248 (setq folder-name (mspools-get-folder-from-spool spool-name))
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
249
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
250 ;; 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
251 (if (not mspools-update)
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
252 (save-excursion
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
253 (setq buffer-read-only nil)
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
254 (beginning-of-line)
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
255 (insert "*")
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
256 (delete-char 1)
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
257 (setq buffer-read-only t)
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
258 ))
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
259
20807
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
260 (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
261 (if (eq (count-lines (point-min)
20807
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
262 (save-excursion
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
263 (end-of-line)
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
264 (point)))
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
265 mspools-files-len)
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
266 (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
267 ;; else just on to next line
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
268 (next-line 1))
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
269
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
270 ;; 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
271 (if mspools-using-vm
20807
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
272 (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
273 ;; else using RMAIL
20807
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
274 (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
275 (setq rmail-inbox-list
20807
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
276 (list (concat mspools-folder-directory spool-name)))
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
277 (rmail-get-new-mail))
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
278
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 (if mspools-update
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
281 ;; 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
282 (save-excursion
20807
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
283 (mspools-show-again 'noshow))))))
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
284
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
285 (defun mspools-get-folder-from-spool (name)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
286 "Return folder name corresponding to the spool file NAME."
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
287 ;; Simply strip of the extension.
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
288 (file-name-sans-extension name))
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
289
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
290 ;; Alternative version if you have more complicated mapping of spool name
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
291 ;; to file name.
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
292 ;(defun get-folder-from-spool-safe (name)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
293 ; "Return the folder name corresponding to the spool file NAME."
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
294 ; (if (string-match "^\\(.*\\)\.spool$" name)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
295 ; (substring name (match-beginning 1) (match-end 1))
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
296 ; (error "Could not extract folder name from spool name %s" name)))
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 ; test
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
299 ;(mspools-get-folder-from-spool "happy.spool")
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
300 ;(mspools-get-folder-from-spool "happy.sp")
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 (defun mspools-get-spool-name ()
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
303 "Return the name of the spool on the current line."
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
304 (let ((line-num (1- (count-lines (point-min)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
305 (save-excursion
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
306 (end-of-line)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
307 (point))
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
308 ))))
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
309 (car (nth line-num mspools-files))))
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 ;;; Keymap
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
312
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
313 (if mspools-mode-map
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
314 ()
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
315 (setq mspools-mode-map (make-sparse-keymap))
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
316
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
317 (define-key mspools-mode-map "\C-c\C-c" 'mspools-visit-spool)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
318 (define-key mspools-mode-map "\C-m" 'mspools-visit-spool)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
319 (define-key mspools-mode-map " " 'mspools-visit-spool)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
320 (define-key mspools-mode-map "?" 'mspools-help)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
321 (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
322 (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
323 (define-key mspools-mode-map "p" 'previous-line)
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
324 (define-key mspools-mode-map "g" 'revert-buffer))
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
325
21537
4a716088f0b4 (mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents: 20807
diff changeset
326 ;;; Spools mode functions
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
327
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
328 (defun mspools-revert-buffer (ignore noconfirm)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
329 "Re-run mspools-show to revert the *spools* buffer."
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
330 (mspools-show 'noshow))
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
331
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
332 (defun mspools-show-again (&optional noshow)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
333 "Update the *spools* buffer. This is useful if mspools-update is
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
334 nil."
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
335 (interactive)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
336 (mspools-show noshow))
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
337
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
338 (defun mspools-help ()
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
339 "Show help for `mspools-mode'."
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
340 (interactive)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
341 (describe-function 'mspools-mode))
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
342
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
343 (defun mspools-quit ()
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
344 "Quit the *spools* buffer."
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
345 (interactive)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
346 (kill-buffer mspools-buffer))
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 (defun mspools-mode ()
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
349 "Major mode for output from mspools-show.
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
350 \\<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
351 \\[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
352 \\[revert-buffer] to regenerate the list of spools.
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
353 \\{mspools-mode-map}"
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
354 (kill-all-local-variables)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
355 (make-local-variable 'revert-buffer-function)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
356 (setq revert-buffer-function 'mspools-revert-buffer)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
357 (use-local-map mspools-mode-map)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
358 (setq major-mode 'mspools-mode)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
359 (setq mode-name "MSpools")
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
360 )
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
361
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
362 (defun mspools-get-spool-files ()
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
363 "Find the list of spool files and display them in *spools* buffer."
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
364 (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
365 (if (null mspools-folder-directory)
4a716088f0b4 (mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents: 20807
diff changeset
366 (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
367 (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
368 (format "^[^.]+\\.%s$" mspools-suffix)))
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
369 (setq folders (mapcar 'mspools-size-folder folders))
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
370 (setq folders (delq nil folders))
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
371 (setq mspools-files folders)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
372 (setq mspools-files-len (length mspools-files))
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
373 (set-buffer mspools-buffer)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
374 (while folders
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
375 (setq any t)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
376 (setq head (car folders))
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
377 (setq spool (car head))
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
378 (setq len (cdr head))
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
379 (setq folders (cdr folders))
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
380 (setq beg (point))
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
381 (insert (format " %10d %s" len spool))
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
382 (setq end (point))
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
383 (insert "\n")
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
384 ;;(put-text-property beg end 'mouse-face 'highlight)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
385 )
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
386 (if any
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
387 (delete-char -1)) ;delete last RET
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
388 (goto-char (point-min))
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
389 ))
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
390
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
391 (defun mspools-size-folder (spool)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
392 "Return (SPOOL . SIZE ) iff SIZE of spool file is non-zero."
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
393 ;; 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
394 (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
395 size)
036cc3196550 (mspools-using-vm): Better handling of VM initialization.
Richard M. Stallman <rms@gnu.org>
parents: 19034
diff changeset
396 (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
397 (setq size (nth 7 (file-attributes file)))
20807
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
398 ;; 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
399 ;; so check this first.
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
400 (if (and size (> size 0))
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
401 (cons spool size)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
402 ;; else SPOOL is empty
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
403 nil)))
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
404
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
405 (provide 'mspools)
19041
036cc3196550 (mspools-using-vm): Better handling of VM initialization.
Richard M. Stallman <rms@gnu.org>
parents: 19034
diff changeset
406 ;;; mspools.el ends here
036cc3196550 (mspools-using-vm): Better handling of VM initialization.
Richard M. Stallman <rms@gnu.org>
parents: 19034
diff changeset
407