diff options
| author | Stephen Eglen | 1998-02-01 17:10:21 +0000 |
|---|---|---|
| committer | Stephen Eglen | 1998-02-01 17:10:21 +0000 |
| commit | 3fb11d36e30a2bf842f164a2c08337718483e3c8 (patch) | |
| tree | 44ba90b2f86e496d5b22558a03118ee98e3a838e | |
| parent | bdb1c08fb956fe149cfdf609f7f152c2ec152992 (diff) | |
| download | emacs-3fb11d36e30a2bf842f164a2c08337718483e3c8.tar.gz emacs-3fb11d36e30a2bf842f164a2c08337718483e3c8.zip | |
File customized + doc fixes.
| -rw-r--r-- | lisp/mail/mspools.el | 204 |
1 files changed, 107 insertions, 97 deletions
diff --git a/lisp/mail/mspools.el b/lisp/mail/mspools.el index c881ad4a5b5..1185eeb2345 100644 --- a/lisp/mail/mspools.el +++ b/lisp/mail/mspools.el | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | ;;; mspools.el --- Show mail spools waiting to be read | 1 | ;;; mspools.el --- show mail spools waiting to be read. |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1997 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1997 Free Software Foundation, Inc. |
| 4 | 4 | ||
| @@ -57,73 +57,92 @@ | |||
| 57 | ;; `mspools-using-vm' for details. | 57 | ;; `mspools-using-vm' for details. |
| 58 | 58 | ||
| 59 | 59 | ||
| 60 | ;;; Installation | 60 | ;;; Basic installation. |
| 61 | 61 | ;; (autoload 'mspools-show "mspools" "Show outstanding mail spools." t) | |
| 62 | ;; Basic | 62 | ;; (setq mspools-folder-directory "~/MAIL/") |
| 63 | ;(autoload 'mspools-show "mspools" "Show outstanding mail spools." t) | 63 | ;; |
| 64 | ; Point to directory where spool files and folders are: | 64 | ;; If you use VM, mspools-folder-directory will default to vm-folder-directory |
| 65 | ; (setq mspools-folder-directory "~/MAIL/") | 65 | ;; unless you have already given it a value. |
| 66 | ; | 66 | |
| 67 | ; If you use VM, mspools-folder-directory will default to vm-folder-directory | 67 | ;; Extras. |
| 68 | ; unless you have already given it a value. | 68 | ;; |
| 69 | 69 | ;; (global-set-key '[S-f1] 'mspools-show) ;Bind mspools-show to Shift F1. | |
| 70 | ;; Extras | 70 | ;; (setq mspools-update t) ;Automatically update buffer. |
| 71 | ; possibly bind it to a key: | 71 | |
| 72 | ;(global-set-key '[S-f1] 'mspools-show) | 72 | ;; Interface with the mail filter. |
| 73 | ;(setq mspools-update t) | 73 | ;; We assume that the mail filter drops new mail into the spool |
| 74 | 74 | ;; `folder.spool'. If your spool files are something like folder.xyz | |
| 75 | ;; Interface with the mail filter | 75 | ;; for inbox `folder', then do: |
| 76 | ; We assume that the mail filter drops new mail into the spool | 76 | ;; (setq mspools-suffix "xyz") |
| 77 | ; `folder.spool'. If your spool files are something like folder.xyz | 77 | ;; If you use other conventions for your spool files, this code will |
| 78 | ; for inbox `folder', then do | 78 | ;; need rewriting. |
| 79 | ; (setq spool-suffix "xyz") | 79 | |
| 80 | ; If you use other conventions for your spool files, this code will | 80 | ;; Warning for VM users |
| 81 | ; need rewriting. | 81 | ;; Don't use if you are not sure what you are doing. The value of |
| 82 | |||
| 83 | ;;; Warning for VM users | ||
| 84 | ;; Dont use if you are not sure what you are doing! The value of | ||
| 85 | ;; vm-spool-files is altered, so you may not be able to read incoming | 82 | ;; vm-spool-files is altered, so you may not be able to read incoming |
| 86 | ;; mail with VM if this is incorrectly set. | 83 | ;; mail with VM if this is incorrectly set. |
| 87 | 84 | ||
| 88 | ;; Useful settings for VM | 85 | ;; Useful settings for VM |
| 89 | ;vm-auto-get-new-mail should be t (default t) | 86 | ;; vm-auto-get-new-mail should be t (the default). |
| 90 | 87 | ||
| 91 | ;;; Acknowledgements | 88 | ;; Acknowledgements |
| 92 | ;; The code for setting up vm-spool-files came from | 89 | ;; Thanks to jond@mitre.org (Jonathan Doughty) for help with code for |
| 93 | ;;http://www-users.informatik.rwth-aachen.de/~berg/archive/procmail/0047.html | 90 | ;; setting up vm-spool-files. |
| 94 | ;; Thanks to jond@mitre.org (Jonathan Doughty) | ||
| 95 | 91 | ||
| 96 | ;;; TODO | 92 | ;;; TODO |
| 97 | 93 | ||
| 98 | ;; What if users have mail spools in more than one directory? Extend | 94 | ;; What if users have mail spools in more than one directory? Extend |
| 99 | ;; mspools-folder-directory to be a list of files? | 95 | ;; mspools-folder-directory to be a list of directories? Currently, |
| 96 | ;; if mail spools are in other directories, the way to read them is to | ||
| 97 | ;; put a symbolic link to the spool into the mspools-folder-directory. | ||
| 100 | 98 | ||
| 101 | ;; I was going to add mouse support so that you could click on a line | 99 | ;; I was going to add mouse support so that you could click on a line |
| 102 | ;; to visit the buffer. Tell me if you want it, and I can put the | 100 | ;; to visit the buffer. Tell me if you want it, and I can put the |
| 103 | ;; code in (I dont use the mouse much, so I havent bothered with it so | 101 | ;; code in (I don't use the mouse much, so I haven't bothered with it |
| 104 | ;; far). | 102 | ;; so far). |
| 105 | |||
| 106 | 103 | ||
| 107 | ;; Rather than showing size in bytes, could we see the number of msgs | 104 | ;; Rather than showing size in bytes, could we see the number of msgs |
| 108 | ;; waiting? (Could be more time demanding / system dependent). | 105 | ;; waiting? (Could be more time demanding / system dependent). |
| 109 | ;; Perl script counts the number of /^From / occurences. | ||
| 110 | ;; ? | ||
| 111 | ;; Include date | ||
| 112 | ;; (substring (current-time-string (nth 4 (file-attributes "~/INBOX"))) 4 19) | ||
| 113 | ;; Maybe just call a perl script to do all the hard work, and | 106 | ;; Maybe just call a perl script to do all the hard work, and |
| 114 | ;; visualise the results in the buffer. | 107 | ;; visualise the results in the buffer. |
| 115 | 108 | ||
| 116 | ;; Shrink wrap the buffer to remove excess white-space? | 109 | ;; Shrink wrap the buffer to remove excess white-space? |
| 117 | 110 | ||
| 111 | ;;; Code: | ||
| 118 | 112 | ||
| 119 | ;;; User Variables | 113 | ;;; User Variables |
| 120 | 114 | ||
| 115 | (defgroup mspools nil | ||
| 116 | "Show mail spools waiting to be read." | ||
| 117 | :group 'mail | ||
| 118 | :link '(emacs-commentary-link :tag "Commentary" "mspools.el") | ||
| 119 | ) | ||
| 120 | |||
| 121 | (defcustom mspools-update nil | ||
| 122 | "*Non-nil means update *spools* buffer after visiting any folder." | ||
| 123 | :type 'boolean | ||
| 124 | :group 'mspools) | ||
| 125 | |||
| 126 | (defcustom mspools-suffix "spool" | ||
| 127 | "*Extension used for spool files (not including full stop)." | ||
| 128 | :type 'string | ||
| 129 | :group 'mspools) | ||
| 121 | 130 | ||
| 122 | (defvar mspools-update nil | ||
| 123 | "*Non-nil means update *spools* buffer after visiting any folder.") | ||
| 124 | 131 | ||
| 125 | (defvar mspools-suffix "spool" | 132 | (defcustom mspools-using-vm (fboundp 'vm) |
| 126 | "*Extension used for spool files (not including full stop).") | 133 | "*Non-nil if VM is used as mail reader, otherwise RMAIL is used." |
| 134 | :type 'boolean | ||
| 135 | :group 'mspools) | ||
| 136 | |||
| 137 | |||
| 138 | (defcustom mspools-folder-directory | ||
| 139 | (if (boundp 'vm-folder-directory) | ||
| 140 | vm-folder-directory | ||
| 141 | nil) | ||
| 142 | "*Directory where mail folders are kept. Ensure it has a trailing /. | ||
| 143 | Defaults to `vm-folder-directory' if bound else nil." | ||
| 144 | :type 'directory | ||
| 145 | :group 'mspools) | ||
| 127 | 146 | ||
| 128 | ;;; Internal Variables | 147 | ;;; Internal Variables |
| 129 | 148 | ||
| @@ -135,7 +154,6 @@ | |||
| 135 | "Crash box for main mailbox. See also `mspools-vm-system-mail'. | 154 | "Crash box for main mailbox. See also `mspools-vm-system-mail'. |
| 136 | Only used by VM." ) | 155 | Only used by VM." ) |
| 137 | 156 | ||
| 138 | |||
| 139 | (defvar mspools-files nil | 157 | (defvar mspools-files nil |
| 140 | "List of entries (SPOOL . SIZE) giving spool name and file size.") | 158 | "List of entries (SPOOL . SIZE) giving spool name and file size.") |
| 141 | 159 | ||
| @@ -148,20 +166,6 @@ Only used by VM." ) | |||
| 148 | (defvar mspools-mode-map nil | 166 | (defvar mspools-mode-map nil |
| 149 | "Keymap for the *spools* buffer.") | 167 | "Keymap for the *spools* buffer.") |
| 150 | 168 | ||
| 151 | (defvar mspools-folder-directory | ||
| 152 | (if (boundp 'vm-folder-directory) | ||
| 153 | vm-folder-directory | ||
| 154 | nil) | ||
| 155 | "Directory where mail folders are kept. Defaults to | ||
| 156 | `vm-folder-directory' if bound else nil. Make sure it has a trailing / | ||
| 157 | at the end. ") | ||
| 158 | |||
| 159 | |||
| 160 | (defvar mspools-using-vm | ||
| 161 | (fboundp 'vm) | ||
| 162 | "*Non-nil if VM is used as mail reader, otherwise RMAIL is used.") | ||
| 163 | |||
| 164 | |||
| 165 | ;;; Code | 169 | ;;; Code |
| 166 | 170 | ||
| 167 | ;;; VM Specific code | 171 | ;;; VM Specific code |
| @@ -177,6 +181,8 @@ at the end. ") | |||
| 177 | 181 | ||
| 178 | (defun mspools-set-vm-spool-files () | 182 | (defun mspools-set-vm-spool-files () |
| 179 | "Set value of `vm-spool-files'. Only needed for VM." | 183 | "Set value of `vm-spool-files'. Only needed for VM." |
| 184 | (if (null mspools-vm-system-mail) | ||
| 185 | (error "need to reset mspools-vm-system-mail to the spool for primary inbox")) | ||
| 180 | (setq | 186 | (setq |
| 181 | vm-spool-files | 187 | vm-spool-files |
| 182 | (append | 188 | (append |
| @@ -215,7 +221,7 @@ Buffer is not displayed if SHOW is non-nil." | |||
| 215 | (set-buffer mspools-buffer) | 221 | (set-buffer mspools-buffer) |
| 216 | (setq buffer-read-only nil) | 222 | (setq buffer-read-only nil) |
| 217 | (delete-region (point-min) (point-max))) | 223 | (delete-region (point-min) (point-max))) |
| 218 | ;; else buff. doesnt exist so create it | 224 | ;; else buffer doesn't exist so create it |
| 219 | (get-buffer-create mspools-buffer)) | 225 | (get-buffer-create mspools-buffer)) |
| 220 | 226 | ||
| 221 | ;; generate the list of spool files | 227 | ;; generate the list of spool files |
| @@ -237,44 +243,46 @@ Buffer is not displayed if SHOW is non-nil." | |||
| 237 | (interactive) | 243 | (interactive) |
| 238 | (let ( spool-name folder-name) | 244 | (let ( spool-name folder-name) |
| 239 | (setq spool-name (mspools-get-spool-name)) | 245 | (setq spool-name (mspools-get-spool-name)) |
| 240 | (setq folder-name (mspools-get-folder-from-spool spool-name)) | 246 | (if (null spool-name) |
| 241 | 247 | (message "No spool on current line") | |
| 242 | ;; put in a little "*" to indicate spool file has been read. | 248 | |
| 243 | (if (not mspools-update) | 249 | (setq folder-name (mspools-get-folder-from-spool spool-name)) |
| 244 | (save-excursion | 250 | |
| 245 | (setq buffer-read-only nil) | 251 | ;; put in a little "*" to indicate spool file has been read. |
| 246 | (beginning-of-line) | 252 | (if (not mspools-update) |
| 247 | (insert "*") | 253 | (save-excursion |
| 248 | (delete-char 1) | 254 | (setq buffer-read-only nil) |
| 249 | (setq buffer-read-only t) | 255 | (beginning-of-line) |
| 250 | )) | 256 | (insert "*") |
| 251 | 257 | (delete-char 1) | |
| 258 | (setq buffer-read-only t) | ||
| 259 | )) | ||
| 260 | |||
| 261 | (message "folder %s spool %s" folder-name spool-name) | ||
| 262 | (if (eq (count-lines (point-min) | ||
| 263 | (save-excursion | ||
| 264 | (end-of-line) | ||
| 265 | (point))) | ||
| 266 | mspools-files-len) | ||
| 267 | (next-line (- 1 mspools-files-len)) ;back to top of list | ||
| 268 | ;; else just on to next line | ||
| 269 | (next-line 1)) | ||
| 270 | |||
| 271 | ;; Choose whether to use VM or RMAIL for reading folder. | ||
| 272 | (if mspools-using-vm | ||
| 273 | (vm-visit-folder (concat mspools-folder-directory folder-name)) | ||
| 274 | ;; else using RMAIL | ||
| 275 | (rmail (concat mspools-folder-directory folder-name)) | ||
| 276 | (setq rmail-inbox-list | ||
| 277 | (list (concat mspools-folder-directory spool-name))) | ||
| 278 | (rmail-get-new-mail)) | ||
| 279 | |||
| 280 | |||
| 281 | (if mspools-update | ||
| 282 | ;; generate new list of spools. | ||
| 283 | (save-excursion | ||
| 284 | (mspools-show-again 'noshow)))))) | ||
| 252 | 285 | ||
| 253 | (message "folder %s spool %s" folder-name spool-name) | ||
| 254 | (if (eq (count-lines (point-min) | ||
| 255 | (save-excursion | ||
| 256 | (end-of-line) | ||
| 257 | (point))) | ||
| 258 | mspools-files-len) | ||
| 259 | (next-line (- 1 mspools-files-len)) ;back to top of list | ||
| 260 | ;; else just on to next line | ||
| 261 | (next-line 1)) | ||
| 262 | |||
| 263 | ;; Choose whether to use VM or RMAIL for reading folder. | ||
| 264 | (if mspools-using-vm | ||
| 265 | (vm-visit-folder (concat mspools-folder-directory folder-name)) | ||
| 266 | ;; else using RMAIL | ||
| 267 | (rmail (concat mspools-folder-directory folder-name)) | ||
| 268 | (setq rmail-inbox-list | ||
| 269 | (list (concat mspools-folder-directory spool-name))) | ||
| 270 | (rmail-get-new-mail)) | ||
| 271 | |||
| 272 | |||
| 273 | (if mspools-update | ||
| 274 | ;; generate new list of spools. | ||
| 275 | (save-excursion | ||
| 276 | (mspools-show-again 'noshow))) | ||
| 277 | )) | ||
| 278 | 286 | ||
| 279 | 287 | ||
| 280 | 288 | ||
| @@ -397,7 +405,9 @@ nil." | |||
| 397 | size) | 405 | size) |
| 398 | (setq file (or (file-symlink-p file) file)) | 406 | (setq file (or (file-symlink-p file) file)) |
| 399 | (setq size (nth 7 (file-attributes file))) | 407 | (setq size (nth 7 (file-attributes file))) |
| 400 | (if (> size 0) | 408 | ;; size could be nil if the sym-link points to a non-existent file |
| 409 | ;; so check this first. | ||
| 410 | (if (and size (> size 0)) | ||
| 401 | (cons spool size) | 411 | (cons spool size) |
| 402 | ;; else SPOOL is empty | 412 | ;; else SPOOL is empty |
| 403 | nil))) | 413 | nil))) |