X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/aaf34461ff5804e5cebe163b31e535da72e81d87..bb13183c1bb56724fc3c4ab5ed8f1eaf6ed5338d:/lisp/mail/mspools.el diff --git a/lisp/mail/mspools.el b/lisp/mail/mspools.el index 988ce2f8e0..ddd5414de7 100644 --- a/lisp/mail/mspools.el +++ b/lisp/mail/mspools.el @@ -1,7 +1,6 @@ ;;; mspools.el --- show mail spools waiting to be read -;; Copyright (C) 1997, 2001, 2002, 2003, 2004, 2005, -;; 2006, 2007 Free Software Foundation, Inc. +;; Copyright (C) 1997, 2001-2015 Free Software Foundation, Inc. ;; Author: Stephen Eglen ;; Maintainer: Stephen Eglen @@ -11,10 +10,10 @@ ;; This file is part of GNU Emacs. -;; GNU Emacs is free software; you can redistribute it and/or modify +;; GNU Emacs is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 3, or (at your option) -;; any later version. +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. ;; GNU Emacs is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -22,9 +21,7 @@ ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -;; Boston, MA 02110-1301, USA. +;; along with GNU Emacs. If not, see . ;;; Commentary: @@ -86,7 +83,7 @@ ;; Useful settings for VM ;; vm-auto-get-new-mail should be t (the default). -;; Acknowledgements +;; Acknowledgments ;; Thanks to jond@mitre.org (Jonathan Doughty) for help with code for ;; setting up vm-spool-files. @@ -105,7 +102,7 @@ ;; Rather than showing size in bytes, could we see the number of msgs ;; waiting? (Could be more time demanding / system dependent). ;; Maybe just call a perl script to do all the hard work, and -;; visualise the results in the buffer. +;; visualize the results in the buffer. ;; Shrink wrap the buffer to remove excess white-space? @@ -128,17 +125,17 @@ ) (defcustom mspools-update nil - "*Non-nil means update *spools* buffer after visiting any folder." + "Non-nil means update *spools* buffer after visiting any folder." :type 'boolean :group 'mspools) (defcustom mspools-suffix "spool" - "*Extension used for spool files (not including full stop)." + "Extension used for spool files (not including full stop)." :type 'string :group 'mspools) (defcustom mspools-using-vm (fboundp 'vm) - "*Non-nil if VM is used as mail reader, otherwise RMAIL is used." + "Non-nil if VM is used as mail reader, otherwise RMAIL is used." :type 'boolean :group 'mspools) @@ -146,7 +143,7 @@ (if (boundp 'vm-folder-directory) vm-folder-directory "~/MAIL/") - "*Directory where mail folders are kept. Ensure it has a trailing /. + "Directory where mail folders are kept. Ensure it has a trailing /. Defaults to `vm-folder-directory' if bound else to ~/MAIL/." :type 'directory :group 'mspools) @@ -154,7 +151,7 @@ Defaults to `vm-folder-directory' if bound else to ~/MAIL/." (defcustom mspools-vm-system-mail (or (getenv "MAIL") (concat rmail-spool-directory (user-login-name))) - "*Spool file for main mailbox. Only used by VM. + "Spool file for main mailbox. Only used by VM. This needs to be set to your primary mail spool - mspools will not run without it. By default this will be set to the environment variable $MAIL. Otherwise it will use `rmail-spool-directory' to guess where @@ -174,7 +171,17 @@ your primary spool is. If this fails, set it to something like (defvar mspools-buffer "*spools*" "Name of buffer for displaying spool info.") -(defvar mspools-mode-map nil +(defvar mspools-mode-map + (let ((map (make-sparse-keymap))) + (define-key map "\C-c\C-c" 'mspools-visit-spool) + (define-key map "\C-m" 'mspools-visit-spool) + (define-key map " " 'mspools-visit-spool) + (define-key map "?" 'mspools-help) + (define-key map "q" 'mspools-quit) + (define-key map "n" 'next-line) + (define-key map "p" 'previous-line) + (define-key map "g" 'revert-buffer) + map) "Keymap for the *spools* buffer.") ;;; Code @@ -208,12 +215,12 @@ your primary spool is. If this fails, set it to something like ;; Mailing list inboxes ;; must have VM already loaded to get vm-folder-directory. - (mapcar '(lambda (s) - "make the appropriate entry for vm-spool-files" - (list - (concat mspools-folder-directory s) - (concat mspools-folder-directory s "." mspools-suffix) - (concat mspools-folder-directory s ".crash"))) + (mapcar (lambda (s) + "make the appropriate entry for vm-spool-files" + (list + (concat mspools-folder-directory s) + (concat mspools-folder-directory s "." mspools-suffix) + (concat mspools-folder-directory s ".crash"))) ;; So I create a vm-spool-files entry for each of those mail drops (mapcar 'file-name-sans-extension (directory-files mspools-folder-directory nil @@ -246,6 +253,11 @@ Buffer is not displayed if SHOW is non-nil." (mspools-mode) ) +(declare-function rmail-get-new-mail "rmail" (&optional file-name)) + +;; External. +(declare-function vm-visit-folder "ext:vm-startup" (folder &optional read-only)) + (defun mspools-visit-spool () "Visit the folder on the current line of the *spools* buffer." (interactive) @@ -267,14 +279,11 @@ Buffer is not displayed if SHOW is non-nil." )) (message "folder %s spool %s" folder-name spool-name) - (if (eq (count-lines (point-min) - (save-excursion - (end-of-line) - (point))) + (if (eq (count-lines (point-min) (point-at-eol)) mspools-files-len) - (next-line (- 1 mspools-files-len)) ;back to top of list + (forward-line (- 1 mspools-files-len)) ;back to top of list ;; else just on to next line - (next-line 1)) + (forward-line 1)) ;; Choose whether to use VM or RMAIL for reading folder. (if mspools-using-vm @@ -310,28 +319,9 @@ Buffer is not displayed if SHOW is non-nil." (defun mspools-get-spool-name () "Return the name of the spool on the current line." - (let ((line-num (1- (count-lines (point-min) - (save-excursion - (end-of-line) - (point)) - )))) + (let ((line-num (1- (count-lines (point-min) (point-at-eol))))) (car (nth line-num mspools-files)))) -;;; Keymap - -(if mspools-mode-map - () - (setq mspools-mode-map (make-sparse-keymap)) - - (define-key mspools-mode-map "\C-c\C-c" 'mspools-visit-spool) - (define-key mspools-mode-map "\C-m" 'mspools-visit-spool) - (define-key mspools-mode-map " " 'mspools-visit-spool) - (define-key mspools-mode-map "?" 'mspools-help) - (define-key mspools-mode-map "q" 'mspools-quit) - (define-key mspools-mode-map "n" 'next-line) - (define-key mspools-mode-map "p" 'previous-line) - (define-key mspools-mode-map "g" 'revert-buffer)) - ;;; Spools mode functions (defun mspools-revert-buffer (ignore noconfirm) @@ -354,19 +344,13 @@ nil." (interactive) (kill-buffer mspools-buffer)) -(defun mspools-mode () +(define-derived-mode mspools-mode special-mode "MSpools" "Major mode for output from mspools-show. \\Move point to one of the items in this buffer, then use \\[mspools-visit-spool] to go to the spool that the current line refers to. \\[revert-buffer] to regenerate the list of spools. \\{mspools-mode-map}" - (kill-all-local-variables) - (make-local-variable 'revert-buffer-function) - (setq revert-buffer-function 'mspools-revert-buffer) - (use-local-map mspools-mode-map) - (setq major-mode 'mspools-mode) - (setq mode-name "MSpools") - (run-mode-hooks 'mspools-mode-hook)) + (setq-local revert-buffer-function 'mspools-revert-buffer)) (defun mspools-get-spool-files () "Find the list of spool files and display them in *spools* buffer." @@ -413,5 +397,4 @@ nil." (provide 'mspools) -;;; arch-tag: 8990b3ee-68c8-4892-98f1-51a735c8bac6 ;;; mspools.el ends here