annotate lisp/mail/metamail.el @ 14946:3ad13f2b6ea0

(x_term_init): Respecify LC_NUMERIC locale.
author Richard M. Stallman <rms@gnu.org>
date Fri, 05 Apr 1996 18:17:07 +0000
parents 83f275dcd93a
children 6a6b3630e251
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4171
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1 ;;; metamail.el --- Metamail interface for GNU Emacs
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3 ;; Copyright (C) 1993 Masanobu UMEDA
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5 ;; Author: Masanobu UMEDA <umerin@mse.kyutech.ac.jp>
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14018
diff changeset
6 ;; Version: $Header: /home/gd/gnu/emacs/19.0/lisp/RCS/metamail.el,v 1.2 1996/01/05 00:07:09 kwzh Exp erik $
4171
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7 ;; Keywords: mail, news, mime, multimedia
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 ;; any later version.
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;; GNU General Public License for more details.
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14018
diff changeset
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14018
diff changeset
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14018
diff changeset
24 ;; Boston, MA 02111-1307, USA.
4171
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26 ;;; Commentary:
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28 ;; LCD Archive Entry:
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 ;; metamail|Masanobu UMEDA|umerin@mse.kyutech.ac.jp|
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30 ;; Metamail interface for GNU Emacs|
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14018
diff changeset
31 ;; $Date: 1996/01/05 00:07:09 $|$Revision: 1.2 $|~/misc/metamail.el.Z|
4171
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32
14018
0a94cd2c51c4 Comment fixes.
Karl Heuer <kwzh@gnu.org>
parents: 4171
diff changeset
33 ;; Note: Metamail does not have all options which are compatible with
0a94cd2c51c4 Comment fixes.
Karl Heuer <kwzh@gnu.org>
parents: 4171
diff changeset
34 ;; the environment variables. For that reason, metamail.el has to
4171
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 ;; hack the environment variables. In addition, there is no way to
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 ;; display all header fields without extra informative body messages
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37 ;; which is suppressed by "-q" option.
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 ;; The idea of using metamail to process MIME messages is from
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 ;; gnus-mime.el by Spike <Spike@world.std.com>.
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42 ;;; Code:
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 (defvar metamail-program-name "metamail"
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 "*Metamail program name.")
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47 (defvar metamail-environment '("KEYHEADS=*")
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48 "*Environment variables passed to `metamail'.
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49 It must ba a list of strings that have the format ENVVARNAME=VALUE.")
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 (defvar metamail-switches '("-m" "emacs" "-x" "-d" "-z")
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52 "*Switches for `metamail' program.
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53 -z is required to remove zap file.")
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55 (defun metamail-buffer (&optional buffer nodisplay)
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 "Process current buffer through `metamail'.
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 Optional 1st argument BUFFER specifies a buffer to be filled (nil
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 means current).
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59 Optional 2nd argument NODISPLAY non-nil means buffer is not
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 redisplayed as output is inserted."
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 (interactive)
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62 (metamail-region (point-min) (point-max) buffer nodisplay))
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 (defun metamail-region (beg end &optional buffer nodisplay)
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 "Process current region through 'metamail'.
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 Optional 1st argument BUFFER specifies a buffer to be filled (nil
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67 means current).
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 Optional 2nd argument NODISPLAY non-nil means buffer is not
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 redisplayed as output is inserted."
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 (interactive "r")
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 (let ((curbuf (current-buffer))
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 (buffer-read-only nil)
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 (metafile (make-temp-name "/tmp/metamail")))
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 (save-excursion
14018
0a94cd2c51c4 Comment fixes.
Karl Heuer <kwzh@gnu.org>
parents: 4171
diff changeset
75 ;; Gee! Metamail does not output to stdout if input comes from
4171
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 ;; stdin.
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 (write-region beg end metafile nil 'nomessage)
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 (if buffer
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79 (set-buffer buffer))
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 (setq buffer-read-only nil)
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 ;; Clear destination buffer.
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 (if (eq curbuf (current-buffer))
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83 (delete-region beg end)
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 (delete-region (point-min) (point-max)))
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 ;; We have to pass the environment variable KEYHEADS to display
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86 ;; all header fields. Metamail should have an optional argument
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87 ;; to pass such information directly.
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 (let ((process-environment
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 (append metamail-environment process-environment)))
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 (apply (function call-process)
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 metamail-program-name
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 nil
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93 t ;Output to current buffer
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 (not nodisplay) ;Force redisplay
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95 (append metamail-switches (list metafile))))
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 ;; `metamail' may not delete the temporary file!
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97 (condition-case error
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 (delete-file metafile)
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99 (error nil))
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100 )))
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 ;(defun metamail-region (beg end &optional buffer)
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 ; "Process current region through 'metamail'.
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 ;Optional argument BUFFER specifies a buffer to be filled (nil means current)."
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105 ; (interactive "r")
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 ; (let ((curbuf (current-buffer))
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 ; (buffer-read-only nil)
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 ; (metafile (make-temp-name "/tmp/metamail")))
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 ; (save-excursion
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110 ; (write-region (point-min) (point-max) metafile nil 'nomessage)
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111 ; (if (eq curbuf
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112 ; (if buffer (get-buffer buffer) (current-buffer)))
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 ; (delete-region (point-min) (point-max)))
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 ; (apply (function call-process)
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115 ; metamail-program-name
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116 ; nil
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 ; (or buffer t) ;BUFFER or current buffer
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 ; nil ;don't redisplay
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 ; (append metamail-switches (list metafile)))
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 ; )))
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 (provide 'metamail)
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124 ;;; metamail.el ends here