annotate lisp/mail/metamail.el @ 11156:31a046cedfc8

(comint-read-noecho): Don't log prompt messages.
author Karl Heuer <kwzh@gnu.org>
date Thu, 30 Mar 1995 23:38:23 +0000
parents 341cd3b063ae
children 0a94cd2c51c4
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>
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6 ;; Version: $Header: metamail.el,v 1.5 93/07/08 21:56:49 umerin Exp $
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
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 ;; along with GNU Emacs; see the file COPYING. If not, write to
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25 ;;; Commentary:
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 ;; LCD Archive Entry:
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28 ;; metamail|Masanobu UMEDA|umerin@mse.kyutech.ac.jp|
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 ;; Metamail interface for GNU Emacs|
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30 ;; $Date: 93/07/08 21:56:49 $|$Revision: 1.5 $|~/misc/metamail.el.Z|
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32 ;; Note: Metamail does not have all options which is compatible with
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 ;; the environment variables. For that reason, matamail.el have to
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34 ;; hack the environment variables. In addition, there is no way to
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 ;; display all header fields without extra informative body messages
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 ;; which is suppressed by "-q" option.
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 ;; The idea of using metamail to process MIME messages is from
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 ;; gnus-mime.el by Spike <Spike@world.std.com>.
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 ;;; Code:
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43 (defvar metamail-program-name "metamail"
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 "*Metamail program name.")
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 (defvar metamail-environment '("KEYHEADS=*")
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47 "*Environment variables passed to `metamail'.
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48 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
49
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50 (defvar metamail-switches '("-m" "emacs" "-x" "-d" "-z")
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 "*Switches for `metamail' program.
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52 -z is required to remove zap file.")
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54 (defun metamail-buffer (&optional buffer nodisplay)
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55 "Process current buffer through `metamail'.
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 Optional 1st argument BUFFER specifies a buffer to be filled (nil
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 means current).
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 Optional 2nd argument NODISPLAY non-nil means buffer is not
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59 redisplayed as output is inserted."
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 (interactive)
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 (metamail-region (point-min) (point-max) buffer nodisplay))
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 (defun metamail-region (beg end &optional buffer nodisplay)
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 "Process current region through 'metamail'.
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 Optional 1st argument BUFFER specifies a buffer to be filled (nil
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 means current).
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67 Optional 2nd argument NODISPLAY non-nil means buffer is not
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 redisplayed as output is inserted."
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 (interactive "r")
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 (let ((curbuf (current-buffer))
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 (buffer-read-only nil)
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 (metafile (make-temp-name "/tmp/metamail")))
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 (save-excursion
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 ;; Gee! Metamail does not ouput to stdout if input comes from
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 ;; stdin.
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 (write-region beg end metafile nil 'nomessage)
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 (if buffer
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 (set-buffer buffer))
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79 (setq buffer-read-only nil)
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 ;; Clear destination buffer.
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 (if (eq curbuf (current-buffer))
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 (delete-region beg end)
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83 (delete-region (point-min) (point-max)))
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 ;; We have to pass the environment variable KEYHEADS to display
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 ;; all header fields. Metamail should have an optional argument
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86 ;; to pass such information directly.
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87 (let ((process-environment
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 (append metamail-environment process-environment)))
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 (apply (function call-process)
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 metamail-program-name
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 nil
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 t ;Output to current buffer
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93 (not nodisplay) ;Force redisplay
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 (append metamail-switches (list metafile))))
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95 ;; `metamail' may not delete the temporary file!
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 (condition-case error
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97 (delete-file metafile)
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 (error nil))
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99 )))
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 ;(defun metamail-region (beg end &optional buffer)
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 ; "Process current region through 'metamail'.
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 ;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
104 ; (interactive "r")
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105 ; (let ((curbuf (current-buffer))
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 ; (buffer-read-only nil)
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 ; (metafile (make-temp-name "/tmp/metamail")))
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 ; (save-excursion
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 ; (write-region (point-min) (point-max) metafile nil 'nomessage)
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110 ; (if (eq curbuf
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111 ; (if buffer (get-buffer buffer) (current-buffer)))
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112 ; (delete-region (point-min) (point-max)))
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 ; (apply (function call-process)
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 ; metamail-program-name
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115 ; nil
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116 ; (or buffer t) ;BUFFER or current buffer
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 ; nil ;don't redisplay
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 ; (append metamail-switches (list metafile)))
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 ; )))
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 (provide 'metamail)
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 ;;; metamail.el ends here