diff options
| -rw-r--r-- | lisp/mail/mspools.el | 94 |
1 files changed, 40 insertions, 54 deletions
diff --git a/lisp/mail/mspools.el b/lisp/mail/mspools.el index 1185eeb2345..538f8aa0fe7 100644 --- a/lisp/mail/mspools.el +++ b/lisp/mail/mspools.el | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | ;; Maintainer: Stephen Eglen <stephen@cns.ed.ac.uk> | 6 | ;; Maintainer: Stephen Eglen <stephen@cns.ed.ac.uk> |
| 7 | ;; Created: 22 Jan 1997 | 7 | ;; Created: 22 Jan 1997 |
| 8 | ;; Keywords: mail | 8 | ;; Keywords: mail |
| 9 | ;; location: http://www.cns.ed.ac.uk/people/stephen/emacs/ | ||
| 9 | 10 | ||
| 10 | ;; This file is part of GNU Emacs. | 11 | ;; This file is part of GNU Emacs. |
| 11 | 12 | ||
| @@ -56,7 +57,6 @@ | |||
| 56 | ;; This file should work with both VM and RMAIL. See the variable | 57 | ;; This file should work with both VM and RMAIL. See the variable |
| 57 | ;; `mspools-using-vm' for details. | 58 | ;; `mspools-using-vm' for details. |
| 58 | 59 | ||
| 59 | |||
| 60 | ;;; Basic installation. | 60 | ;;; Basic installation. |
| 61 | ;; (autoload 'mspools-show "mspools" "Show outstanding mail spools." t) | 61 | ;; (autoload 'mspools-show "mspools" "Show outstanding mail spools." t) |
| 62 | ;; (setq mspools-folder-directory "~/MAIL/") | 62 | ;; (setq mspools-folder-directory "~/MAIL/") |
| @@ -65,9 +65,9 @@ | |||
| 65 | ;; unless you have already given it a value. | 65 | ;; unless you have already given it a value. |
| 66 | 66 | ||
| 67 | ;; Extras. | 67 | ;; Extras. |
| 68 | ;; | 68 | ;; |
| 69 | ;; (global-set-key '[S-f1] 'mspools-show) ;Bind mspools-show to Shift F1. | 69 | ;; (global-set-key '[S-f1] 'mspools-show) ;Bind mspools-show to Shift F1. |
| 70 | ;; (setq mspools-update t) ;Automatically update buffer. | 70 | ;; (setq mspools-update t) ;Automatically update buffer. |
| 71 | 71 | ||
| 72 | ;; Interface with the mail filter. | 72 | ;; Interface with the mail filter. |
| 73 | ;; We assume that the mail filter drops new mail into the spool | 73 | ;; We assume that the mail filter drops new mail into the spool |
| @@ -128,31 +128,29 @@ | |||
| 128 | :type 'string | 128 | :type 'string |
| 129 | :group 'mspools) | 129 | :group 'mspools) |
| 130 | 130 | ||
| 131 | |||
| 132 | (defcustom mspools-using-vm (fboundp 'vm) | 131 | (defcustom mspools-using-vm (fboundp 'vm) |
| 133 | "*Non-nil if VM is used as mail reader, otherwise RMAIL is used." | 132 | "*Non-nil if VM is used as mail reader, otherwise RMAIL is used." |
| 134 | :type 'boolean | 133 | :type 'boolean |
| 135 | :group 'mspools) | 134 | :group 'mspools) |
| 136 | 135 | ||
| 137 | |||
| 138 | (defcustom mspools-folder-directory | 136 | (defcustom mspools-folder-directory |
| 139 | (if (boundp 'vm-folder-directory) | 137 | (if (boundp 'vm-folder-directory) |
| 140 | vm-folder-directory | 138 | vm-folder-directory |
| 141 | nil) | 139 | "~/MAIL/") |
| 142 | "*Directory where mail folders are kept. Ensure it has a trailing /. | 140 | "*Directory where mail folders are kept. Ensure it has a trailing /. |
| 143 | Defaults to `vm-folder-directory' if bound else nil." | 141 | Defaults to `vm-folder-directory' if bound else to ~/MAIL/." |
| 144 | :type 'directory | 142 | :type 'directory |
| 145 | :group 'mspools) | 143 | :group 'mspools) |
| 146 | 144 | ||
| 147 | ;;; Internal Variables | 145 | (defcustom mspools-vm-system-mail (getenv "MAIL") |
| 148 | 146 | "*Spool file for main mailbox. Only used by VM. | |
| 149 | (defvar mspools-vm-system-mail (getenv "MAIL") | 147 | This needs to be set to your primary mail spool - mspools will not run |
| 150 | "Main mailbox used. Only used by VM.") | 148 | without it. By default this will be set to the environment variable |
| 149 | $MAIL. Otherwise set it to something like /usr/spool/mail/login-name." | ||
| 150 | :type 'file | ||
| 151 | :group 'mspools) | ||
| 151 | 152 | ||
| 152 | (defvar mspools-vm-system-mail-crash | 153 | ;;; Internal Variables |
| 153 | (concat mspools-vm-system-mail ".crash") | ||
| 154 | "Crash box for main mailbox. See also `mspools-vm-system-mail'. | ||
| 155 | Only used by VM." ) | ||
| 156 | 154 | ||
| 157 | (defvar mspools-files nil | 155 | (defvar mspools-files nil |
| 158 | "List of entries (SPOOL . SIZE) giving spool name and file size.") | 156 | "List of entries (SPOOL . SIZE) giving spool name and file size.") |
| @@ -173,7 +171,7 @@ Only used by VM." ) | |||
| 173 | ;; set up vm if not already loaded. | 171 | ;; set up vm if not already loaded. |
| 174 | (progn | 172 | (progn |
| 175 | (require 'vm-vars) | 173 | (require 'vm-vars) |
| 176 | (if (not vm-init-file-loaded) | 174 | (if (and (not vm-init-file-loaded) (file-readable-p vm-init-file)) |
| 177 | (load-file vm-init-file)) | 175 | (load-file vm-init-file)) |
| 178 | (if (not mspools-folder-directory) | 176 | (if (not mspools-folder-directory) |
| 179 | (setq mspools-folder-directory vm-folder-directory)) | 177 | (setq mspools-folder-directory vm-folder-directory)) |
| @@ -182,15 +180,17 @@ Only used by VM." ) | |||
| 182 | (defun mspools-set-vm-spool-files () | 180 | (defun mspools-set-vm-spool-files () |
| 183 | "Set value of `vm-spool-files'. Only needed for VM." | 181 | "Set value of `vm-spool-files'. Only needed for VM." |
| 184 | (if (null mspools-vm-system-mail) | 182 | (if (null mspools-vm-system-mail) |
| 185 | (error "need to reset mspools-vm-system-mail to the spool for primary inbox")) | 183 | (error "Need to set mspools-vm-system-mail to the spool for primary inbox")) |
| 186 | (setq | 184 | (if (null mspools-folder-directory) |
| 187 | vm-spool-files | 185 | (error "Set `mspools-folder-directory' to where the spool files are")) |
| 186 | (setq | ||
| 187 | vm-spool-files | ||
| 188 | (append | 188 | (append |
| 189 | (list | 189 | (list |
| 190 | ;; Main mailbox | 190 | ;; Main mailbox |
| 191 | (list vm-primary-inbox | 191 | (list vm-primary-inbox |
| 192 | mspools-vm-system-mail; your mailbox | 192 | mspools-vm-system-mail ; your mailbox |
| 193 | mspools-vm-system-mail-crash ; crash for mailbox | 193 | vm-crash-box ;crash for mailbox |
| 194 | )) | 194 | )) |
| 195 | 195 | ||
| 196 | ;; Mailing list inboxes | 196 | ;; Mailing list inboxes |
| @@ -198,28 +198,26 @@ Only used by VM." ) | |||
| 198 | (mapcar '(lambda (s) | 198 | (mapcar '(lambda (s) |
| 199 | "make the appropriate entry for vm-spool-files" | 199 | "make the appropriate entry for vm-spool-files" |
| 200 | (list | 200 | (list |
| 201 | (concat vm-folder-directory s) | 201 | (concat mspools-folder-directory s) |
| 202 | (concat vm-folder-directory s "." mspools-suffix) | 202 | (concat mspools-folder-directory s "." mspools-suffix) |
| 203 | (concat vm-folder-directory s ".crash"))) | 203 | (concat mspools-folder-directory s ".crash"))) |
| 204 | ;; So I create a vm-spool-files entry for each of those mail drops | 204 | ;; So I create a vm-spool-files entry for each of those mail drops |
| 205 | (mapcar 'file-name-sans-extension | 205 | (mapcar 'file-name-sans-extension |
| 206 | (directory-files vm-folder-directory nil | 206 | (directory-files mspools-folder-directory nil |
| 207 | (format "^[^.]+\\.%s" mspools-suffix))) | 207 | (format "^[^.]+\\.%s" mspools-suffix))) |
| 208 | )) | 208 | )) |
| 209 | )) | 209 | )) |
| 210 | 210 | ||
| 211 | |||
| 212 | |||
| 213 | ;;; MSPOOLS-SHOW -- the main function | 211 | ;;; MSPOOLS-SHOW -- the main function |
| 214 | (defun mspools-show ( &optional noshow) | 212 | (defun mspools-show ( &optional noshow) |
| 215 | "Show the list of non-empty spool files in the *spools* buffer. | 213 | "Show the list of non-empty spool files in the *spools* buffer. |
| 216 | Buffer is not displayed if SHOW is non-nil." | 214 | Buffer is not displayed if SHOW is non-nil." |
| 217 | (interactive) | 215 | (interactive) |
| 218 | (if (get-buffer mspools-buffer) | 216 | (if (get-buffer mspools-buffer) |
| 219 | ;; buffer exists | 217 | ;; buffer exists |
| 220 | (progn | 218 | (progn |
| 221 | (set-buffer mspools-buffer) | 219 | (set-buffer mspools-buffer) |
| 222 | (setq buffer-read-only nil) | 220 | (setq buffer-read-only nil) |
| 223 | (delete-region (point-min) (point-max))) | 221 | (delete-region (point-min) (point-max))) |
| 224 | ;; else buffer doesn't exist so create it | 222 | ;; else buffer doesn't exist so create it |
| 225 | (get-buffer-create mspools-buffer)) | 223 | (get-buffer-create mspools-buffer)) |
| @@ -235,9 +233,6 @@ Buffer is not displayed if SHOW is non-nil." | |||
| 235 | (mspools-mode) | 233 | (mspools-mode) |
| 236 | ) | 234 | ) |
| 237 | 235 | ||
| 238 | |||
| 239 | |||
| 240 | |||
| 241 | (defun mspools-visit-spool () | 236 | (defun mspools-visit-spool () |
| 242 | "Visit the folder on the current line of the *spools* buffer." | 237 | "Visit the folder on the current line of the *spools* buffer." |
| 243 | (interactive) | 238 | (interactive) |
| @@ -259,7 +254,7 @@ Buffer is not displayed if SHOW is non-nil." | |||
| 259 | )) | 254 | )) |
| 260 | 255 | ||
| 261 | (message "folder %s spool %s" folder-name spool-name) | 256 | (message "folder %s spool %s" folder-name spool-name) |
| 262 | (if (eq (count-lines (point-min) | 257 | (if (eq (count-lines (point-min) |
| 263 | (save-excursion | 258 | (save-excursion |
| 264 | (end-of-line) | 259 | (end-of-line) |
| 265 | (point))) | 260 | (point))) |
| @@ -269,24 +264,20 @@ Buffer is not displayed if SHOW is non-nil." | |||
| 269 | (next-line 1)) | 264 | (next-line 1)) |
| 270 | 265 | ||
| 271 | ;; Choose whether to use VM or RMAIL for reading folder. | 266 | ;; Choose whether to use VM or RMAIL for reading folder. |
| 272 | (if mspools-using-vm | 267 | (if mspools-using-vm |
| 273 | (vm-visit-folder (concat mspools-folder-directory folder-name)) | 268 | (vm-visit-folder (concat mspools-folder-directory folder-name)) |
| 274 | ;; else using RMAIL | 269 | ;; else using RMAIL |
| 275 | (rmail (concat mspools-folder-directory folder-name)) | 270 | (rmail (concat mspools-folder-directory folder-name)) |
| 276 | (setq rmail-inbox-list | 271 | (setq rmail-inbox-list |
| 277 | (list (concat mspools-folder-directory spool-name))) | 272 | (list (concat mspools-folder-directory spool-name))) |
| 278 | (rmail-get-new-mail)) | 273 | (rmail-get-new-mail)) |
| 279 | 274 | ||
| 280 | 275 | ||
| 281 | (if mspools-update | 276 | (if mspools-update |
| 282 | ;; generate new list of spools. | 277 | ;; generate new list of spools. |
| 283 | (save-excursion | 278 | (save-excursion |
| 284 | (mspools-show-again 'noshow)))))) | 279 | (mspools-show-again 'noshow)))))) |
| 285 | 280 | ||
| 286 | |||
| 287 | |||
| 288 | |||
| 289 | |||
| 290 | (defun mspools-get-folder-from-spool (name) | 281 | (defun mspools-get-folder-from-spool (name) |
| 291 | "Return folder name corresponding to the spool file NAME." | 282 | "Return folder name corresponding to the spool file NAME." |
| 292 | ;; Simply strip of the extension. | 283 | ;; Simply strip of the extension. |
| @@ -304,8 +295,6 @@ Buffer is not displayed if SHOW is non-nil." | |||
| 304 | ;(mspools-get-folder-from-spool "happy.spool") | 295 | ;(mspools-get-folder-from-spool "happy.spool") |
| 305 | ;(mspools-get-folder-from-spool "happy.sp") | 296 | ;(mspools-get-folder-from-spool "happy.sp") |
| 306 | 297 | ||
| 307 | |||
| 308 | |||
| 309 | (defun mspools-get-spool-name () | 298 | (defun mspools-get-spool-name () |
| 310 | "Return the name of the spool on the current line." | 299 | "Return the name of the spool on the current line." |
| 311 | (let ((line-num (1- (count-lines (point-min) | 300 | (let ((line-num (1- (count-lines (point-min) |
| @@ -326,10 +315,11 @@ Buffer is not displayed if SHOW is non-nil." | |||
| 326 | (define-key mspools-mode-map " " 'mspools-visit-spool) | 315 | (define-key mspools-mode-map " " 'mspools-visit-spool) |
| 327 | (define-key mspools-mode-map "?" 'mspools-help) | 316 | (define-key mspools-mode-map "?" 'mspools-help) |
| 328 | (define-key mspools-mode-map "q" 'mspools-quit) | 317 | (define-key mspools-mode-map "q" 'mspools-quit) |
| 318 | (define-key mspools-mode-map "n" 'next-line) | ||
| 319 | (define-key mspools-mode-map "p" 'previous-line) | ||
| 329 | (define-key mspools-mode-map "g" 'revert-buffer)) | 320 | (define-key mspools-mode-map "g" 'revert-buffer)) |
| 330 | 321 | ||
| 331 | 322 | ;;; Spools mode functions | |
| 332 | ;;; Spools mode functions | ||
| 333 | 323 | ||
| 334 | (defun mspools-revert-buffer (ignore noconfirm) | 324 | (defun mspools-revert-buffer (ignore noconfirm) |
| 335 | "Re-run mspools-show to revert the *spools* buffer." | 325 | "Re-run mspools-show to revert the *spools* buffer." |
| @@ -350,7 +340,6 @@ nil." | |||
| 350 | "Quit the *spools* buffer." | 340 | "Quit the *spools* buffer." |
| 351 | (interactive) | 341 | (interactive) |
| 352 | (kill-buffer mspools-buffer)) | 342 | (kill-buffer mspools-buffer)) |
| 353 | |||
| 354 | 343 | ||
| 355 | (defun mspools-mode () | 344 | (defun mspools-mode () |
| 356 | "Major mode for output from mspools-show. | 345 | "Major mode for output from mspools-show. |
| @@ -366,14 +355,13 @@ nil." | |||
| 366 | (setq mode-name "MSpools") | 355 | (setq mode-name "MSpools") |
| 367 | ) | 356 | ) |
| 368 | 357 | ||
| 369 | |||
| 370 | (defun mspools-get-spool-files () | 358 | (defun mspools-get-spool-files () |
| 371 | "Find the list of spool files and display them in *spools* buffer." | 359 | "Find the list of spool files and display them in *spools* buffer." |
| 372 | (let (folders head spool len beg end any) | 360 | (let (folders head spool len beg end any) |
| 373 | (setq folders (directory-files mspools-folder-directory nil | 361 | (if (null mspools-folder-directory) |
| 374 | (format "^[^.]+\\.%s" mspools-suffix))) | 362 | (error "Set `mspools-folder-directory' to where the spool files are")) |
| 375 | 363 | (setq folders (directory-files mspools-folder-directory nil | |
| 376 | 364 | (format "^[^.]+\\.%s$" mspools-suffix))) | |
| 377 | (setq folders (mapcar 'mspools-size-folder folders)) | 365 | (setq folders (mapcar 'mspools-size-folder folders)) |
| 378 | (setq folders (delq nil folders)) | 366 | (setq folders (delq nil folders)) |
| 379 | (setq mspools-files folders) | 367 | (setq mspools-files folders) |
| @@ -396,8 +384,6 @@ nil." | |||
| 396 | (goto-char (point-min)) | 384 | (goto-char (point-min)) |
| 397 | )) | 385 | )) |
| 398 | 386 | ||
| 399 | |||
| 400 | |||
| 401 | (defun mspools-size-folder (spool) | 387 | (defun mspools-size-folder (spool) |
| 402 | "Return (SPOOL . SIZE ) iff SIZE of spool file is non-zero." | 388 | "Return (SPOOL . SIZE ) iff SIZE of spool file is non-zero." |
| 403 | ;; 7th file attribute is the size of the file in bytes. | 389 | ;; 7th file attribute is the size of the file in bytes. |