0
|
1 ;;; metamail.el --- Metamail interface for GNU Emacs
|
|
2 ;; Keywords: mail, news, mime, multimedia
|
|
3
|
|
4 ;; Copyright (C) 1993 Masanobu UMEDA
|
|
5
|
|
6 ;; Author: Masanobu UMEDA <umerin@mse.kyutech.ac.jp>
|
|
7 ;; Version: Header: /cadillac-inferno-5/cvs-master/lemacs/lisp/packages/metamail.el,v 1.1 1993/12/01 08:54:51 jwz Exp
|
|
8 ;; Keywords: mail, news, mime, multimedia
|
|
9
|
|
10 ;; This file is part of XEmacs.
|
|
11
|
|
12 ;; XEmacs is free software; you can redistribute it and/or modify it
|
|
13 ;; 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 ;; XEmacs is distributed in the hope that it will be useful, but
|
|
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
20 ;; General Public License for more details.
|
|
21
|
|
22 ;; You should have received a copy of the GNU General Public License
|
|
23 ;; along with XEmacs; see the file COPYING. If not, write to the Free
|
|
24 ;; Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
25
|
|
26 ;;; Synched up with: Very similar to but not quite synched with
|
|
27 ;;; FSF 19.30.
|
|
28
|
|
29 ;;; Commentary:
|
|
30
|
|
31 ;; LCD Archive Entry:
|
|
32 ;; metamail|Masanobu UMEDA|umerin@mse.kyutech.ac.jp|
|
|
33 ;; Metamail interface for GNU Emacs|
|
|
34 ;; !Date: 1993/12/01 08:54:51 !|!Revision: 1.1 !|~/misc/metamail.el.Z|
|
|
35
|
|
36 ;; Note: Metamail does not have all options which is compatible with
|
|
37 ;; the environment variables. For that reason, matamail.el have to
|
|
38 ;; hack the environment variables. In addition, there is no way to
|
|
39 ;; display all header fields without extra informative body messages
|
|
40 ;; which is suppressed by "-q" option.
|
|
41
|
|
42 ;; The idea of using metamail to process MIME messages is from
|
|
43 ;; gnus-mime.el by Spike <Spike@world.std.com>.
|
|
44
|
|
45 ;;; Code:
|
|
46
|
|
47 (defvar metamail-program-name "metamail"
|
|
48 "*Metamail program name.")
|
|
49
|
|
50 (defvar metamail-environment "KEYHEADS='*';export KEYHEADS;"
|
|
51 "*Environment variables for Metamail.
|
|
52 It must be an emtpy string or a string terminated with ';'.")
|
|
53
|
|
54 (defvar metamail-switches '("-m" "emacs" "-x" "-d" "-z")
|
|
55 "*Switches for Metamail program.
|
|
56 -z is required to remove zap file.")
|
|
57
|
|
58 (defun metamail-buffer (&optional buffer)
|
|
59 "Process current buffer through 'metamail'.
|
|
60 Optional argument BUFFER specifies a buffer to be filled (nil means current)."
|
|
61 (interactive)
|
|
62 (metamail-region (point-min) (point-max) buffer))
|
|
63
|
|
64 (defun metamail-region (beg end &optional buffer)
|
|
65 "Process current region through 'metamail'.
|
|
66 Optional argument BUFFER specifies a buffer to be filled (nil means current)."
|
|
67 (interactive "r")
|
|
68 (let ((curbuf (current-buffer))
|
|
69 (buffer-read-only nil)
|
|
70 (metafile (make-temp-name "/tmp/metamail")))
|
|
71 (save-excursion
|
|
72 ;; Gee! Metamail does not ouput to stdout if input comes from
|
|
73 ;; stdin.
|
|
74 (write-region beg end metafile nil 'nomessage)
|
|
75 (if buffer
|
|
76 (set-buffer buffer))
|
|
77 (setq buffer-read-only nil)
|
|
78 ;; Clear destination buffer.
|
|
79 (if (eq curbuf (current-buffer))
|
|
80 (delete-region beg end)
|
|
81 (delete-region (point-min) (point-max)))
|
|
82 ;; We have to pass the environment variable KEYHEADS to /bin/sh
|
|
83 ;; to display all header fields. Metamail should have an
|
|
84 ;; optional argument to pass such information directly.
|
|
85 (apply (function call-process)
|
|
86 "/bin/sh"
|
|
87 nil
|
|
88 t ;Output to current buffer
|
|
89 t ;Force redisplay
|
|
90 (list "-c"
|
|
91 ;; Construct environment and the command.
|
|
92 (concat
|
|
93 metamail-environment
|
|
94 metamail-program-name
|
|
95 " "
|
|
96 (mapconcat (function identity) metamail-switches " ")
|
|
97 " "
|
|
98 metafile
|
|
99 )))
|
|
100 )))
|
|
101
|
|
102 ;(defun metamail-region (beg end &optional buffer)
|
|
103 ; "Process current region through 'metamail'.
|
|
104 ;Optional argument BUFFER specifies a buffer to be filled (nil means current)."
|
|
105 ; (interactive "r")
|
|
106 ; (let ((curbuf (current-buffer))
|
|
107 ; (buffer-read-only nil)
|
|
108 ; (metafile (make-temp-name "/tmp/metamail")))
|
|
109 ; (save-excursion
|
|
110 ; (write-region (point-min) (point-max) metafile nil 'nomessage)
|
|
111 ; (if (eq curbuf
|
|
112 ; (if buffer (get-buffer buffer) (current-buffer)))
|
|
113 ; (delete-region (point-min) (point-max)))
|
|
114 ; (apply (function call-process)
|
|
115 ; metamail-program-name
|
|
116 ; nil
|
|
117 ; (or buffer t) ;BUFFER or current buffer
|
|
118 ; nil ;don't redisplay
|
|
119 ; (append metamail-switches (list metafile)))
|
|
120 ; )))
|
|
121
|
|
122 (provide 'metamail)
|
|
123
|
|
124 ;;; metamail.el ends here
|