annotate lisp/packages/metamail.el @ 0:376386a54a3c r19-14

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