annotate lisp/mail/metamail.el @ 106039:84036421a1d0

(calc-embedded-mode-vars): Add `calc-complement-signed-mode'.
author Jay Belanger <jay.p.belanger@gmail.com>
date Mon, 16 Nov 2009 00:01:17 +0000
parents 3459df385d69
children 1d1d5d9bd884
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
74509
f7702c5f335d Update copyright years.
Glenn Morris <rgm@gnu.org>
parents: 68648
diff changeset
3 ;; Copyright (C) 1993, 1996, 2001, 2002, 2003, 2004,
100908
a9dc0e7c3f2b Add 2009 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 94674
diff changeset
4 ;; 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
4171
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6 ;; Author: Masanobu UMEDA <umerin@mse.kyutech.ac.jp>
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
94674
ef65fa4dca3b Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
4171
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
94674
ef65fa4dca3b Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
13 ;; the Free Software Foundation, either version 3 of the License, or
ef65fa4dca3b Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
14 ;; (at your option) any later version.
4171
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
94674
ef65fa4dca3b Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
4171
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24 ;;; Commentary:
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25
33414
9c3a204531a0 comment fixes
Dave Love <fx@gnu.org>
parents: 26039
diff changeset
26 ;; Note: Metamail does not have all the options which are compatible with
9c3a204531a0 comment fixes
Dave Love <fx@gnu.org>
parents: 26039
diff changeset
27 ;; the environment variables. For that reason, metamail.el has to
4171
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28 ;; hack the environment variables. In addition, there is no way to
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 ;; display all header fields without extra informative body messages
33414
9c3a204531a0 comment fixes
Dave Love <fx@gnu.org>
parents: 26039
diff changeset
30 ;; which are suppressed by the "-q" option.
4171
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 ;; The idea of using metamail to process MIME messages is from
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 ;; gnus-mime.el by Spike <Spike@world.std.com>.
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 ;;; Code:
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36
65212
fa5b2493902e (rmail-current-message, rmail-message-vector): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents: 64754
diff changeset
37 (defvar rmail-current-message)
fa5b2493902e (rmail-current-message, rmail-message-vector): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents: 64754
diff changeset
38 (defvar rmail-message-vector)
fa5b2493902e (rmail-current-message, rmail-message-vector): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents: 64754
diff changeset
39
17663
d2c64a1563f7 Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17661
diff changeset
40 (defgroup metamail nil
d2c64a1563f7 Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17661
diff changeset
41 "Metamail interface for Emacs."
d2c64a1563f7 Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17661
diff changeset
42 :group 'mail
d2c64a1563f7 Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17661
diff changeset
43 :group 'hypermedia
d2c64a1563f7 Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17661
diff changeset
44 :group 'processes)
4171
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45
17663
d2c64a1563f7 Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17661
diff changeset
46 (defcustom metamail-program-name "metamail"
d2c64a1563f7 Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17661
diff changeset
47 "*Metamail program name."
d2c64a1563f7 Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17661
diff changeset
48 :type 'string
d2c64a1563f7 Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17661
diff changeset
49 :group 'metamail)
d2c64a1563f7 Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17661
diff changeset
50
d2c64a1563f7 Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17661
diff changeset
51 (defcustom metamail-mailer-name "emacs"
d2c64a1563f7 Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17661
diff changeset
52 "*Mailer name set to MM_MAILER environment variable."
d2c64a1563f7 Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17661
diff changeset
53 :type 'string
d2c64a1563f7 Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17661
diff changeset
54 :group 'metamail)
15051
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
55
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
56 (defvar metamail-environment '("KEYHEADS=*" "MM_QUIET=1")
4171
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 "*Environment variables passed to `metamail'.
15051
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
58 It must be a list of strings that have the format ENVVARNAME=VALUE.
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
59 It is not expected to be altered globally by `set' or `setq'.
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
60 Instead, change its value temporary using `let' or `let*' form.")
4171
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61
17663
d2c64a1563f7 Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17661
diff changeset
62 (defcustom metamail-switches '("-x" "-d" "-z")
4171
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 "*Switches for `metamail' program.
15051
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
64 `-z' is required to remove zap file.
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
65 It is not expected to be altered globally by `set' or `setq'.
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
66 Instead, change its value temporary using `let' or `let*' form.
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
67 `-m MAILER' argument is automatically generated from the
17663
d2c64a1563f7 Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17661
diff changeset
68 `metamail-mailer-name' variable."
d2c64a1563f7 Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17661
diff changeset
69 :type '(repeat (string :tag "Switch"))
d2c64a1563f7 Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17661
diff changeset
70 :group 'metamail)
15051
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
71
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
72 ;;;###autoload
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
73 (defun metamail-interpret-header ()
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
74 "Interpret a header part of a MIME message in current buffer.
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
75 Its body part is not interpreted at all."
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
76 (interactive)
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
77 (save-excursion
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
78 (let* ((buffer-read-only nil)
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
79 (metamail-switches ;Inhibit processing an empty body.
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
80 (append metamail-switches '("-c" "text/plain" "-E" "7bit")))
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
81 (end (progn
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
82 (goto-char (point-min))
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
83 (search-forward "\n\n" nil 'move)
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
84 ;; An extra newline is inserted by metamail if there
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
85 ;; is no body part. So, insert a dummy body by
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
86 ;; itself.
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
87 (insert "\n")
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
88 (point))))
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
89 (metamail-region (point-min) end nil nil 'nodisplay)
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
90 ;; Remove an extra newline inserted by myself.
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
91 (goto-char (point-min))
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
92 (if (search-forward "\n\n\n" nil t)
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
93 (delete-char -1))
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
94 )))
4171
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95
15051
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
96 ;;;###autoload
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
97 (defun metamail-interpret-body (&optional viewmode nodisplay)
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
98 "Interpret a body part of a MIME message in current buffer.
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
99 Optional argument VIEWMODE specifies the value of the
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
100 EMACS_VIEW_MODE environment variable (defaulted to 1).
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
101 Optional argument NODISPLAY non-nil means buffer is not
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
102 redisplayed as output is inserted.
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
103 Its header part is not interpreted at all."
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
104 (interactive "p")
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
105 (save-excursion
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
106 (let ((contype nil)
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
107 (encoding nil)
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
108 (end (progn
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
109 (goto-char (point-min))
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
110 (search-forward "\n\n" nil t)
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
111 (point))))
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
112 ;; Find Content-Type and Content-Transfer-Encoding from the header.
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
113 (save-restriction
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
114 (narrow-to-region (point-min) end)
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 33414
diff changeset
115 (setq contype
15051
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
116 (or (mail-fetch-field "Content-Type") "text/plain"))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 33414
diff changeset
117 (setq encoding
15051
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
118 (or (mail-fetch-field "Content-Transfer-Encoding") "7bit")))
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
119 ;; Interpret the body part only.
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
120 (let ((metamail-switches ;Process body part only.
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
121 (append metamail-switches
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
122 (list "-b" "-c" contype "-E" encoding))))
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
123 (metamail-region end (point-max) viewmode nil nodisplay))
101842
3459df385d69 (metamail-interpret-body): Remove Rmail-specific hack that is no
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
124 ;; This mode specific hack is no longer appropriate in mbox Rmail.
3459df385d69 (metamail-interpret-body): Remove Rmail-specific hack that is no
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
125 ;; Pre-mbox, we have just modified the actual folder, so we
3459df385d69 (metamail-interpret-body): Remove Rmail-specific hack that is no
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
126 ;; update the message-vector with the new end position of the
3459df385d69 (metamail-interpret-body): Remove Rmail-specific hack that is no
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
127 ;; current message. In mbox Rmail, all we have done is modify a
3459df385d69 (metamail-interpret-body): Remove Rmail-specific hack that is no
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
128 ;; display copy of the message. Note also that point-max is a
3459df385d69 (metamail-interpret-body): Remove Rmail-specific hack that is no
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
129 ;; marker in the wrong buffer: the message-vector contains
3459df385d69 (metamail-interpret-body): Remove Rmail-specific hack that is no
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
130 ;; markers in rmail-view-buffer (which is not in rmail-mode).
3459df385d69 (metamail-interpret-body): Remove Rmail-specific hack that is no
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
131 ;; So this hack actually breaks the message-vector.
3459df385d69 (metamail-interpret-body): Remove Rmail-specific hack that is no
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
132 ;; If you're calling this on the actual rmail-view-buffer (or a
3459df385d69 (metamail-interpret-body): Remove Rmail-specific hack that is no
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
133 ;; non-swapped rmail-buffer), you would still need this hack.
3459df385d69 (metamail-interpret-body): Remove Rmail-specific hack that is no
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
134 ;; But you're not going to do that.
3459df385d69 (metamail-interpret-body): Remove Rmail-specific hack that is no
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
135 ;;; (cond ((eq major-mode 'rmail-mode)
3459df385d69 (metamail-interpret-body): Remove Rmail-specific hack that is no
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
136 ;;; ;; Adjust the marker of this message if in Rmail mode buffer.
3459df385d69 (metamail-interpret-body): Remove Rmail-specific hack that is no
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
137 ;;; (set-marker (aref rmail-message-vector (1+ rmail-current-message))
3459df385d69 (metamail-interpret-body): Remove Rmail-specific hack that is no
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
138 ;;; (point-max))))
15051
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
139 )))
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
140
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
141 ;;;###autoload
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
142 (defun metamail-buffer (&optional viewmode buffer nodisplay)
4171
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143 "Process current buffer through `metamail'.
15051
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
144 Optional argument VIEWMODE specifies the value of the
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
145 EMACS_VIEW_MODE environment variable (defaulted to 1).
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
146 Optional argument BUFFER specifies a buffer to be filled (nil
4171
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147 means current).
15051
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
148 Optional argument NODISPLAY non-nil means buffer is not
4171
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 redisplayed as output is inserted."
15051
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
150 (interactive "p")
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
151 (metamail-region (point-min) (point-max) viewmode buffer nodisplay))
4171
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
152
15051
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
153 ;;;###autoload
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
154 (defun metamail-region (beg end &optional viewmode buffer nodisplay)
4171
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155 "Process current region through 'metamail'.
15051
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
156 Optional argument VIEWMODE specifies the value of the
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
157 EMACS_VIEW_MODE environment variable (defaulted to 1).
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
158 Optional argument BUFFER specifies a buffer to be filled (nil
4171
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159 means current).
15051
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
160 Optional argument NODISPLAY non-nil means buffer is not
4171
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
161 redisplayed as output is inserted."
15051
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
162 (interactive "r\np")
4171
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
163 (let ((curbuf (current-buffer))
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164 (buffer-read-only nil)
26039
fb6b9c37cdc4 Use make-temp-file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 25419
diff changeset
165 (metafile (make-temp-file "metamail"))
15051
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
166 (option-environment
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 33414
diff changeset
167 (list (format "EMACS_VIEW_MODE=%d"
15051
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
168 (if (numberp viewmode) viewmode 1)))))
4171
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
169 (save-excursion
15051
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
170 ;; Gee! Metamail does not ouput to stdout if input comes from
4171
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
171 ;; stdin.
18964
10af35406220 (metamail-region): Don't bind kanji-fileio-code
Richard M. Stallman <rms@gnu.org>
parents: 17663
diff changeset
172 (let ((selective-display nil)) ;Disable ^M to nl translation.
15051
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
173 (write-region beg end metafile nil 'nomessage))
4171
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
174 (if buffer
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175 (set-buffer buffer))
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176 (setq buffer-read-only nil)
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177 ;; Clear destination buffer.
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178 (if (eq curbuf (current-buffer))
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179 (delete-region beg end)
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
180 (delete-region (point-min) (point-max)))
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181 ;; We have to pass the environment variable KEYHEADS to display
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182 ;; all header fields. Metamail should have an optional argument
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183 ;; to pass such information directly.
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184 (let ((process-environment
15051
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
185 (append process-environment
18964
10af35406220 (metamail-region): Don't bind kanji-fileio-code
Richard M. Stallman <rms@gnu.org>
parents: 17663
diff changeset
186 metamail-environment option-environment))
10af35406220 (metamail-region): Don't bind kanji-fileio-code
Richard M. Stallman <rms@gnu.org>
parents: 17663
diff changeset
187 (coding-system-for-read 'undecided))
4171
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188 (apply (function call-process)
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189 metamail-program-name
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190 nil
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
191 t ;Output to current buffer
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192 (not nodisplay) ;Force redisplay
15051
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
193 (append metamail-switches
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
194 (list "-m" (or metamail-mailer-name "emacs"))
4dbe0f673671 (metamail-mailer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14994
diff changeset
195 (list metafile))))
4171
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
196 ;; `metamail' may not delete the temporary file!
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
197 (condition-case error
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198 (delete-file metafile)
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199 (error nil))
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200 )))
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
201
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
202 (provide 'metamail)
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
203
93975
1e3a407766b9 Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 79712
diff changeset
204 ;; arch-tag: 52c0cb6f-d800-4776-9789-f0275cb5490e
4171
341cd3b063ae entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
205 ;;; metamail.el ends here