2020-09-03 22:03:46 -04:00
|
|
|
;;; mspools.el --- show mail spools waiting to be read -*- lexical-binding: t; -*-
|
1997-05-20 21:48:58 +00:00
|
|
|
|
2021-01-01 01:13:56 -08:00
|
|
|
;; Copyright (C) 1997, 2001-2021 Free Software Foundation, Inc.
|
1997-05-20 21:48:58 +00:00
|
|
|
|
2001-11-16 21:10:58 +00:00
|
|
|
;; Author: Stephen Eglen <stephen@gnu.org>
|
1997-05-20 21:48:58 +00:00
|
|
|
;; Created: 22 Jan 1997
|
1997-07-24 04:01:12 +00:00
|
|
|
;; Keywords: mail
|
1998-11-30 23:29:13 +00:00
|
|
|
;; location: http://www.anc.ed.ac.uk/~stephen/emacs/
|
1997-05-20 21:48:58 +00:00
|
|
|
|
1997-07-30 16:14:07 +00:00
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
2008-05-06 07:25:26 +00:00
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
1997-05-20 21:48:58 +00:00
|
|
|
;; it under the terms of the GNU General Public License as published by
|
2008-05-06 07:25:26 +00:00
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
;; (at your option) any later version.
|
1997-05-20 21:48:58 +00:00
|
|
|
|
1997-07-30 16:14:07 +00:00
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
1997-05-20 21:48:58 +00:00
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
2017-09-13 15:52:52 -07:00
|
|
|
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
1997-05-20 21:48:58 +00:00
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
;; If you use a mail filter (e.g. procmail, filter) to put mail messages in
|
|
|
|
;; folders, this file will let you see which folders have mail waiting
|
|
|
|
;; to be read in them. It assumes that new mail for the file `folder'
|
|
|
|
;; is written by the filter to a file called `folder.spool'. (If the
|
|
|
|
;; file writes directly to `folder' you may lose mail if new mail
|
|
|
|
;; arrives whilst you are reading the folder in emacs, hence the use
|
|
|
|
;; of a spool file.) For example, the following procmail recipe puts
|
|
|
|
;; any mail with `emacs' in the subject line into the spool file
|
1997-07-30 16:12:30 +00:00
|
|
|
;; `emacs.spool', ready to go into the folder `emacs'.
|
1997-05-20 21:48:58 +00:00
|
|
|
;:0:
|
|
|
|
;* ^Subject.*emacs
|
|
|
|
;emacs.spool
|
|
|
|
|
|
|
|
;; It also assumes that all of your spool files and mail folders live
|
|
|
|
;; in the directory pointed to by `mspools-folder-directory', so you must
|
|
|
|
;; set this (see Installation).
|
|
|
|
|
|
|
|
;; When you run `mspools-show', it creates a *spools* buffer containing
|
|
|
|
;; all of the spools in the folder directory that are waiting to be
|
|
|
|
;; read. On each line is the spool name and its size in bytes. Move
|
|
|
|
;; to the line of the folder that you would like to read, and then
|
|
|
|
;; press return or space. The mailer (VM or RMAIL) should then read
|
|
|
|
;; that folder and get the new mail for you. When you return to the
|
|
|
|
;; *spools* buffer, you will either see "*" to indicate that the spool
|
|
|
|
;; has been read, or the remaining unread spools, depending on the
|
|
|
|
;; value of `mspools-update'.
|
|
|
|
|
|
|
|
;; This file should work with both VM and RMAIL. See the variable
|
|
|
|
;; `mspools-using-vm' for details.
|
|
|
|
|
1998-02-01 17:10:21 +00:00
|
|
|
;;; Basic installation.
|
|
|
|
;; (autoload 'mspools-show "mspools" "Show outstanding mail spools." t)
|
|
|
|
;; (setq mspools-folder-directory "~/MAIL/")
|
|
|
|
;;
|
|
|
|
;; If you use VM, mspools-folder-directory will default to vm-folder-directory
|
|
|
|
;; unless you have already given it a value.
|
|
|
|
|
|
|
|
;; Extras.
|
1998-04-14 19:23:37 +00:00
|
|
|
;;
|
1998-02-01 17:10:21 +00:00
|
|
|
;; (global-set-key '[S-f1] 'mspools-show) ;Bind mspools-show to Shift F1.
|
1998-04-14 19:23:37 +00:00
|
|
|
;; (setq mspools-update t) ;Automatically update buffer.
|
1998-02-01 17:10:21 +00:00
|
|
|
|
|
|
|
;; Interface with the mail filter.
|
|
|
|
;; We assume that the mail filter drops new mail into the spool
|
|
|
|
;; `folder.spool'. If your spool files are something like folder.xyz
|
|
|
|
;; for inbox `folder', then do:
|
|
|
|
;; (setq mspools-suffix "xyz")
|
|
|
|
;; If you use other conventions for your spool files, this code will
|
|
|
|
;; need rewriting.
|
|
|
|
|
|
|
|
;; Warning for VM users
|
|
|
|
;; Don't use if you are not sure what you are doing. The value of
|
1997-05-20 21:48:58 +00:00
|
|
|
;; vm-spool-files is altered, so you may not be able to read incoming
|
|
|
|
;; mail with VM if this is incorrectly set.
|
|
|
|
|
|
|
|
;; Useful settings for VM
|
1998-02-01 17:10:21 +00:00
|
|
|
;; vm-auto-get-new-mail should be t (the default).
|
1997-05-20 21:48:58 +00:00
|
|
|
|
2012-07-24 22:48:19 -07:00
|
|
|
;; Acknowledgments
|
1998-02-01 17:10:21 +00:00
|
|
|
;; Thanks to jond@mitre.org (Jonathan Doughty) for help with code for
|
|
|
|
;; setting up vm-spool-files.
|
1997-05-20 21:48:58 +00:00
|
|
|
|
|
|
|
;;; TODO
|
|
|
|
|
|
|
|
;; What if users have mail spools in more than one directory? Extend
|
1998-02-01 17:10:21 +00:00
|
|
|
;; mspools-folder-directory to be a list of directories? Currently,
|
|
|
|
;; if mail spools are in other directories, the way to read them is to
|
|
|
|
;; put a symbolic link to the spool into the mspools-folder-directory.
|
1997-05-20 21:48:58 +00:00
|
|
|
|
|
|
|
;; I was going to add mouse support so that you could click on a line
|
|
|
|
;; to visit the buffer. Tell me if you want it, and I can put the
|
1998-02-01 17:10:21 +00:00
|
|
|
;; code in (I don't use the mouse much, so I haven't bothered with it
|
|
|
|
;; so far).
|
1997-05-20 21:48:58 +00:00
|
|
|
|
|
|
|
;; 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
|
2008-06-27 07:34:53 +00:00
|
|
|
;; visualize the results in the buffer.
|
1997-05-20 21:48:58 +00:00
|
|
|
|
|
|
|
;; Shrink wrap the buffer to remove excess white-space?
|
|
|
|
|
1998-02-01 17:10:21 +00:00
|
|
|
;;; Code:
|
1997-05-20 21:48:58 +00:00
|
|
|
|
2005-08-29 14:39:32 +00:00
|
|
|
(defvar rmail-inbox-list)
|
|
|
|
(defvar vm-crash-box)
|
|
|
|
(defvar vm-folder-directory)
|
|
|
|
(defvar vm-init-file)
|
|
|
|
(defvar vm-init-file-loaded)
|
|
|
|
(defvar vm-primary-inbox)
|
|
|
|
(defvar vm-spool-files)
|
|
|
|
|
1997-05-20 21:48:58 +00:00
|
|
|
;;; User Variables
|
|
|
|
|
1998-02-01 17:10:21 +00:00
|
|
|
(defgroup mspools nil
|
|
|
|
"Show mail spools waiting to be read."
|
|
|
|
:group 'mail
|
|
|
|
:link '(emacs-commentary-link :tag "Commentary" "mspools.el")
|
|
|
|
)
|
|
|
|
|
|
|
|
(defcustom mspools-update nil
|
2012-04-09 21:05:48 +08:00
|
|
|
"Non-nil means update *spools* buffer after visiting any folder."
|
2020-08-29 16:13:05 +02:00
|
|
|
:type 'boolean)
|
1998-02-01 17:10:21 +00:00
|
|
|
|
|
|
|
(defcustom mspools-suffix "spool"
|
2012-04-09 21:05:48 +08:00
|
|
|
"Extension used for spool files (not including full stop)."
|
2020-08-29 16:13:05 +02:00
|
|
|
:type 'string)
|
1997-05-20 21:48:58 +00:00
|
|
|
|
1998-02-01 17:10:21 +00:00
|
|
|
(defcustom mspools-using-vm (fboundp 'vm)
|
2012-04-09 21:05:48 +08:00
|
|
|
"Non-nil if VM is used as mail reader, otherwise RMAIL is used."
|
2020-08-29 16:13:05 +02:00
|
|
|
:type 'boolean)
|
1998-02-01 17:10:21 +00:00
|
|
|
|
|
|
|
(defcustom mspools-folder-directory
|
|
|
|
(if (boundp 'vm-folder-directory)
|
|
|
|
vm-folder-directory
|
1998-04-14 19:23:37 +00:00
|
|
|
"~/MAIL/")
|
2012-04-09 21:05:48 +08:00
|
|
|
"Directory where mail folders are kept. Ensure it has a trailing /.
|
1998-04-14 19:23:37 +00:00
|
|
|
Defaults to `vm-folder-directory' if bound else to ~/MAIL/."
|
2020-08-29 16:13:05 +02:00
|
|
|
:type 'directory)
|
1997-05-20 21:48:58 +00:00
|
|
|
|
1999-01-05 09:46:03 +00:00
|
|
|
(defcustom mspools-vm-system-mail (or (getenv "MAIL")
|
|
|
|
(concat rmail-spool-directory
|
|
|
|
(user-login-name)))
|
2012-04-09 21:05:48 +08:00
|
|
|
"Spool file for main mailbox. Only used by VM.
|
1998-04-14 19:23:37 +00:00
|
|
|
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
|
1999-01-05 09:46:03 +00:00
|
|
|
$MAIL. Otherwise it will use `rmail-spool-directory' to guess where
|
|
|
|
your primary spool is. If this fails, set it to something like
|
|
|
|
/usr/spool/mail/login-name."
|
2020-08-29 16:13:05 +02:00
|
|
|
:type 'file)
|
1997-05-20 21:48:58 +00:00
|
|
|
|
1998-04-14 19:23:37 +00:00
|
|
|
;;; Internal Variables
|
1997-05-20 21:48:58 +00:00
|
|
|
|
|
|
|
(defvar mspools-files nil
|
|
|
|
"List of entries (SPOOL . SIZE) giving spool name and file size.")
|
|
|
|
|
|
|
|
(defvar mspools-files-len nil
|
|
|
|
"Length of `mspools-files' list.")
|
|
|
|
|
|
|
|
(defvar mspools-buffer "*spools*"
|
|
|
|
"Name of buffer for displaying spool info.")
|
|
|
|
|
2010-10-10 16:12:30 -07:00
|
|
|
(defvar mspools-mode-map
|
|
|
|
(let ((map (make-sparse-keymap)))
|
2021-03-11 14:32:42 -05:00
|
|
|
(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 "n" #'next-line)
|
|
|
|
(define-key map "p" #'previous-line)
|
2010-10-24 17:44:53 -04:00
|
|
|
map)
|
1997-05-20 21:48:58 +00:00
|
|
|
"Keymap for the *spools* buffer.")
|
|
|
|
|
|
|
|
;;; Code
|
|
|
|
|
|
|
|
;;; VM Specific code
|
|
|
|
(if mspools-using-vm
|
1997-07-30 16:12:30 +00:00
|
|
|
;; set up vm if not already loaded.
|
|
|
|
(progn
|
|
|
|
(require 'vm-vars)
|
1998-04-14 19:23:37 +00:00
|
|
|
(if (and (not vm-init-file-loaded) (file-readable-p vm-init-file))
|
1997-07-30 16:12:30 +00:00
|
|
|
(load-file vm-init-file))
|
|
|
|
(if (not mspools-folder-directory)
|
|
|
|
(setq mspools-folder-directory vm-folder-directory))
|
|
|
|
))
|
1997-05-20 21:48:58 +00:00
|
|
|
|
|
|
|
(defun mspools-set-vm-spool-files ()
|
|
|
|
"Set value of `vm-spool-files'. Only needed for VM."
|
1999-01-05 09:46:03 +00:00
|
|
|
(if (not (file-readable-p mspools-vm-system-mail))
|
1998-04-14 19:23:37 +00:00
|
|
|
(error "Need to set mspools-vm-system-mail to the spool for primary inbox"))
|
|
|
|
(if (null mspools-folder-directory)
|
|
|
|
(error "Set `mspools-folder-directory' to where the spool files are"))
|
|
|
|
(setq
|
|
|
|
vm-spool-files
|
1997-05-20 21:48:58 +00:00
|
|
|
(append
|
|
|
|
(list
|
|
|
|
;; Main mailbox
|
|
|
|
(list vm-primary-inbox
|
1998-04-14 19:23:37 +00:00
|
|
|
mspools-vm-system-mail ; your mailbox
|
|
|
|
vm-crash-box ;crash for mailbox
|
1997-05-20 21:48:58 +00:00
|
|
|
))
|
2003-02-04 13:24:35 +00:00
|
|
|
|
1997-05-20 21:48:58 +00:00
|
|
|
;; Mailing list inboxes
|
1997-07-30 16:12:30 +00:00
|
|
|
;; must have VM already loaded to get vm-folder-directory.
|
2011-05-23 14:57:17 -03:00
|
|
|
(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")))
|
1997-05-20 21:48:58 +00:00
|
|
|
;; So I create a vm-spool-files entry for each of those mail drops
|
2020-09-03 22:03:46 -04:00
|
|
|
(mapcar #'file-name-sans-extension
|
2003-02-04 13:24:35 +00:00
|
|
|
(directory-files mspools-folder-directory nil
|
Fix edge case errors in filename-matching regexps
These changes fix actual or latent bugs in regexps that match
file names, such as PATTERN arguments to 'directory-files'. See
https://lists.gnu.org/archive/html/emacs-devel/2020-04/msg00265.html
* admin/authors.el (authors-obsolete-files-regexps)
(authors-renamed-files-regexps):
* lisp/auth-source-pass.el (auth-source-pass-entries):
* lisp/calendar/todo-mode.el (todo-show, todo-find-filtered-items-file)
(todo-filter-items, todo-reset-nondiary-marker, todo-reset-done-string)
(todo-reset-comment-string, todo-reset-highlight-item):
* lisp/cedet/semantic/db-ebrowse.el (semanticdb-load-ebrowse-caches):
* lisp/cedet/semantic/texi.el (semantic-texi-associated-files):
* lisp/cedet/srecode/map.el (srecode-map-update-map):
* lisp/dired.el (dired-re-no-dot):
* lisp/emacs-lisp/autoload.el (update-directory-autoloads):
* lisp/emacs-lisp/shadow.el (load-path-shadows-find):
* lisp/files.el (auto-mode-alist, directory-files-no-dot-files-regexp):
* lisp/finder.el (finder-compile-keywords):
* lisp/generic-x.el (inetd-conf-generic-mode, named-boot-generic-mode)
(resolve-conf-generic-mode, etc-modules-conf-generic-mode):
* lisp/gnus/gnus-agent.el (gnus-agent-read-agentview)
(gnus-agent-regenerate-group, gnus-agent-update-files-total-fetched-for):
* lisp/gnus/gnus-cache.el (gnus-cache-articles-in-group):
* lisp/gnus/gnus-score.el (gnus-score-search-global-directories):
* lisp/gnus/gnus-util.el (gnus-delete-directory):
* lisp/gnus/gnus-uu.el (gnus-uu-dir-files):
* lisp/gnus/nndraft.el (nndraft-request-group):
* lisp/gnus/nnmh.el (nnmh-request-group, nnmh-request-create-group):
(nnmh-request-delete-group, nnmh-active-number, nnmh-update-gnus-unreads):
* lisp/gnus/nnspool.el (nnspool-request-group):
* lisp/gnus/spam-stat.el (spam-stat-process-directory)
(spam-stat-test-directory):
* lisp/help-fns.el (help-fns--first-release):
* lisp/help.el (view-emacs-news):
* lisp/international/quail.el (quail-update-leim-list-file):
* lisp/international/titdic-cnv.el (batch-titdic-convert):
* lisp/mail/mspools.el (mspools-set-vm-spool-files)
(mspools-get-spool-files):
* lisp/mail/rmail.el (rmail-secondary-file-regexp)
(rmail-speedbar-match-folder-regexp):
* lisp/net/ange-ftp.el (ange-ftp-delete-directory):
* lisp/net/tramp.el (tramp-use-absolute-autoload-file-names):
* lisp/obsolete/gulp.el (gulp-send-requests):
* lisp/obsolete/vc-arch.el (vc-arch-trim-revlib):
* lisp/org/ob-core.el (org-babel-remove-temporary-directory):
* lisp/progmodes/ebnf2ps.el (ebnf-file-suffix-regexp, ebnf-style-database):
* lisp/progmodes/executable.el (executable-command-find-posix-p):
* lisp/startup.el (command-line):
* lisp/textmodes/refer.el (refer-get-bib-files):
* lisp/url/url-about.el (url-probe-protocols):
* lisp/vc/vc-rcs.el (vc-rcs-register, vc-rcs-unregister):
* test/lisp/net/tramp-archive-tests.el
(tramp-archive-test19-directory-files-and-attributes):
* test/lisp/net/tramp-tests.el (tramp-test19-directory-files-and-attributes):
Replace ^ and $ with \` and \', respectively.
Use (rx (or (not ".") "...")), translated into "[^.]\\|\\.\\.\\.",
to match anything but "." and "..", instead of several incorrect
regexps.
2020-04-14 12:17:40 +02:00
|
|
|
(format "\\`[^.]+\\.%s" mspools-suffix)))
|
1997-05-20 21:48:58 +00:00
|
|
|
))
|
|
|
|
))
|
|
|
|
|
|
|
|
;;; MSPOOLS-SHOW -- the main function
|
2020-09-03 22:03:46 -04:00
|
|
|
;;;###autoload
|
|
|
|
(defun mspools-show (&optional noshow)
|
1997-05-20 21:48:58 +00:00
|
|
|
"Show the list of non-empty spool files in the *spools* buffer.
|
|
|
|
Buffer is not displayed if SHOW is non-nil."
|
|
|
|
(interactive)
|
|
|
|
(if (get-buffer mspools-buffer)
|
|
|
|
;; buffer exists
|
|
|
|
(progn
|
1998-04-14 19:23:37 +00:00
|
|
|
(set-buffer mspools-buffer)
|
|
|
|
(setq buffer-read-only nil)
|
2020-09-03 22:03:46 -04:00
|
|
|
(erase-buffer))
|
1998-02-01 17:10:21 +00:00
|
|
|
;; else buffer doesn't exist so create it
|
1997-05-20 21:48:58 +00:00
|
|
|
(get-buffer-create mspools-buffer))
|
2003-02-04 13:24:35 +00:00
|
|
|
|
1997-05-20 21:48:58 +00:00
|
|
|
;; generate the list of spool files
|
|
|
|
(if mspools-using-vm
|
|
|
|
(mspools-set-vm-spool-files))
|
2003-02-04 13:24:35 +00:00
|
|
|
|
1997-05-20 21:48:58 +00:00
|
|
|
(mspools-get-spool-files)
|
|
|
|
(if (not noshow) (pop-to-buffer mspools-buffer))
|
2003-02-04 13:24:35 +00:00
|
|
|
|
1997-05-20 21:48:58 +00:00
|
|
|
(setq buffer-read-only t)
|
|
|
|
(mspools-mode)
|
|
|
|
)
|
|
|
|
|
2007-11-25 16:48:31 +00:00
|
|
|
(declare-function rmail-get-new-mail "rmail" (&optional file-name))
|
|
|
|
|
2007-11-29 04:26:13 +00:00
|
|
|
;; External.
|
|
|
|
(declare-function vm-visit-folder "ext:vm-startup" (folder &optional read-only))
|
|
|
|
|
1997-05-20 21:48:58 +00:00
|
|
|
(defun mspools-visit-spool ()
|
|
|
|
"Visit the folder on the current line of the *spools* buffer."
|
|
|
|
(interactive)
|
2020-09-03 22:03:46 -04:00
|
|
|
(let ((spool-name (mspools-get-spool-name))
|
|
|
|
folder-name)
|
1998-02-01 17:10:21 +00:00
|
|
|
(if (null spool-name)
|
|
|
|
(message "No spool on current line")
|
2003-02-04 13:24:35 +00:00
|
|
|
|
1998-02-01 17:10:21 +00:00
|
|
|
(setq folder-name (mspools-get-folder-from-spool spool-name))
|
2003-02-04 13:24:35 +00:00
|
|
|
|
1998-02-01 17:10:21 +00:00
|
|
|
;; put in a little "*" to indicate spool file has been read.
|
|
|
|
(if (not mspools-update)
|
|
|
|
(save-excursion
|
|
|
|
(beginning-of-line)
|
2020-09-03 22:03:46 -04:00
|
|
|
(let ((inhibit-read-only t))
|
|
|
|
(insert "*")
|
|
|
|
(delete-char 1))))
|
1998-02-01 17:10:21 +00:00
|
|
|
|
|
|
|
(message "folder %s spool %s" folder-name spool-name)
|
2020-09-03 22:03:46 -04:00
|
|
|
(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))
|
2003-02-04 13:24:35 +00:00
|
|
|
|
1998-02-01 17:10:21 +00:00
|
|
|
;; Choose whether to use VM or RMAIL for reading folder.
|
1998-04-14 19:23:37 +00:00
|
|
|
(if mspools-using-vm
|
1998-02-01 17:10:21 +00:00
|
|
|
(vm-visit-folder (concat mspools-folder-directory folder-name))
|
1998-04-14 19:23:37 +00:00
|
|
|
;; else using RMAIL
|
1998-02-01 17:10:21 +00:00
|
|
|
(rmail (concat mspools-folder-directory folder-name))
|
1998-04-14 19:23:37 +00:00
|
|
|
(setq rmail-inbox-list
|
1998-02-01 17:10:21 +00:00
|
|
|
(list (concat mspools-folder-directory spool-name)))
|
|
|
|
(rmail-get-new-mail))
|
2003-02-04 13:24:35 +00:00
|
|
|
|
|
|
|
|
1998-02-01 17:10:21 +00:00
|
|
|
(if mspools-update
|
|
|
|
;; generate new list of spools.
|
2020-09-03 22:03:46 -04:00
|
|
|
(save-excursion ;;FIXME: Why?
|
|
|
|
(mspools-revert-buffer))))))
|
1997-05-20 21:48:58 +00:00
|
|
|
|
|
|
|
(defun mspools-get-folder-from-spool (name)
|
|
|
|
"Return folder name corresponding to the spool file NAME."
|
|
|
|
;; Simply strip of the extension.
|
|
|
|
(file-name-sans-extension name))
|
|
|
|
|
|
|
|
;; Alternative version if you have more complicated mapping of spool name
|
|
|
|
;; to file name.
|
|
|
|
;(defun get-folder-from-spool-safe (name)
|
|
|
|
; "Return the folder name corresponding to the spool file NAME."
|
2015-09-17 16:08:20 -07:00
|
|
|
; (if (string-match "^\\(.*\\)\\.spool$" name)
|
1997-05-20 21:48:58 +00:00
|
|
|
; (substring name (match-beginning 1) (match-end 1))
|
|
|
|
; (error "Could not extract folder name from spool name %s" name)))
|
|
|
|
|
|
|
|
; test
|
|
|
|
;(mspools-get-folder-from-spool "happy.spool")
|
|
|
|
;(mspools-get-folder-from-spool "happy.sp")
|
|
|
|
|
|
|
|
(defun mspools-get-spool-name ()
|
|
|
|
"Return the name of the spool on the current line."
|
Replace still more end-of-line etc with line-end-position, etc.
* lisp/gnus/nnbabyl.el (nnbabyl-request-move-article, nnbabyl-delete-mail)
(nnbabyl-check-mbox): Use point-at-bol.
* lisp/cedet/semantic/lex.el (semantic-lex-ignore-comments, semantic-flex):
* lisp/cedet/semantic/grammar.el (semantic-grammar-epilogue):
* lisp/cedet/ede/speedbar.el (ede-find-nearest-file-line):
* lisp/cedet/ede/pmake.el (ede-proj-makefile-insert-dist-rules):
* lisp/cedet/ede/autoconf-edit.el (autoconf-delete-parameter):
Use point-at-bol and point-at-eol.
* lisp/vc/emerge.el (emerge-line-number-in-buf):
* lisp/textmodes/ispell.el (ispell-region):
* lisp/textmodes/fill.el (current-fill-column):
* lisp/progmodes/xscheme.el (xscheme-send-current-line):
* lisp/progmodes/vhdl-mode.el (vhdl-current-line, vhdl-line-copy):
* lisp/progmodes/tcl.el (tcl-hairy-scan-for-comment):
* lisp/progmodes/sh-script.el (sh-handle-prev-do):
* lisp/progmodes/meta-mode.el (meta-indent-line):
* lisp/progmodes/idlwave.el (idlwave-goto-comment, idlwave-fill-paragraph)
(idlwave-in-quote):
* lisp/progmodes/idlw-shell.el (idlwave-shell-current-frame)
(idlwave-shell-update-bp-overlays, idlwave-shell-sources-filter):
* lisp/progmodes/fortran.el (fortran-looking-at-if-then):
* lisp/progmodes/etags.el (find-tag-in-order, etags-snarf-tag):
* lisp/progmodes/cperl-mode.el (cperl-sniff-for-indent)
(cperl-find-pods-heres):
* lisp/progmodes/ada-mode.el (ada-get-current-indent, ada-narrow-to-defun):
* lisp/net/quickurl.el (quickurl-list-insert):
* lisp/net/ldap.el (ldap-search-internal):
* lisp/net/eudc.el (eudc-expand-inline):
* lisp/mail/sendmail.el (sendmail-send-it):
* lisp/mail/mspools.el (mspools-visit-spool, mspools-get-spool-name):
* lisp/emulation/viper-cmd.el (viper-paren-match, viper-backward-indent)
(viper-brac-function):
* lisp/calc/calc-yank.el (calc-do-grab-region):
* lisp/calc/calc-keypd.el (calc-keypad-press):
* lisp/term.el (term-move-columns, term-insert-spaces):
* lisp/speedbar.el (speedbar-highlight-one-tag-line):
* lisp/simple.el (current-word):
* lisp/mouse-drag.el (mouse-drag-should-do-col-scrolling):
* lisp/info.el (Info-find-node-in-buffer-1, Info-follow-reference)
(Info-scroll-down):
* lisp/hippie-exp.el (he-line-beg):
* lisp/epa.el (epa--marked-keys):
* lisp/dired-aux.el (dired-kill-line, dired-do-kill-lines)
(dired-update-file-line, dired-add-entry, dired-remove-entry)
(dired-relist-entry):
* lisp/buff-menu.el (Buffer-menu-buffer):
* lisp/array.el (current-line):
* lisp/allout.el (allout-resolve-xref)
(allout-latex-verbatim-quote-curr-line):
Replace yet more uses of end-of-line etc with line-end-position.
2010-11-08 21:33:07 -08:00
|
|
|
(let ((line-num (1- (count-lines (point-min) (point-at-eol)))))
|
2020-09-03 22:03:46 -04:00
|
|
|
;; FIXME: Why not extract the name directly from the current line's text?
|
1997-05-20 21:48:58 +00:00
|
|
|
(car (nth line-num mspools-files))))
|
|
|
|
|
1998-04-14 19:23:37 +00:00
|
|
|
;;; Spools mode functions
|
1997-05-20 21:48:58 +00:00
|
|
|
|
2020-09-03 22:03:46 -04:00
|
|
|
(defun mspools-revert-buffer (&optional _ignore _noconfirm)
|
|
|
|
"Re-run `mspools-show' to revert the *spools* buffer."
|
1997-05-20 21:48:58 +00:00
|
|
|
(mspools-show 'noshow))
|
|
|
|
|
|
|
|
(defun mspools-show-again (&optional noshow)
|
2020-09-03 22:03:46 -04:00
|
|
|
"Update the *spools* buffer.
|
|
|
|
This is useful if `mspools-update' is nil."
|
|
|
|
(declare (obsolete revert-buffer "28.1"))
|
1997-05-20 21:48:58 +00:00
|
|
|
(interactive)
|
|
|
|
(mspools-show noshow))
|
2003-02-04 13:24:35 +00:00
|
|
|
|
1997-05-20 21:48:58 +00:00
|
|
|
(defun mspools-help ()
|
|
|
|
"Show help for `mspools-mode'."
|
2020-09-03 22:03:46 -04:00
|
|
|
(declare (obsolete describe-mode "28.1"))
|
1997-05-20 21:48:58 +00:00
|
|
|
(interactive)
|
|
|
|
(describe-function 'mspools-mode))
|
|
|
|
|
|
|
|
(defun mspools-quit ()
|
|
|
|
"Quit the *spools* buffer."
|
2020-09-03 22:03:46 -04:00
|
|
|
(declare (obsolete quit-window "28.1"))
|
1997-05-20 21:48:58 +00:00
|
|
|
(interactive)
|
|
|
|
(kill-buffer mspools-buffer))
|
|
|
|
|
2013-09-10 23:31:56 -04:00
|
|
|
(define-derived-mode mspools-mode special-mode "MSpools"
|
1997-05-20 21:48:58 +00:00
|
|
|
"Major mode for output from mspools-show.
|
|
|
|
\\<mspools-mode-map>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.
|
1997-07-30 16:12:30 +00:00
|
|
|
\\[revert-buffer] to regenerate the list of spools.
|
1997-05-20 21:48:58 +00:00
|
|
|
\\{mspools-mode-map}"
|
2013-09-10 23:31:56 -04:00
|
|
|
(setq-local revert-buffer-function 'mspools-revert-buffer))
|
1997-05-20 21:48:58 +00:00
|
|
|
|
|
|
|
(defun mspools-get-spool-files ()
|
|
|
|
"Find the list of spool files and display them in *spools* buffer."
|
2020-09-03 22:03:46 -04:00
|
|
|
(if (null mspools-folder-directory)
|
|
|
|
(error "Set `mspools-folder-directory' to where the spool files are"))
|
|
|
|
(let* ((folders (directory-files mspools-folder-directory nil
|
Fix edge case errors in filename-matching regexps
These changes fix actual or latent bugs in regexps that match
file names, such as PATTERN arguments to 'directory-files'. See
https://lists.gnu.org/archive/html/emacs-devel/2020-04/msg00265.html
* admin/authors.el (authors-obsolete-files-regexps)
(authors-renamed-files-regexps):
* lisp/auth-source-pass.el (auth-source-pass-entries):
* lisp/calendar/todo-mode.el (todo-show, todo-find-filtered-items-file)
(todo-filter-items, todo-reset-nondiary-marker, todo-reset-done-string)
(todo-reset-comment-string, todo-reset-highlight-item):
* lisp/cedet/semantic/db-ebrowse.el (semanticdb-load-ebrowse-caches):
* lisp/cedet/semantic/texi.el (semantic-texi-associated-files):
* lisp/cedet/srecode/map.el (srecode-map-update-map):
* lisp/dired.el (dired-re-no-dot):
* lisp/emacs-lisp/autoload.el (update-directory-autoloads):
* lisp/emacs-lisp/shadow.el (load-path-shadows-find):
* lisp/files.el (auto-mode-alist, directory-files-no-dot-files-regexp):
* lisp/finder.el (finder-compile-keywords):
* lisp/generic-x.el (inetd-conf-generic-mode, named-boot-generic-mode)
(resolve-conf-generic-mode, etc-modules-conf-generic-mode):
* lisp/gnus/gnus-agent.el (gnus-agent-read-agentview)
(gnus-agent-regenerate-group, gnus-agent-update-files-total-fetched-for):
* lisp/gnus/gnus-cache.el (gnus-cache-articles-in-group):
* lisp/gnus/gnus-score.el (gnus-score-search-global-directories):
* lisp/gnus/gnus-util.el (gnus-delete-directory):
* lisp/gnus/gnus-uu.el (gnus-uu-dir-files):
* lisp/gnus/nndraft.el (nndraft-request-group):
* lisp/gnus/nnmh.el (nnmh-request-group, nnmh-request-create-group):
(nnmh-request-delete-group, nnmh-active-number, nnmh-update-gnus-unreads):
* lisp/gnus/nnspool.el (nnspool-request-group):
* lisp/gnus/spam-stat.el (spam-stat-process-directory)
(spam-stat-test-directory):
* lisp/help-fns.el (help-fns--first-release):
* lisp/help.el (view-emacs-news):
* lisp/international/quail.el (quail-update-leim-list-file):
* lisp/international/titdic-cnv.el (batch-titdic-convert):
* lisp/mail/mspools.el (mspools-set-vm-spool-files)
(mspools-get-spool-files):
* lisp/mail/rmail.el (rmail-secondary-file-regexp)
(rmail-speedbar-match-folder-regexp):
* lisp/net/ange-ftp.el (ange-ftp-delete-directory):
* lisp/net/tramp.el (tramp-use-absolute-autoload-file-names):
* lisp/obsolete/gulp.el (gulp-send-requests):
* lisp/obsolete/vc-arch.el (vc-arch-trim-revlib):
* lisp/org/ob-core.el (org-babel-remove-temporary-directory):
* lisp/progmodes/ebnf2ps.el (ebnf-file-suffix-regexp, ebnf-style-database):
* lisp/progmodes/executable.el (executable-command-find-posix-p):
* lisp/startup.el (command-line):
* lisp/textmodes/refer.el (refer-get-bib-files):
* lisp/url/url-about.el (url-probe-protocols):
* lisp/vc/vc-rcs.el (vc-rcs-register, vc-rcs-unregister):
* test/lisp/net/tramp-archive-tests.el
(tramp-archive-test19-directory-files-and-attributes):
* test/lisp/net/tramp-tests.el (tramp-test19-directory-files-and-attributes):
Replace ^ and $ with \` and \', respectively.
Use (rx (or (not ".") "...")), translated into "[^.]\\|\\.\\.\\.",
to match anything but "." and "..", instead of several incorrect
regexps.
2020-04-14 12:17:40 +02:00
|
|
|
(format "\\`[^.]+\\.%s\\'" mspools-suffix)))
|
2020-09-03 22:03:46 -04:00
|
|
|
(folders (delq nil (mapcar #'mspools-size-folder folders)))
|
|
|
|
;; beg end
|
|
|
|
)
|
1997-05-20 21:48:58 +00:00
|
|
|
(setq mspools-files folders)
|
|
|
|
(setq mspools-files-len (length mspools-files))
|
2020-09-03 22:03:46 -04:00
|
|
|
(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)))))
|
1997-05-20 21:48:58 +00:00
|
|
|
|
|
|
|
(defun mspools-size-folder (spool)
|
2007-08-08 07:18:57 +00:00
|
|
|
"Return (SPOOL . SIZE ), if SIZE of spool file is non-zero."
|
1997-05-20 21:48:58 +00:00
|
|
|
;; 7th file attribute is the size of the file in bytes.
|
1997-07-30 16:12:30 +00:00
|
|
|
(let ((file (concat mspools-folder-directory spool))
|
|
|
|
size)
|
|
|
|
(setq file (or (file-symlink-p file) file))
|
file-attributes cleanup
Mostly, this replaces magic-number calls like (nth 4 A) with
more-informative calls like (file-attribute-access-time A).
It also fixes some documentation and minor timestamp coding
issues that I noticed while looking into this.
* doc/lispref/files.texi (File Attributes):
* lisp/files.el (file-attribute-size)
(file-attribute-inode-number, file-attribute-device-number):
* src/dired.c (Fdirectory_files_and_attributes)
(Ffile_attributes):
Mention which attributes must be integers, or nonnegative integers,
as opposed to merely being numbers. Remove no-longer-correct
talk about representing large integers as conses of integers.
* doc/lispref/files.texi (Magic File Names):
* doc/misc/gnus.texi (Low-level interface to the spam-stat dictionary):
* lisp/autorevert.el (auto-revert-find-file-function)
(auto-revert-tail-mode, auto-revert-handler):
* lisp/auth-source.el (auth-source-netrc-parse):
* lisp/cedet/ede/files.el (ede--inode-for-dir):
* lisp/cedet/semantic/db-file.el (object-write):
* lisp/cedet/semantic/db-mode.el (semanticdb-kill-hook):
* lisp/cedet/semantic/db.el (semanticdb-needs-refresh-p)
(semanticdb-synchronize):
* lisp/cedet/srecode/table.el (srecode-mode-table-new):
* lisp/desktop.el (desktop-save, desktop-read):
* lisp/dired-aux.el (dired-file-set-difference)
(dired-do-chxxx, dired-do-chmod, dired-copy-file-recursive)
(dired-create-files):
* lisp/dired.el (dired-directory-changed-p, dired-readin):
* lisp/dos-w32.el (w32-direct-print-region-helper):
* lisp/emacs-lisp/autoload.el (autoload-generate-file-autoloads)
(autoload-find-destination, update-directory-autoloads):
* lisp/emacs-lisp/shadow.el (load-path-shadows-same-file-or-nonexistent):
* lisp/epg.el (epg--start, epg-wait-for-completion):
* lisp/eshell/em-ls.el (eshell-ls-filetype-p)
(eshell-ls-applicable, eshell-ls-size-string)
(eshell-ls-file, eshell-ls-dir, eshell-ls-files)
(eshell-ls-entries):
* lisp/eshell/em-pred.el (eshell-predicate-alist)
(eshell-pred-file-type, eshell-pred-file-links)
(eshell-pred-file-size):
* lisp/eshell/em-unix.el (eshell-shuffle-files, eshell/cat)
(eshell-du-sum-directory, eshell/du):
* lisp/eshell/esh-util.el (eshell-read-passwd)
(eshell-read-hosts):
* lisp/files.el (remote-file-name-inhibit-cache)
(find-file-noselect, insert-file-1, dir-locals-find-file)
(dir-locals-read-from-dir, backup-buffer)
(file-ownership-preserved-p, copy-directory)
(read-file-modes):
* lisp/find-lisp.el (find-lisp-format):
* lisp/gnus/gnus-agent.el (gnus-agent-unfetch-articles)
(gnus-agent-read-agentview, gnus-agent-expire-group-1)
(gnus-agent-request-article, gnus-agent-regenerate-group)
(gnus-agent-update-files-total-fetched-for)
(gnus-agent-update-view-total-fetched-for):
* lisp/gnus/gnus-cache.el (gnus-cache-read-active)
(gnus-cache-update-file-total-fetched-for)
(gnus-cache-update-overview-total-fetched-for):
* lisp/gnus/gnus-cloud.el (gnus-cloud-file-new-p):
* lisp/gnus/gnus-score.el (gnus-score-score-files):
* lisp/gnus/gnus-start.el (gnus-save-newsrc-file)
(gnus-master-read-slave-newsrc):
* lisp/gnus/gnus-sum.el (gnus-summary-import-article):
* lisp/gnus/gnus-util.el (gnus-file-newer-than)
(gnus-cache-file-contents):
* lisp/gnus/mail-source.el (mail-source-delete-old-incoming)
(mail-source-callback, mail-source-movemail):
* lisp/gnus/nneething.el (nneething-create-mapping)
(nneething-make-head):
* lisp/gnus/nnfolder.el (nnfolder-read-folder):
* lisp/gnus/nnheader.el (nnheader-file-size)
(nnheader-insert-nov-file):
* lisp/gnus/nnmail.el (nnmail-activate):
* lisp/gnus/nnmaildir.el (nnmaildir--group-maxnum)
(nnmaildir--new-number, nnmaildir--update-nov)
(nnmaildir--scan, nnmaildir-request-scan)
(nnmaildir-request-update-info)
(nnmaildir-request-expire-articles):
* lisp/gnus/nnmh.el (nnmh-request-list-1)
(nnmh-request-expire-articles, nnmh-update-gnus-unreads):
* lisp/gnus/nnml.el (nnml-request-expire-articles):
* lisp/gnus/spam-stat.el (spam-stat-save, spam-stat-load)
(spam-stat-process-directory, spam-stat-test-directory):
* lisp/ido.el (ido-directory-too-big-p)
(ido-file-name-all-completions):
* lisp/image-dired.el (image-dired-get-thumbnail-image)
(image-dired-create-thumb-1):
* lisp/info.el (info-insert-file-contents):
* lisp/ls-lisp.el (ls-lisp-insert-directory)
(ls-lisp-handle-switches, ls-lisp-classify-file)
(ls-lisp-format):
* lisp/mail/blessmail.el:
* lisp/mail/feedmail.el (feedmail-default-date-generator)
(feedmail-default-message-id-generator):
* lisp/mail/mailabbrev.el (mail-abbrevs-sync-aliases)
(mail-abbrevs-setup):
* lisp/mail/mspools.el (mspools-size-folder):
* lisp/mail/rmail.el (rmail-insert-inbox-text):
* lisp/mail/sendmail.el (sendmail-sync-aliases):
* lisp/mh-e/mh-alias.el (mh-alias-tstamp):
* lisp/net/ange-ftp.el (ange-ftp-parse-netrc)
(ange-ftp-write-region, ange-ftp-file-newer-than-file-p)
(ange-ftp-cf1):
* lisp/net/eudcb-mab.el (eudc-mab-query-internal):
* lisp/net/eww.el (eww-read-bookmarks):
* lisp/net/netrc.el (netrc-parse):
* lisp/net/newst-backend.el (newsticker--image-get):
* lisp/nxml/rng-loc.el (rng-get-parsed-schema-locating-file):
* lisp/obsolete/fast-lock.el (fast-lock-save-cache):
* lisp/obsolete/vc-arch.el (vc-arch-state)
(vc-arch-diff3-rej-p):
* lisp/org/ob-eval.el (org-babel--shell-command-on-region):
* lisp/org/org-attach.el (org-attach-commit):
* lisp/org/org-macro.el (org-macro-initialize-templates):
* lisp/org/org.el (org-babel-load-file)
(org-file-newer-than-p):
* lisp/org/ox-html.el (org-html-format-spec):
* lisp/org/ox-publish.el (org-publish-find-date)
(org-publish-cache-ctime-of-src):
* lisp/pcmpl-gnu.el (pcomplete/tar):
* lisp/pcmpl-rpm.el (pcmpl-rpm-packages):
* lisp/play/cookie1.el (cookie-snarf):
* lisp/progmodes/cmacexp.el (c-macro-expansion):
* lisp/ps-bdf.el (bdf-file-mod-time):
* lisp/server.el (server-ensure-safe-dir):
* lisp/simple.el (shell-command-on-region):
* lisp/speedbar.el (speedbar-item-info-file-helper)
(speedbar-check-obj-this-line):
* lisp/thumbs.el (thumbs-cleanup-thumbsdir):
* lisp/time.el (display-time-mail-check-directory)
(display-time-file-nonempty-p):
* lisp/url/url-cache.el (url-is-cached):
* lisp/url/url-file.el (url-file-asynch-callback):
* lisp/vc/diff-mode.el (diff-delete-if-empty):
* lisp/vc/pcvs-info.el (cvs-fileinfo-from-entries):
* lisp/vc/vc-bzr.el (vc-bzr-state-heuristic):
* lisp/vc/vc-cvs.el (vc-cvs-checkout-model)
(vc-cvs-state-heuristic, vc-cvs-merge-news)
(vc-cvs-retrieve-tag, vc-cvs-parse-status, vc-cvs-parse-entry):
* lisp/vc/vc-hg.el (vc-hg--slurp-hgignore-1)
(vc-hg--ignore-patterns-valid-p)
(vc-hg--cached-dirstate-search, vc-hg-state-fast):
* lisp/vc/vc-hooks.el (vc-after-save):
* lisp/vc/vc-rcs.el (vc-rcs-workfile-is-newer):
* lisp/vc/vc-svn.el (vc-svn-merge-news, vc-svn-parse-status):
* lisp/vc/vc.el (vc-checkout, vc-checkin, vc-revert-file):
* lisp/xdg.el (xdg-mime-apps):
Prefer (file-attribute-size A) to (nth 7 A), and similarly
for other file attributes accessors.
* doc/lispref/files.texi (File Attributes):
* doc/lispref/intro.texi (Version Info):
* doc/lispref/os.texi (Idle Timers):
* lisp/erc/erc.el (erc-string-to-emacs-time):
* lisp/files.el (file-attribute-access-time)
(file-attribute-modification-time)
(file-attribute-status-change-time):
* lisp/net/tramp-compat.el:
(tramp-compat-file-attribute-modification-time)
(tramp-compat-file-attribute-size):
* src/buffer.c (syms_of_buffer):
* src/editfns.c (Fget_internal_run_time):
* src/fileio.c (Fvisited_file_modtime)
(Fset_visited_file_modtime):
* src/keyboard.c (Fcurrent_idle_time):
* src/process.c (Fprocess_attributes):
Defer implementation details about timestamp format to the
section that talks about timestamp format, to make it easier
to change the documentation later if timestamp formats are
extended.
* lisp/gnus/gnus-util.el (gnus-file-newer-than):
* lisp/speedbar.el (speedbar-check-obj-this-line):
* lisp/vc/vc-rcs.el (vc-rcs-workfile-is-newer):
Prefer time-less-p to doing it by hand.
* lisp/ls-lisp.el (ls-lisp-format): Inode numbers are no longer conses.
* lisp/vc/vc-bzr.el (vc-bzr-state-heuristic):
Use eql, not eq, to compare integers that might be bignums.
* lisp/org/ox-publish.el (org-publish-cache-ctime-of-src):
Prefer float-time to doing time arithmetic by hand.
2018-09-23 18:30:46 -07:00
|
|
|
(setq size (file-attribute-size (file-attributes file)))
|
1998-02-01 17:10:21 +00:00
|
|
|
;; size could be nil if the sym-link points to a non-existent file
|
|
|
|
;; so check this first.
|
|
|
|
(if (and size (> size 0))
|
1997-05-20 21:48:58 +00:00
|
|
|
(cons spool size)
|
|
|
|
;; else SPOOL is empty
|
|
|
|
nil)))
|
|
|
|
|
|
|
|
(provide 'mspools)
|
1997-07-30 16:12:30 +00:00
|
|
|
|
2001-07-16 12:23:00 +00:00
|
|
|
;;; mspools.el ends here
|