Add standard library headers.
[emacs.git] / lisp / mail / unrmail.el
blob0850d4be05ef417386243d0ae1324d826b3c5fa1
1 ;;; unrmail.el --- convert Rmail files to mailbox files.
3 ;;; Copyright (C) 1992 Free Software Foundation, Inc.
5 ;; This file is part of GNU Emacs.
7 ;; GNU Emacs is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation; either version 2, or (at your option)
10 ;; 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.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GNU Emacs; see the file COPYING. If not, write to
19 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21 ;;; Code:
23 (defvar command-line-args-left) ;Avoid 'free variable' warning
25 ;;;###autoload
26 (defun batch-unrmail ()
27 "Convert Rmail files to mailbox files.
28 Specify the input Rmail file names as command line arguments.
29 For each Rmail file, the corresponding output file name
30 is made by adding `.mail' at the end.
31 For example, invoke `emacs -batch -f batch-unrmail RMAIL'."
32 ;; command-line-args-left is what is left of the command line (from startup.el)
33 (if (not noninteractive)
34 (error "`batch-unrmail' is to be used only with -batch"))
35 (let ((error nil))
36 (while command-line-args-left
37 (or (unrmail (car command-line-args-left)
38 (concat (car command-line-args-left) ".mail"))
39 (setq error t))
40 (setq command-line-args-left (cdr command-line-args-left)))
41 (message "Done")
42 (kill-emacs (if error 1 0))))
44 ;;;###autoload
45 (defun unrmail (file to-file)
46 "Convert Rmail file FILE to mailbox-format file TO-FILE."
47 (interactive "fUnrmail (rmail file): \nfUnrmail into (new mailbox file): ")
48 (let ((message-count 0))
49 (rmail file)
50 (rmail-show-message 1)
51 (while (not (rmail-output to-file))
52 (setq message-count (1+ message-count)))))
54 ;;; unrmail.el ends here