1;;; mh-inc.el --- MH-E "inc" and separate mail spool handling
2
3;; Copyright (C) 2003, 2004, 2006, 2007 Free Software Foundation, Inc.
4
5;; Author: Peter S. Galbraith <psg@debian.org>
6;; Maintainer: Bill Wohler <wohler@newt.com>
7;; Keywords: mail
8;; See: mh-e.el
9
10;; This file is part of GNU Emacs.
11
12;; GNU Emacs is free software; you can redistribute it and/or modify
13;; it under the terms of the GNU General Public License as published by
14;; the Free Software Foundation; either version 2, or (at your option)
15;; any later version.
16
17;; GNU Emacs is distributed in the hope that it will be useful,
18;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20;; GNU General Public License for more details.
21
22;; You should have received a copy of the GNU General Public License
23;; along with GNU Emacs; see the file COPYING.  If not, write to the
24;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25;; Boston, MA 02110-1301, USA.
26
27;;; Commentary:
28
29;; Support for inc. In addition to reading from the system mailbox,
30;; inc can also be used to incorporate mail from multiple spool files
31;; into separate folders. See "C-h v mh-inc-spool-list".
32
33;;; Change Log:
34
35;;; Code:
36
37(require 'mh-e)
38(mh-require-cl)
39
40(defvar mh-inc-spool-map-help nil
41  "Help text for `mh-inc-spool-map'.")
42
43(define-key mh-inc-spool-map "?"
44  '(lambda ()
45     (interactive)
46     (if mh-inc-spool-map-help
47         (mh-help mh-inc-spool-map-help)
48       (mh-ephem-message
49        "There are no keys defined yet; customize `mh-inc-spool-list'"))))
50
51;;;###mh-autoload
52(defun mh-inc-spool-make ()
53  "Make all commands and defines keys for contents of `mh-inc-spool-list'."
54  (setq mh-inc-spool-map-help nil)
55  (when mh-inc-spool-list
56    (loop for elem in mh-inc-spool-list
57          do (let ((spool (nth 0 elem))
58                   (folder (nth 1 elem))
59                   (key (nth 2 elem)))
60               (progn
61                 (mh-inc-spool-generator folder spool)
62                 (mh-inc-spool-def-key key folder))))))
63
64(defalias 'mh-inc-spool-make-no-autoload 'mh-inc-spool-make)
65
66(defun mh-inc-spool-generator (folder spool)
67  "Create a command to inc into FOLDER from SPOOL file."
68  (let ((folder1 (make-symbol "folder"))
69        (spool1 (make-symbol "spool")))
70    (set folder1 folder)
71    (set spool1 spool)
72    (setf (symbol-function (intern (concat "mh-inc-spool-" folder)))
73          `(lambda ()
74             ,(format "Inc spool file %s into folder %s." spool folder)
75             (interactive)
76             (mh-inc-folder ,spool1 (concat "+" ,folder1))))))
77
78(defun mh-inc-spool-def-key (key folder)
79  "Define a KEY in `mh-inc-spool-map' to inc FOLDER and collect help string."
80  (when (not (= 0 key))
81    (define-key mh-inc-spool-map (format "%c" key)
82       (intern (concat "mh-inc-spool-" folder)))
83    (add-to-list 'mh-inc-spool-map-help
84                 (concat "[" (char-to-string key) "] inc " folder " folder\n")
85                 t)))
86
87(provide 'mh-inc)
88
89;; Local Variables:
90;; indent-tabs-mode: nil
91;; sentence-end-double-space: nil
92;; End:
93
94;; arch-tag: 3713cf2a-6082-4cb4-8ce2-99d9acaba835
95;;; mh-inc.el ends here
96