annotate lisp/packages/metamail.el @ 191:ecf6ba7b0a10 r20-3b22

Import from CVS: tag r20-3b22
author cvs
date Mon, 13 Aug 2007 09:57:38 +0200
parents 538048ae2ab8
children
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>
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 110
diff changeset
6 ;; Version: $Header: /afs/informatik.uni-tuebingen.de/local/web/xemacs/xemacs-cvs/XEmacs/xemacs/lisp/packages/Attic/metamail.el,v 1.4 1997/05/18 03:40:08 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
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 110
diff changeset
56 (defgroup metamail nil
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 110
diff changeset
57 "Metamail interface for Emacs."
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 110
diff changeset
58 :group 'mail
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 110
diff changeset
59 :group 'hypermedia
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 110
diff changeset
60 :group 'processes)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 110
diff changeset
62 (defcustom metamail-program-name "metamail"
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 110
diff changeset
63 "*Metamail program name."
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 110
diff changeset
64 :type 'string
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 110
diff changeset
65 :group 'metamail)
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 110
diff changeset
66
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 110
diff changeset
67 (defcustom metamail-mailer-name "emacs"
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 110
diff changeset
68 "*Mailer name set to MM_MAILER environment variable."
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 110
diff changeset
69 :type 'string
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 110
diff changeset
70 :group 'metamail)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
71
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
72 (defvar metamail-environment '("KEYHEADS=*" "MM_QUIET=1")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
73 "*Environment variables passed to `metamail'.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
74 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
75 It is not expected to be altered globally by `set' or `setq'.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
76 Instead, change its value temporary using `let' or `let*' form.")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
77
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 110
diff changeset
78 (defcustom metamail-switches '("-x" "-d" "-z")
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
79 "*Switches for `metamail' program.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
80 `-z' is required to remove zap file.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
81 It is not expected to be altered globally by `set' or `setq'.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
82 Instead, change its value temporary using `let' or `let*' form.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
83 `-m MAILER' argument is automatically generated from the
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 110
diff changeset
84 `metamail-mailer-name' variable."
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 110
diff changeset
85 :type '(repeat (string :tag "Switch"))
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 110
diff changeset
86 :group 'metamail)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
88 ;;;###autoload
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
89 (defun metamail-interpret-header ()
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
90 "Interpret a header part of a MIME message in current buffer.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
91 Its body part is not interpreted at all."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
92 (interactive)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
93 (save-excursion
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
94 (let* ((buffer-read-only nil)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
95 (metamail-switches ;Inhibit processing an empty body.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
96 (append metamail-switches '("-c" "text/plain" "-E" "7bit")))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
97 (end (progn
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
98 (goto-char (point-min))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
99 (search-forward "\n\n" nil 'move)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
100 ;; An extra newline is inserted by metamail if there
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
101 ;; is no body part. So, insert a dummy body by
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
102 ;; itself.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
103 (insert "\n")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
104 (point))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
105 (metamail-region (point-min) end nil nil 'nodisplay)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
106 ;; Remove an extra newline inserted by myself.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
107 (goto-char (point-min))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
108 (if (search-forward "\n\n\n" nil t)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
109 (delete-char -1))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
110 )))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
112 ;;;###autoload
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
113 (defun metamail-interpret-body (&optional viewmode nodisplay)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
114 "Interpret a body part of a MIME message in current buffer.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
115 Optional argument VIEWMODE specifies the value of the
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
116 EMACS_VIEW_MODE environment variable (defaulted to 1).
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
117 Optional argument NODISPLAY non-nil means buffer is not
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
118 redisplayed as output is inserted.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
119 Its header part is not interpreted at all."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
120 (interactive "p")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
121 (save-excursion
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
122 (let ((contype nil)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
123 (encoding nil)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
124 (end (progn
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
125 (goto-char (point-min))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
126 (search-forward "\n\n" nil t)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
127 (point))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
128 ;; Find Content-Type and Content-Transfer-Encoding from the header.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
129 (save-restriction
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
130 (narrow-to-region (point-min) end)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
131 (setq contype
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
132 (or (mail-fetch-field "Content-Type") "text/plain"))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
133 (setq encoding
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
134 (or (mail-fetch-field "Content-Transfer-Encoding") "7bit")))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
135 ;; Interpret the body part only.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
136 (let ((metamail-switches ;Process body part only.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
137 (append metamail-switches
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
138 (list "-b" "-c" contype "-E" encoding))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
139 (metamail-region end (point-max) viewmode nil nodisplay))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
140 ;; Mode specific hack.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
141 (cond ((eq major-mode 'rmail-mode)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
142 ;; Adjust the marker of this message if in Rmail mode buffer.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
143 (set-marker (aref rmail-message-vector (1+ rmail-current-message))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
144 (point-max))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
145 )))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146
2
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-buffer (&optional viewmode buffer nodisplay)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
149 "Process current buffer through `metamail'.
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 "p")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
157 (metamail-region (point-min) (point-max) viewmode buffer nodisplay))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
158
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
159 ;;;###autoload
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
160 (defun metamail-region (beg end &optional viewmode buffer nodisplay)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 "Process current region through 'metamail'.
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
162 Optional argument VIEWMODE specifies the value of the
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
163 EMACS_VIEW_MODE environment variable (defaulted to 1).
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
164 Optional argument BUFFER specifies a buffer to be filled (nil
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
165 means current).
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
166 Optional argument NODISPLAY non-nil means buffer is not
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
167 redisplayed as output is inserted."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
168 (interactive "r\np")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (let ((curbuf (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (buffer-read-only nil)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
171 (metafile (make-temp-name "/tmp/metamail"))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
172 (option-environment
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
173 (list (concat "EMACS_VIEW_MODE="
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
174 (if (numberp viewmode) viewmode 1)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 ;; Gee! Metamail does not ouput to stdout if input comes from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 ;; stdin.
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 94
diff changeset
178 (let ((selective-display nil) ;Disable ^M to nl translation.
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 94
diff changeset
179 (kanji-fileio-code 2) ;Write in JIS code when nemacs.
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 94
diff changeset
180 (file-coding-system ;Write in JUNET style when mule.
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 94
diff changeset
181 (if (featurep 'mule) '*junet*))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 94
diff changeset
182 (coding-system-for-write ;Write in iso-2022-jp style
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 94
diff changeset
183 'iso-2022-jp) ; when XEmacs/mule
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 94
diff changeset
184 )
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
185 (write-region beg end metafile nil 'nomessage))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (if buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (set-buffer buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (setq buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 ;; Clear destination buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (if (eq curbuf (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (delete-region beg end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (delete-region (point-min) (point-max)))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
193 ;; We have to pass the environment variable KEYHEADS to display
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
194 ;; all header fields. Metamail should have an optional argument
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
195 ;; to pass such information directly.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
196 (let ((process-environment
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
197 (append process-environment
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
198 metamail-environment option-environment)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
199 ;; Specify character coding system.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
200 (if (boundp 'NEMACS)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
201 (define-program-kanji-code nil metamail-program-name 2)) ;JIS
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
202 (if (featurep 'mule)
94
1040fe1366ac Import from CVS: tag xemacs-20-0f2
cvs
parents: 70
diff changeset
203 (if (fboundp 'define-program-coding-system)
1040fe1366ac Import from CVS: tag xemacs-20-0f2
cvs
parents: 70
diff changeset
204 (define-program-coding-system
1040fe1366ac Import from CVS: tag xemacs-20-0f2
cvs
parents: 70
diff changeset
205 nil
1040fe1366ac Import from CVS: tag xemacs-20-0f2
cvs
parents: 70
diff changeset
206 metamail-program-name
1040fe1366ac Import from CVS: tag xemacs-20-0f2
cvs
parents: 70
diff changeset
207 'junet)
1040fe1366ac Import from CVS: tag xemacs-20-0f2
cvs
parents: 70
diff changeset
208 ;; XEmacs with MULE
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 94
diff changeset
209 (setq buffer-file-coding-system 'junet)))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
210 (apply (function call-process)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
211 metamail-program-name
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
212 nil
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
213 t ;Output to current buffer
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
214 (not nodisplay) ;Force redisplay
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
215 (append metamail-switches
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
216 (list "-m" (or metamail-mailer-name "emacs"))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
217 (list metafile))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
218 ;; `metamail' may not delete the temporary file!
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
219 (condition-case error
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
220 (delete-file metafile)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
221 (error nil))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (provide 'metamail)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 ;;; metamail.el ends here