mh-inc.el 3.0 KB

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