annotate lisp/mail/mspools.el @ 105726:b0c56106af54

* fileio.c (syms_of_fileio): Initialize Vdirectory_sep_char. (init_fileio_once): * lisp.h (init_fileio_once): Remove. * emacs.c (main): Don't call init_fileio_once.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Fri, 23 Oct 2009 17:33:52 +0000
parents a9dc0e7c3f2b
children 1d1d5d9bd884
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38436
b174db545cfd Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 23996
diff changeset
1 ;;; mspools.el --- show mail spools waiting to be read
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2
74509
f7702c5f335d Update copyright years.
Glenn Morris <rgm@gnu.org>
parents: 68648
diff changeset
3 ;; Copyright (C) 1997, 2001, 2002, 2003, 2004, 2005,
100908
a9dc0e7c3f2b Add 2009 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 96376
diff changeset
4 ;; 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5
41161
e72cd74733bb Change maintainer email address.
Richard M. Stallman <rms@gnu.org>
parents: 38436
diff changeset
6 ;; Author: Stephen Eglen <stephen@gnu.org>
e72cd74733bb Change maintainer email address.
Richard M. Stallman <rms@gnu.org>
parents: 38436
diff changeset
7 ;; Maintainer: Stephen Eglen <stephen@gnu.org>
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8 ;; Created: 22 Jan 1997
18929
073e0019f9d9 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17905
diff changeset
9 ;; Keywords: mail
23785
ef0150f917c9 Update author email and web page.
Stephen Eglen <stephen@gnu.org>
parents: 21537
diff changeset
10 ;; location: http://www.anc.ed.ac.uk/~stephen/emacs/
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11
19042
e50604c01474 Update distribution terms.
Richard M. Stallman <rms@gnu.org>
parents: 19041
diff changeset
12 ;; This file is part of GNU Emacs.
e50604c01474 Update distribution terms.
Richard M. Stallman <rms@gnu.org>
parents: 19041
diff changeset
13
94674
ef65fa4dca3b Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
14 ;; 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
15 ;; it under the terms of the GNU General Public License as published by
94674
ef65fa4dca3b Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
16 ;; the Free Software Foundation, either version 3 of the License, or
ef65fa4dca3b Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
17 ;; (at your option) any later version.
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18
19042
e50604c01474 Update distribution terms.
Richard M. Stallman <rms@gnu.org>
parents: 19041
diff changeset
19 ;; GNU Emacs is distributed in the hope that it will be useful,
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 ;; GNU General Public License for more details.
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24 ;; You should have received a copy of the GNU General Public License
94674
ef65fa4dca3b Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
25 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 ;;; Commentary:
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 ;; 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
30 ;; folders, this file will let you see which folders have mail waiting
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31 ;; 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
32 ;; 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
33 ;; file writes directly to `folder' you may lose mail if new mail
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34 ;; arrives whilst you are reading the folder in emacs, hence the use
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 ;; of a spool file.) For example, the following procmail recipe puts
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 ;; any mail with `emacs' in the subject line into the spool file
19041
036cc3196550 (mspools-using-vm): Better handling of VM initialization.
Richard M. Stallman <rms@gnu.org>
parents: 19034
diff changeset
37 ;; `emacs.spool', ready to go into the folder `emacs'.
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 ;:0:
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 ;* ^Subject.*emacs
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 ;emacs.spool
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42 ;; 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
43 ;; in the directory pointed to by `mspools-folder-directory', so you must
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 ;; set this (see Installation).
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 ;; When you run `mspools-show', it creates a *spools* buffer containing
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47 ;; 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
48 ;; 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
49 ;; 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
50 ;; press return or space. The mailer (VM or RMAIL) should then read
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 ;; 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
52 ;; *spools* buffer, you will either see "*" to indicate that the spool
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53 ;; has been read, or the remaining unread spools, depending on the
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54 ;; value of `mspools-update'.
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 ;; This file should work with both VM and RMAIL. See the variable
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 ;; `mspools-using-vm' for details.
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58
20807
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
59 ;;; Basic installation.
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
60 ;; (autoload 'mspools-show "mspools" "Show outstanding mail spools." t)
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
61 ;; (setq mspools-folder-directory "~/MAIL/")
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
62 ;;
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
63 ;; 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
64 ;; unless you have already given it a value.
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65
20807
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
66 ;; Extras.
21537
4a716088f0b4 (mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents: 20807
diff changeset
67 ;;
20807
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
68 ;; (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
69 ;; (setq mspools-update t) ;Automatically update buffer.
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70
20807
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
71 ;; Interface with the mail filter.
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
72 ;; 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
73 ;; `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
74 ;; for inbox `folder', then do:
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
75 ;; (setq mspools-suffix "xyz")
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
76 ;; 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
77 ;; need rewriting.
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78
20807
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
79 ;; Warning for VM users
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
80 ;; 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
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
20807
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
85 ;; vm-auto-get-new-mail should be t (the default).
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86
20807
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
87 ;; Acknowledgements
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
88 ;; 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
89 ;; setting up vm-spool-files.
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 ;;; TODO
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93 ;; 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
94 ;; mspools-folder-directory to be a list of directories? Currently,
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
95 ;; 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
96 ;; 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
97
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 ;; 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
99 ;; 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
100 ;; 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
101 ;; so far).
17905
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 ;; Maybe just call a perl script to do all the hard work, and
96376
c3309dba6542 American English spelling fix.
Glenn Morris <rgm@gnu.org>
parents: 94674
diff changeset
106 ;; visualize the results in the buffer.
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 ;; Shrink wrap the buffer to remove excess white-space?
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109
20807
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
110 ;;; Code:
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111
65211
7dba2c5465c6 (rmail-inbox-list, vm-crash-box, vm-folder-directory, vm-init-file,
Juanma Barranquero <lekktu@gmail.com>
parents: 64754
diff changeset
112 (defvar rmail-inbox-list)
7dba2c5465c6 (rmail-inbox-list, vm-crash-box, vm-folder-directory, vm-init-file,
Juanma Barranquero <lekktu@gmail.com>
parents: 64754
diff changeset
113 (defvar vm-crash-box)
7dba2c5465c6 (rmail-inbox-list, vm-crash-box, vm-folder-directory, vm-init-file,
Juanma Barranquero <lekktu@gmail.com>
parents: 64754
diff changeset
114 (defvar vm-folder-directory)
7dba2c5465c6 (rmail-inbox-list, vm-crash-box, vm-folder-directory, vm-init-file,
Juanma Barranquero <lekktu@gmail.com>
parents: 64754
diff changeset
115 (defvar vm-init-file)
7dba2c5465c6 (rmail-inbox-list, vm-crash-box, vm-folder-directory, vm-init-file,
Juanma Barranquero <lekktu@gmail.com>
parents: 64754
diff changeset
116 (defvar vm-init-file-loaded)
7dba2c5465c6 (rmail-inbox-list, vm-crash-box, vm-folder-directory, vm-init-file,
Juanma Barranquero <lekktu@gmail.com>
parents: 64754
diff changeset
117 (defvar vm-primary-inbox)
7dba2c5465c6 (rmail-inbox-list, vm-crash-box, vm-folder-directory, vm-init-file,
Juanma Barranquero <lekktu@gmail.com>
parents: 64754
diff changeset
118 (defvar vm-spool-files)
7dba2c5465c6 (rmail-inbox-list, vm-crash-box, vm-folder-directory, vm-init-file,
Juanma Barranquero <lekktu@gmail.com>
parents: 64754
diff changeset
119
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 ;;; User Variables
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121
20807
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
122 (defgroup mspools nil
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
123 "Show mail spools waiting to be read."
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
124 :group 'mail
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
125 :link '(emacs-commentary-link :tag "Commentary" "mspools.el")
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
126 )
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127
20807
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
128 (defcustom mspools-update nil
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
129 "*Non-nil means update *spools* buffer after visiting any folder."
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
130 :type 'boolean
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
131 :group 'mspools)
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
132
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
133 (defcustom mspools-suffix "spool"
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
134 "*Extension used for spool files (not including full stop)."
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
135 :type 'string
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
136 :group 'mspools)
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
137
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
138 (defcustom mspools-using-vm (fboundp 'vm)
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
139 "*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
140 :type 'boolean
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
141 :group 'mspools)
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
142
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
143 (defcustom mspools-folder-directory
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
144 (if (boundp 'vm-folder-directory)
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
145 vm-folder-directory
21537
4a716088f0b4 (mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents: 20807
diff changeset
146 "~/MAIL/")
20807
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
147 "*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
148 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
149 :type 'directory
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
150 :group 'mspools)
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151
23996
aa6eab250ce8 (mspools-vm-system-mail): Provide an alternative value based on
Stephen Eglen <stephen@gnu.org>
parents: 23785
diff changeset
152 (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
153 (concat rmail-spool-directory
aa6eab250ce8 (mspools-vm-system-mail): Provide an alternative value based on
Stephen Eglen <stephen@gnu.org>
parents: 23785
diff changeset
154 (user-login-name)))
21537
4a716088f0b4 (mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents: 20807
diff changeset
155 "*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
156 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
157 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
158 $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
159 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
160 /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
161 :type 'file
4a716088f0b4 (mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents: 20807
diff changeset
162 :group 'mspools)
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
163
21537
4a716088f0b4 (mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents: 20807
diff changeset
164 ;;; Internal Variables
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166 (defvar mspools-files nil
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
167 "List of entries (SPOOL . SIZE) giving spool name and file size.")
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
168
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
169 (defvar mspools-files-len nil
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
170 "Length of `mspools-files' list.")
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
171
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
172 (defvar mspools-buffer "*spools*"
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
173 "Name of buffer for displaying spool info.")
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
174
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175 (defvar mspools-mode-map nil
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176 "Keymap for the *spools* buffer.")
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 ;;; Code
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
180 ;;; VM Specific code
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181 (if mspools-using-vm
19041
036cc3196550 (mspools-using-vm): Better handling of VM initialization.
Richard M. Stallman <rms@gnu.org>
parents: 19034
diff changeset
182 ;; 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
183 (progn
036cc3196550 (mspools-using-vm): Better handling of VM initialization.
Richard M. Stallman <rms@gnu.org>
parents: 19034
diff changeset
184 (require 'vm-vars)
21537
4a716088f0b4 (mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents: 20807
diff changeset
185 (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
186 (load-file vm-init-file))
036cc3196550 (mspools-using-vm): Better handling of VM initialization.
Richard M. Stallman <rms@gnu.org>
parents: 19034
diff changeset
187 (if (not mspools-folder-directory)
036cc3196550 (mspools-using-vm): Better handling of VM initialization.
Richard M. Stallman <rms@gnu.org>
parents: 19034
diff changeset
188 (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
189 ))
17905
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 (defun mspools-set-vm-spool-files ()
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192 "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
193 (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
194 (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
195 (if (null mspools-folder-directory)
4a716088f0b4 (mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents: 20807
diff changeset
196 (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
197 (setq
4a716088f0b4 (mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents: 20807
diff changeset
198 vm-spool-files
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199 (append
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200 (list
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
201 ;; Main mailbox
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
202 (list vm-primary-inbox
21537
4a716088f0b4 (mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents: 20807
diff changeset
203 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
204 vm-crash-box ;crash for mailbox
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
205 ))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 41161
diff changeset
206
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
207 ;; Mailing list inboxes
19041
036cc3196550 (mspools-using-vm): Better handling of VM initialization.
Richard M. Stallman <rms@gnu.org>
parents: 19034
diff changeset
208 ;; must have VM already loaded to get vm-folder-directory.
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209 (mapcar '(lambda (s)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210 "make the appropriate entry for vm-spool-files"
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
211 (list
21537
4a716088f0b4 (mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents: 20807
diff changeset
212 (concat mspools-folder-directory s)
4a716088f0b4 (mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents: 20807
diff changeset
213 (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
214 (concat mspools-folder-directory s ".crash")))
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
215 ;; So I create a vm-spool-files entry for each of those mail drops
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 41161
diff changeset
216 (mapcar 'file-name-sans-extension
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 41161
diff changeset
217 (directory-files mspools-folder-directory nil
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218 (format "^[^.]+\\.%s" mspools-suffix)))
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 ;;; 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
223 (defun mspools-show ( &optional noshow)
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
224 "Show the list of non-empty spool files in the *spools* buffer.
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
225 Buffer is not displayed if SHOW is non-nil."
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
226 (interactive)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
227 (if (get-buffer mspools-buffer)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
228 ;; buffer exists
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
229 (progn
21537
4a716088f0b4 (mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents: 20807
diff changeset
230 (set-buffer mspools-buffer)
4a716088f0b4 (mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents: 20807
diff changeset
231 (setq buffer-read-only nil)
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
232 (delete-region (point-min) (point-max)))
20807
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
233 ;; else buffer doesn't exist so create it
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
234 (get-buffer-create mspools-buffer))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 41161
diff changeset
235
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
236 ;; generate the list of spool files
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
237 (if mspools-using-vm
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
238 (mspools-set-vm-spool-files))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 41161
diff changeset
239
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
240 (mspools-get-spool-files)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
241 (if (not noshow) (pop-to-buffer mspools-buffer))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 41161
diff changeset
242
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
243 (setq buffer-read-only t)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
244 (mspools-mode)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
245 )
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
246
86440
4aedd218aad1 * mail/mspools.el (rmail-get-new-mail):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 85478
diff changeset
247 (declare-function rmail-get-new-mail "rmail" (&optional file-name))
4aedd218aad1 * mail/mspools.el (rmail-get-new-mail):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 85478
diff changeset
248
86813
48b3541f28c2 (vm-visit-folder): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 86440
diff changeset
249 ;; External.
48b3541f28c2 (vm-visit-folder): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 86440
diff changeset
250 (declare-function vm-visit-folder "ext:vm-startup" (folder &optional read-only))
48b3541f28c2 (vm-visit-folder): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 86440
diff changeset
251
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
252 (defun mspools-visit-spool ()
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
253 "Visit the folder on the current line of the *spools* buffer."
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
254 (interactive)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
255 (let ( spool-name folder-name)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
256 (setq spool-name (mspools-get-spool-name))
20807
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
257 (if (null spool-name)
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
258 (message "No spool on current line")
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 41161
diff changeset
259
20807
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
260 (setq folder-name (mspools-get-folder-from-spool spool-name))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 41161
diff changeset
261
20807
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
262 ;; 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
263 (if (not mspools-update)
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
264 (save-excursion
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
265 (setq buffer-read-only nil)
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
266 (beginning-of-line)
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
267 (insert "*")
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
268 (delete-char 1)
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
269 (setq buffer-read-only t)
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
270 ))
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
271
20807
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
272 (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
273 (if (eq (count-lines (point-min)
20807
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
274 (save-excursion
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
275 (end-of-line)
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
276 (point)))
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
277 mspools-files-len)
85478
786d3a985758 * term/x-win.el (x-gtk-stock-map, icon-map-list)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78477
diff changeset
278 (forward-line (- 1 mspools-files-len)) ;back to top of list
20807
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
279 ;; else just on to next line
85478
786d3a985758 * term/x-win.el (x-gtk-stock-map, icon-map-list)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78477
diff changeset
280 (forward-line 1))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 41161
diff changeset
281
20807
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
282 ;; 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
283 (if mspools-using-vm
20807
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
284 (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
285 ;; else using RMAIL
20807
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
286 (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
287 (setq rmail-inbox-list
20807
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
288 (list (concat mspools-folder-directory spool-name)))
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
289 (rmail-get-new-mail))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 41161
diff changeset
290
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 41161
diff changeset
291
20807
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
292 (if mspools-update
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
293 ;; 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
294 (save-excursion
20807
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
295 (mspools-show-again 'noshow))))))
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
296
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
297 (defun mspools-get-folder-from-spool (name)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
298 "Return folder name corresponding to the spool file NAME."
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
299 ;; Simply strip of the extension.
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
300 (file-name-sans-extension name))
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 ;; Alternative version if you have more complicated mapping of spool name
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
303 ;; to file name.
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
304 ;(defun get-folder-from-spool-safe (name)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
305 ; "Return the folder name corresponding to the spool file NAME."
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
306 ; (if (string-match "^\\(.*\\)\.spool$" name)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
307 ; (substring name (match-beginning 1) (match-end 1))
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
308 ; (error "Could not extract folder name from spool name %s" name)))
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
309
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
310 ; test
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
311 ;(mspools-get-folder-from-spool "happy.spool")
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
312 ;(mspools-get-folder-from-spool "happy.sp")
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-get-spool-name ()
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
315 "Return the name of the spool on the current line."
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
316 (let ((line-num (1- (count-lines (point-min)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
317 (save-excursion
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
318 (end-of-line)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
319 (point))
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
320 ))))
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
321 (car (nth line-num mspools-files))))
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
322
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
323 ;;; Keymap
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
324
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
325 (if mspools-mode-map
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
326 ()
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
327 (setq mspools-mode-map (make-sparse-keymap))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 41161
diff changeset
328
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
329 (define-key mspools-mode-map "\C-c\C-c" 'mspools-visit-spool)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
330 (define-key mspools-mode-map "\C-m" 'mspools-visit-spool)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
331 (define-key mspools-mode-map " " 'mspools-visit-spool)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
332 (define-key mspools-mode-map "?" 'mspools-help)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
333 (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
334 (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
335 (define-key mspools-mode-map "p" 'previous-line)
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
336 (define-key mspools-mode-map "g" 'revert-buffer))
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
337
21537
4a716088f0b4 (mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents: 20807
diff changeset
338 ;;; Spools mode functions
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
339
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
340 (defun mspools-revert-buffer (ignore noconfirm)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
341 "Re-run mspools-show to revert the *spools* buffer."
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
342 (mspools-show 'noshow))
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
343
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
344 (defun mspools-show-again (&optional noshow)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
345 "Update the *spools* buffer. This is useful if mspools-update is
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
346 nil."
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
347 (interactive)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
348 (mspools-show noshow))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 41161
diff changeset
349
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
350 (defun mspools-help ()
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
351 "Show help for `mspools-mode'."
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
352 (interactive)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
353 (describe-function 'mspools-mode))
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
354
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
355 (defun mspools-quit ()
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
356 "Quit the *spools* buffer."
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
357 (interactive)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
358 (kill-buffer mspools-buffer))
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
359
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
360 (defun mspools-mode ()
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
361 "Major mode for output from mspools-show.
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
362 \\<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
363 \\[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
364 \\[revert-buffer] to regenerate the list of spools.
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
365 \\{mspools-mode-map}"
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
366 (kill-all-local-variables)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
367 (make-local-variable 'revert-buffer-function)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
368 (setq revert-buffer-function 'mspools-revert-buffer)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
369 (use-local-map mspools-mode-map)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
370 (setq major-mode 'mspools-mode)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
371 (setq mode-name "MSpools")
63242
58b57765132c (mspools-mode): Use run-mode-hooks.
Lute Kamstra <lute@gnu.org>
parents: 52401
diff changeset
372 (run-mode-hooks 'mspools-mode-hook))
17905
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 (defun mspools-get-spool-files ()
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
375 "Find the list of spool files and display them in *spools* buffer."
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
376 (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
377 (if (null mspools-folder-directory)
4a716088f0b4 (mspools-folder-directory): Takes default value of ~/MAIL/ if
Stephen Eglen <stephen@gnu.org>
parents: 20807
diff changeset
378 (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
379 (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
380 (format "^[^.]+\\.%s$" mspools-suffix)))
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
381 (setq folders (mapcar 'mspools-size-folder folders))
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
382 (setq folders (delq nil folders))
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
383 (setq mspools-files folders)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
384 (setq mspools-files-len (length mspools-files))
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
385 (set-buffer mspools-buffer)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
386 (while folders
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
387 (setq any t)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
388 (setq head (car folders))
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
389 (setq spool (car head))
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
390 (setq len (cdr head))
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
391 (setq folders (cdr folders))
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
392 (setq beg (point))
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
393 (insert (format " %10d %s" len spool))
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
394 (setq end (point))
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
395 (insert "\n")
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
396 ;;(put-text-property beg end 'mouse-face 'highlight)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
397 )
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
398 (if any
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
399 (delete-char -1)) ;delete last RET
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
400 (goto-char (point-min))
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
401 ))
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
402
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
403 (defun mspools-size-folder (spool)
78477
0092d723fe35 Replace `iff' in doc-strings and comments.
Glenn Morris <rgm@gnu.org>
parents: 78232
diff changeset
404 "Return (SPOOL . SIZE ), if SIZE of spool file is non-zero."
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
405 ;; 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
406 (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
407 size)
036cc3196550 (mspools-using-vm): Better handling of VM initialization.
Richard M. Stallman <rms@gnu.org>
parents: 19034
diff changeset
408 (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
409 (setq size (nth 7 (file-attributes file)))
20807
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
410 ;; 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
411 ;; so check this first.
498136447303 File customized + doc fixes.
Stephen Eglen <stephen@gnu.org>
parents: 19042
diff changeset
412 (if (and size (> size 0))
17905
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
413 (cons spool size)
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
414 ;; else SPOOL is empty
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
415 nil)))
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
416
07602ad4416d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
417 (provide 'mspools)
38436
b174db545cfd Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 23996
diff changeset
418
93975
1e3a407766b9 Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
419 ;; arch-tag: 8990b3ee-68c8-4892-98f1-51a735c8bac6
19041
036cc3196550 (mspools-using-vm): Better handling of VM initialization.
Richard M. Stallman <rms@gnu.org>
parents: 19034
diff changeset
420 ;;; mspools.el ends here