-;;; mspools.el --- show mail spools waiting to be read
+;;; mspools.el --- show mail spools waiting to be read -*- lexical-binding: t; -*-
;; Copyright (C) 1997, 2001-2020 Free Software Foundation, Inc.
(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.")
(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
+ (mapcar #'file-name-sans-extension
(directory-files mspools-folder-directory nil
(format "\\`[^.]+\\.%s" mspools-suffix)))
))
))
;;; MSPOOLS-SHOW -- the main function
-(defun mspools-show ( &optional noshow)
+;;;###autoload
+(defun mspools-show (&optional noshow)
"Show the list of non-empty spool files in the *spools* buffer.
Buffer is not displayed if SHOW is non-nil."
(interactive)
(progn
(set-buffer mspools-buffer)
(setq buffer-read-only nil)
- (delete-region (point-min) (point-max)))
+ (erase-buffer))
;; else buffer doesn't exist so create it
(get-buffer-create mspools-buffer))
(defun mspools-visit-spool ()
"Visit the folder on the current line of the *spools* buffer."
(interactive)
- (let ( spool-name folder-name)
- (setq spool-name (mspools-get-spool-name))
+ (let ((spool-name (mspools-get-spool-name))
+ folder-name)
(if (null spool-name)
(message "No spool on current line")
;; put in a little "*" to indicate spool file has been read.
(if (not mspools-update)
(save-excursion
- (setq buffer-read-only nil)
(beginning-of-line)
- (insert "*")
- (delete-char 1)
- (setq buffer-read-only t)
- ))
+ (let ((inhibit-read-only t))
+ (insert "*")
+ (delete-char 1))))
(message "folder %s spool %s" folder-name spool-name)
- (if (eq (count-lines (point-min) (point-at-eol))
- mspools-files-len)
- (forward-line (- 1 mspools-files-len)) ;back to top of list
- ;; else just on to next line
- (forward-line 1))
+ (forward-line (if (eq (count-lines (point-min) (point-at-eol))
+ mspools-files-len)
+ ;; FIXME: Why use `mspools-files-len' instead
+ ;; of looking if we're on the last line and
+ ;; jumping to the first one if so?
+ (- 1 mspools-files-len) ;back to top of list
+ ;; else just on to next line
+ 1))
;; Choose whether to use VM or RMAIL for reading folder.
(if mspools-using-vm
(if mspools-update
;; generate new list of spools.
- (save-excursion
- (mspools-show-again 'noshow))))))
+ (save-excursion ;;FIXME: Why?
+ (mspools-revert-buffer))))))
(defun mspools-get-folder-from-spool (name)
"Return folder name corresponding to the spool file NAME."
(defun mspools-get-spool-name ()
"Return the name of the spool on the current line."
(let ((line-num (1- (count-lines (point-min) (point-at-eol)))))
+ ;; FIXME: Why not extract the name directly from the current line's text?
(car (nth line-num mspools-files))))
;;; Spools mode functions
-(defun mspools-revert-buffer (ignore noconfirm)
- "Re-run mspools-show to revert the *spools* buffer."
+(defun mspools-revert-buffer (&optional _ignore _noconfirm)
+ "Re-run `mspools-show' to revert the *spools* buffer."
(mspools-show 'noshow))
(defun mspools-show-again (&optional noshow)
- "Update the *spools* buffer. This is useful if mspools-update is
-nil."
+ "Update the *spools* buffer.
+This is useful if `mspools-update' is nil."
+ (declare (obsolete revert-buffer "28.1"))
(interactive)
(mspools-show noshow))
(defun mspools-help ()
"Show help for `mspools-mode'."
+ (declare (obsolete describe-mode "28.1"))
(interactive)
(describe-function 'mspools-mode))
(defun mspools-quit ()
"Quit the *spools* buffer."
+ (declare (obsolete quit-window "28.1"))
(interactive)
(kill-buffer mspools-buffer))
(defun mspools-get-spool-files ()
"Find the list of spool files and display them in *spools* buffer."
- (let (folders head spool len beg end any)
- (if (null mspools-folder-directory)
- (error "Set `mspools-folder-directory' to where the spool files are"))
- (setq folders (directory-files mspools-folder-directory nil
+ (if (null mspools-folder-directory)
+ (error "Set `mspools-folder-directory' to where the spool files are"))
+ (let* ((folders (directory-files mspools-folder-directory nil
(format "\\`[^.]+\\.%s\\'" mspools-suffix)))
- (setq folders (mapcar 'mspools-size-folder folders))
- (setq folders (delq nil folders))
+ (folders (delq nil (mapcar #'mspools-size-folder folders)))
+ ;; beg end
+ )
(setq mspools-files folders)
(setq mspools-files-len (length mspools-files))
- (set-buffer mspools-buffer)
- (while folders
- (setq any t)
- (setq head (car folders))
- (setq spool (car head))
- (setq len (cdr head))
- (setq folders (cdr folders))
- (setq beg (point))
- (insert (format " %10d %s" len spool))
- (setq end (point))
- (insert "\n")
- ;;(put-text-property beg end 'mouse-face 'highlight)
- )
- (if any
- (delete-char -1)) ;delete last RET
- (goto-char (point-min))
- ))
+ (with-current-buffer mspools-buffer
+ (pcase-dolist (`(,spool . ,len) folders)
+ ;; (setq beg (point))
+ (insert (format " %10d %s" len spool))
+ ;; (setq end (point))
+ (insert "\n")
+ ;;(put-text-property beg end 'mouse-face 'highlight)
+ )
+ (if (not (bolp))
+ (delete-char -1)) ;delete last RET
+ (goto-char (point-min)))))
(defun mspools-size-folder (spool)
"Return (SPOOL . SIZE ), if SIZE of spool file is non-zero."