annotate lisp/packages/metamail.el @ 110:fe104dbd9147 r20-1b7

Import from CVS: tag r20-1b7
author cvs
date Mon, 13 Aug 2007 09:19:45 +0200
parents 1040fe1366ac
children 538048ae2ab8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; metamail.el --- Metamail interface for GNU Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3 ;; Copyright (C) 1993, 1996 Masanobu UMEDA
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Author: Masanobu UMEDA <umerin@mse.kyutech.ac.jp>
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 94
diff changeset
6 ;; Version: $Header: /afs/informatik.uni-tuebingen.de/local/web/xemacs/xemacs-cvs/XEmacs/xemacs/lisp/packages/Attic/metamail.el,v 1.3 1997/03/16 03:05:29 steve Exp $
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; Keywords: mail, news, mime, multimedia
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; XEmacs is distributed in the hope that it will be useful, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; along with XEmacs; see the file COPYING. If not, write to the Free
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
23 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
24 ;; 02111-1307, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
26 ;;; Synched up with: FSF 19.34.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
30 ;; I trashed all the differences this file had from the FSF version.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
31 ;; So sue me. -sb
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
32
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
33 ;; The latest version will be at:
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
34 ;; ftp://ftp.kyutech.ac.jp/pub/MultiMedia/mime/emacs-mime-tools.shar
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;; Note: Metamail does not have all options which is compatible with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;; the environment variables. For that reason, matamail.el have to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;; hack the environment variables. In addition, there is no way to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;; display all header fields without extra informative body messages
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
40 ;; which are suppressed by "-q" option.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
41
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
42 ;; The following definition is what I'm using with GNUS 4:
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
43 ;;(setq gnus-show-mime-method
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
44 ;; (function
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
45 ;; (lambda ()
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
46 ;; (metamail-interpret-header)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
47 ;; (let ((metamail-switches ;Suppress header fields in a body.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
48 ;; (append metamail-switches '("-q"))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
49 ;; (metamail-interpret-body)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;; The idea of using metamail to process MIME messages is from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 ;; gnus-mime.el by Spike <Spike@world.std.com>.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (defvar metamail-program-name "metamail"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 "*Metamail program name.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
59 (defvar metamail-mailer-name "emacs"
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
60 "*Mailer name set to MM_MAILER environment variable.")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
61
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
62 (defvar metamail-environment '("KEYHEADS=*" "MM_QUIET=1")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
63 "*Environment variables passed to `metamail'.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
64 It must be a list of strings that have the format ENVVARNAME=VALUE.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
65 It is not expected to be altered globally by `set' or `setq'.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
66 Instead, change its value temporary using `let' or `let*' form.")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
67
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
68 (defvar metamail-switches '("-x" "-d" "-z")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
69 "*Switches for `metamail' program.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
70 `-z' is required to remove zap file.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
71 It is not expected to be altered globally by `set' or `setq'.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
72 Instead, change its value temporary using `let' or `let*' form.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
73 `-m MAILER' argument is automatically generated from the
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
74 `metamail-mailer-name' variable.")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
76 ;;;###autoload
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
77 (defun metamail-interpret-header ()
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
78 "Interpret a header part of a MIME message in current buffer.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
79 Its body part is not interpreted at all."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
80 (interactive)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
81 (save-excursion
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
82 (let* ((buffer-read-only nil)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
83 (metamail-switches ;Inhibit processing an empty body.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
84 (append metamail-switches '("-c" "text/plain" "-E" "7bit")))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
85 (end (progn
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
86 (goto-char (point-min))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
87 (search-forward "\n\n" nil 'move)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
88 ;; An extra newline is inserted by metamail if there
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
89 ;; is no body part. So, insert a dummy body by
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
90 ;; itself.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
91 (insert "\n")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
92 (point))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
93 (metamail-region (point-min) end nil nil 'nodisplay)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
94 ;; Remove an extra newline inserted by myself.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
95 (goto-char (point-min))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
96 (if (search-forward "\n\n\n" nil t)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
97 (delete-char -1))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
98 )))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
100 ;;;###autoload
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
101 (defun metamail-interpret-body (&optional viewmode nodisplay)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
102 "Interpret a body part of a MIME message in current buffer.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
103 Optional argument VIEWMODE specifies the value of the
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
104 EMACS_VIEW_MODE environment variable (defaulted to 1).
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
105 Optional argument NODISPLAY non-nil means buffer is not
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
106 redisplayed as output is inserted.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
107 Its header part is not interpreted at all."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
108 (interactive "p")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
109 (save-excursion
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
110 (let ((contype nil)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
111 (encoding nil)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
112 (end (progn
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
113 (goto-char (point-min))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
114 (search-forward "\n\n" nil t)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
115 (point))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
116 ;; Find Content-Type and Content-Transfer-Encoding from the header.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
117 (save-restriction
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
118 (narrow-to-region (point-min) end)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
119 (setq contype
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
120 (or (mail-fetch-field "Content-Type") "text/plain"))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
121 (setq encoding
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
122 (or (mail-fetch-field "Content-Transfer-Encoding") "7bit")))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
123 ;; Interpret the body part only.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
124 (let ((metamail-switches ;Process body part only.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
125 (append metamail-switches
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
126 (list "-b" "-c" contype "-E" encoding))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
127 (metamail-region end (point-max) viewmode nil nodisplay))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
128 ;; Mode specific hack.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
129 (cond ((eq major-mode 'rmail-mode)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
130 ;; Adjust the marker of this message if in Rmail mode buffer.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
131 (set-marker (aref rmail-message-vector (1+ rmail-current-message))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
132 (point-max))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
133 )))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
135 ;;;###autoload
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
136 (defun metamail-buffer (&optional viewmode buffer nodisplay)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
137 "Process current buffer through `metamail'.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
138 Optional argument VIEWMODE specifies the value of the
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
139 EMACS_VIEW_MODE environment variable (defaulted to 1).
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
140 Optional argument BUFFER specifies a buffer to be filled (nil
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
141 means current).
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
142 Optional argument NODISPLAY non-nil means buffer is not
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
143 redisplayed as output is inserted."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
144 (interactive "p")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
145 (metamail-region (point-min) (point-max) viewmode buffer nodisplay))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
146
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
147 ;;;###autoload
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
148 (defun metamail-region (beg end &optional viewmode buffer nodisplay)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 "Process current region through 'metamail'.
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
150 Optional argument VIEWMODE specifies the value of the
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
151 EMACS_VIEW_MODE environment variable (defaulted to 1).
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
152 Optional argument BUFFER specifies a buffer to be filled (nil
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
153 means current).
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
154 Optional argument NODISPLAY non-nil means buffer is not
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
155 redisplayed as output is inserted."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
156 (interactive "r\np")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (let ((curbuf (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (buffer-read-only nil)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
159 (metafile (make-temp-name "/tmp/metamail"))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
160 (option-environment
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
161 (list (concat "EMACS_VIEW_MODE="
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
162 (if (numberp viewmode) viewmode 1)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 ;; Gee! Metamail does not ouput to stdout if input comes from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 ;; stdin.
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 94
diff changeset
166 (let ((selective-display nil) ;Disable ^M to nl translation.
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 94
diff changeset
167 (kanji-fileio-code 2) ;Write in JIS code when nemacs.
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 94
diff changeset
168 (file-coding-system ;Write in JUNET style when mule.
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 94
diff changeset
169 (if (featurep 'mule) '*junet*))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 94
diff changeset
170 (coding-system-for-write ;Write in iso-2022-jp style
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 94
diff changeset
171 'iso-2022-jp) ; when XEmacs/mule
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 94
diff changeset
172 )
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
173 (write-region beg end metafile nil 'nomessage))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (if buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (set-buffer buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (setq buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 ;; Clear destination buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (if (eq curbuf (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (delete-region beg end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (delete-region (point-min) (point-max)))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
181 ;; We have to pass the environment variable KEYHEADS to display
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
182 ;; all header fields. Metamail should have an optional argument
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
183 ;; to pass such information directly.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
184 (let ((process-environment
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
185 (append process-environment
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
186 metamail-environment option-environment)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
187 ;; Specify character coding system.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
188 (if (boundp 'NEMACS)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
189 (define-program-kanji-code nil metamail-program-name 2)) ;JIS
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
190 (if (featurep 'mule)
94
1040fe1366ac Import from CVS: tag xemacs-20-0f2
cvs
parents: 70
diff changeset
191 (if (fboundp 'define-program-coding-system)
1040fe1366ac Import from CVS: tag xemacs-20-0f2
cvs
parents: 70
diff changeset
192 (define-program-coding-system
1040fe1366ac Import from CVS: tag xemacs-20-0f2
cvs
parents: 70
diff changeset
193 nil
1040fe1366ac Import from CVS: tag xemacs-20-0f2
cvs
parents: 70
diff changeset
194 metamail-program-name
1040fe1366ac Import from CVS: tag xemacs-20-0f2
cvs
parents: 70
diff changeset
195 'junet)
1040fe1366ac Import from CVS: tag xemacs-20-0f2
cvs
parents: 70
diff changeset
196 ;; XEmacs with MULE
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 94
diff changeset
197 (setq buffer-file-coding-system 'junet)))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
198 (apply (function call-process)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
199 metamail-program-name
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
200 nil
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
201 t ;Output to current buffer
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
202 (not nodisplay) ;Force redisplay
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
203 (append metamail-switches
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
204 (list "-m" (or metamail-mailer-name "emacs"))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
205 (list metafile))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
206 ;; `metamail' may not delete the temporary file!
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
207 (condition-case error
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
208 (delete-file metafile)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
209 (error nil))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (provide 'metamail)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 ;;; metamail.el ends here