Mercurial > emacs
annotate lisp/gnus/mml.el @ 82980:08aac74a5b90
Remove Gnus image files now in lisp/gnus
author | Miles Bader <miles@gnu.org> |
---|---|
date | Sat, 04 Sep 2004 11:40:51 +0000 |
parents | 0fde48feb604 |
children | 497f0d2ca551 cce1c0ee76ee |
rev | line source |
---|---|
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1 ;;; mml.el --- A package for parsing and validating MML documents |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
2 ;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
3 ;; Free Software Foundation, Inc. |
31717 | 4 |
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org> | |
6 ;; This file is part of GNU Emacs. | |
7 | |
8 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
9 ;; it under the terms of the GNU General Public License as published by | |
10 ;; the Free Software Foundation; either version 2, or (at your option) | |
11 ;; any later version. | |
12 | |
13 ;; GNU Emacs is distributed in the hope that it will be useful, | |
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 ;; GNU General Public License for more details. | |
17 | |
18 ;; You should have received a copy of the GNU General Public License | |
19 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
20 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
21 ;; Boston, MA 02111-1307, USA. | |
22 | |
23 ;;; Commentary: | |
24 | |
25 ;;; Code: | |
26 | |
27 (require 'mm-util) | |
28 (require 'mm-bodies) | |
29 (require 'mm-encode) | |
30 (require 'mm-decode) | |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
31 (require 'mml-sec) |
33123
18591e92c712
*** empty log message ***
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31764
diff
changeset
|
32 (eval-when-compile (require 'cl)) |
31717 | 33 |
34 (eval-and-compile | |
35 (autoload 'message-make-message-id "message") | |
36 (autoload 'gnus-setup-posting-charset "gnus-msg") | |
34797
b473bc6d9a55
* mml.el (gnus-add-minor-mode): Autoload.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
34752
diff
changeset
|
37 (autoload 'gnus-add-minor-mode "gnus-ems") |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
38 (autoload 'gnus-make-local-hook "gnus-util") |
31717 | 39 (autoload 'message-fetch-field "message") |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
40 (autoload 'fill-flowed-encode "flow-fill") |
31717 | 41 (autoload 'message-posting-charset "message")) |
42 | |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
43 (defcustom mml-content-type-parameters |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
44 '(name access-type expiration size permission format) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
45 "*A list of acceptable parameters in MML tag. |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
46 These parameters are generated in Content-Type header if exists." |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
47 :type '(repeat (symbol :tag "Parameter")) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
48 :group 'message) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
49 |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
50 (defcustom mml-content-disposition-parameters |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
51 '(filename creation-date modification-date read-date) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
52 "*A list of acceptable parameters in MML tag. |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
53 These parameters are generated in Content-Disposition header if exists." |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
54 :type '(repeat (symbol :tag "Parameter")) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
55 :group 'message) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
56 |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
57 (defcustom mml-insert-mime-headers-always nil |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
58 "If non-nil, always put Content-Type: text/plain at top of empty parts. |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
59 It is necessary to work against a bug in certain clients." |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
60 :type 'boolean |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
61 :group 'message) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
62 |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
63 (defvar mml-tweak-type-alist nil |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
64 "A list of (TYPE . FUNCTION) for tweaking MML parts. |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
65 TYPE is a string containing a regexp to match the MIME type. FUNCTION |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
66 is a Lisp function which is called with the MML handle to tweak the |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
67 part. This variable is used only when no TWEAK parameter exists in |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
68 the MML handle.") |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
69 |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
70 (defvar mml-tweak-function-alist nil |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
71 "A list of (NAME . FUNCTION) for tweaking MML parts. |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
72 NAME is a string containing the name of the TWEAK parameter in the MML |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
73 handle. FUNCTION is a Lisp function which is called with the MML |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
74 handle to tweak the part.") |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
75 |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
76 (defvar mml-tweak-sexp-alist |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
77 '((mml-externalize-attachments . mml-tweak-externalize-attachments)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
78 "A list of (SEXP . FUNCTION) for tweaking MML parts. |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
79 SEXP is an s-expression. If the evaluation of SEXP is non-nil, FUNCTION |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
80 is called. FUNCTION is a Lisp function which is called with the MML |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
81 handle to tweak the part.") |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
82 |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
83 (defvar mml-externalize-attachments nil |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
84 "*If non-nil, local-file attachments are generated as external parts.") |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
85 |
31717 | 86 (defvar mml-generate-multipart-alist nil |
87 "*Alist of multipart generation functions. | |
88 Each entry has the form (NAME . FUNCTION), where | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
43166
diff
changeset
|
89 NAME is a string containing the name of the part (without the |
31717 | 90 leading \"/multipart/\"), |
91 FUNCTION is a Lisp function which is called to generate the part. | |
92 | |
93 The Lisp function has to supply the appropriate MIME headers and the | |
94 contents of this part.") | |
95 | |
96 (defvar mml-syntax-table | |
97 (let ((table (copy-syntax-table emacs-lisp-mode-syntax-table))) | |
98 (modify-syntax-entry ?\\ "/" table) | |
99 (modify-syntax-entry ?< "(" table) | |
100 (modify-syntax-entry ?> ")" table) | |
101 (modify-syntax-entry ?@ "w" table) | |
102 (modify-syntax-entry ?/ "w" table) | |
103 (modify-syntax-entry ?= " " table) | |
104 (modify-syntax-entry ?* " " table) | |
105 (modify-syntax-entry ?\; " " table) | |
106 (modify-syntax-entry ?\' " " table) | |
107 table)) | |
108 | |
109 (defvar mml-boundary-function 'mml-make-boundary | |
110 "A function called to suggest a boundary. | |
111 The function may be called several times, and should try to make a new | |
112 suggestion each time. The function is called with one parameter, | |
113 which is a number that says how many times the function has been | |
114 called for this message.") | |
115 | |
116 (defvar mml-confirmation-set nil | |
117 "A list of symbols, each of which disables some warning. | |
118 `unknown-encoding': always send messages contain characters with | |
119 unknown encoding; `use-ascii': always use ASCII for those characters | |
120 with unknown encoding; `multipart': always send messages with more than | |
121 one charsets.") | |
122 | |
123 (defvar mml-generate-default-type "text/plain") | |
124 | |
125 (defvar mml-buffer-list nil) | |
126 | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
43166
diff
changeset
|
127 (defun mml-generate-new-buffer (name) |
31717 | 128 (let ((buf (generate-new-buffer name))) |
129 (push buf mml-buffer-list) | |
130 buf)) | |
131 | |
132 (defun mml-destroy-buffers () | |
133 (let (kill-buffer-hook) | |
134 (mapcar 'kill-buffer mml-buffer-list) | |
135 (setq mml-buffer-list nil))) | |
136 | |
137 (defun mml-parse () | |
138 "Parse the current buffer as an MML document." | |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
139 (save-excursion |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
140 (goto-char (point-min)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
141 (let ((table (syntax-table))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
142 (unwind-protect |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
143 (progn |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
144 (set-syntax-table mml-syntax-table) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
145 (mml-parse-1)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
146 (set-syntax-table table))))) |
31717 | 147 |
148 (defun mml-parse-1 () | |
149 "Parse the current buffer as an MML document." | |
150 (let (struct tag point contents charsets warn use-ascii no-markup-p raw) | |
151 (while (and (not (eobp)) | |
152 (not (looking-at "<#/multipart"))) | |
153 (cond | |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
154 ((looking-at "<#secure") |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
155 ;; The secure part is essentially a meta-meta tag, which |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
156 ;; expands to either a part tag if there are no other parts in |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
157 ;; the document or a multipart tag if there are other parts |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
158 ;; included in the message |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
159 (let* (secure-mode |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
160 (taginfo (mml-read-tag)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
161 (recipients (cdr (assq 'recipients taginfo))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
162 (sender (cdr (assq 'sender taginfo))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
163 (location (cdr (assq 'tag-location taginfo))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
164 (mode (cdr (assq 'mode taginfo))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
165 (method (cdr (assq 'method taginfo))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
166 tags) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
167 (save-excursion |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
168 (if |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
169 (re-search-forward |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
170 "<#\\(/\\)?\\(multipart\\|part\\|external\\|mml\\)." nil t) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
171 (setq secure-mode "multipart") |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
172 (setq secure-mode "part"))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
173 (save-excursion |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
174 (goto-char location) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
175 (re-search-forward "<#secure[^\n]*>\n")) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
176 (delete-region (match-beginning 0) (match-end 0)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
177 (cond ((string= mode "sign") |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
178 (setq tags (list "sign" method))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
179 ((string= mode "encrypt") |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
180 (setq tags (list "encrypt" method))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
181 ((string= mode "signencrypt") |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
182 (setq tags (list "sign" method "encrypt" method)))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
183 (eval `(mml-insert-tag ,secure-mode |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
184 ,@tags |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
185 ,(if recipients "recipients") |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
186 ,recipients |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
187 ,(if sender "sender") |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
188 ,sender)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
189 ;; restart the parse |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
190 (goto-char location))) |
31717 | 191 ((looking-at "<#multipart") |
192 (push (nconc (mml-read-tag) (mml-parse-1)) struct)) | |
193 ((looking-at "<#external") | |
194 (push (nconc (mml-read-tag) (list (cons 'contents (mml-read-part)))) | |
195 struct)) | |
196 (t | |
197 (if (or (looking-at "<#part") (looking-at "<#mml")) | |
198 (setq tag (mml-read-tag) | |
199 no-markup-p nil | |
200 warn nil) | |
201 (setq tag (list 'part '(type . "text/plain")) | |
202 no-markup-p t | |
203 warn t)) | |
204 (setq raw (cdr (assq 'raw tag)) | |
205 point (point) | |
31764 | 206 contents (mml-read-part (eq 'mml (car tag))) |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
207 charsets (cond |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
208 (raw nil) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
209 ((assq 'charset tag) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
210 (list |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
211 (intern (downcase (cdr (assq 'charset tag)))))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
212 (t |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
213 (mm-find-mime-charset-region point (point) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
214 mm-hack-charsets)))) |
31717 | 215 (when (and (not raw) (memq nil charsets)) |
216 (if (or (memq 'unknown-encoding mml-confirmation-set) | |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
217 (message-options-get 'unknown-encoding) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
218 (and (y-or-n-p "\ |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
219 Message contains characters with unknown encoding. Really send? ") |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
220 (message-options-set 'unknown-encoding t))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
43166
diff
changeset
|
221 (if (setq use-ascii |
31717 | 222 (or (memq 'use-ascii mml-confirmation-set) |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
223 (message-options-get 'use-ascii) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
224 (and (y-or-n-p "Use ASCII as charset? ") |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
225 (message-options-set 'use-ascii t)))) |
31717 | 226 (setq charsets (delq nil charsets)) |
227 (setq warn nil)) | |
228 (error "Edit your message to remove those characters"))) | |
229 (if (or raw | |
230 (eq 'mml (car tag)) | |
231 (< (length charsets) 2)) | |
232 (if (or (not no-markup-p) | |
233 (string-match "[^ \t\r\n]" contents)) | |
234 ;; Don't create blank parts. | |
235 (push (nconc tag (list (cons 'contents contents))) | |
236 struct)) | |
237 (let ((nstruct (mml-parse-singlepart-with-multiple-charsets | |
238 tag point (point) use-ascii))) | |
239 (when (and warn | |
240 (not (memq 'multipart mml-confirmation-set)) | |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
241 (not (message-options-get 'multipart)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
242 (not (and (y-or-n-p (format "\ |
35142
40698b92a36a
(mml-parse-1): Frob mml-confirmation-set when proceeding
Dave Love <fx@gnu.org>
parents:
34797
diff
changeset
|
243 A message part needs to be split into %d charset parts. Really send? " |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
244 (length nstruct))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
245 (message-options-set 'multipart t)))) |
31717 | 246 (error "Edit your message to use only one charset")) |
247 (setq struct (nconc nstruct struct))))))) | |
248 (unless (eobp) | |
249 (forward-line 1)) | |
250 (nreverse struct))) | |
251 | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
43166
diff
changeset
|
252 (defun mml-parse-singlepart-with-multiple-charsets |
31717 | 253 (orig-tag beg end &optional use-ascii) |
254 (save-excursion | |
255 (save-restriction | |
256 (narrow-to-region beg end) | |
257 (goto-char (point-min)) | |
258 (let ((current (or (mm-mime-charset (mm-charset-after)) | |
259 (and use-ascii 'us-ascii))) | |
260 charset struct space newline paragraph) | |
261 (while (not (eobp)) | |
262 (setq charset (mm-mime-charset (mm-charset-after))) | |
263 (cond | |
264 ;; The charset remains the same. | |
265 ((eq charset 'us-ascii)) | |
266 ((or (and use-ascii (not charset)) | |
267 (eq charset current)) | |
268 (setq space nil | |
269 newline nil | |
270 paragraph nil)) | |
271 ;; The initial charset was ascii. | |
272 ((eq current 'us-ascii) | |
273 (setq current charset | |
274 space nil | |
275 newline nil | |
276 paragraph nil)) | |
277 ;; We have a change in charsets. | |
278 (t | |
279 (push (append | |
280 orig-tag | |
281 (list (cons 'contents | |
282 (buffer-substring-no-properties | |
283 beg (or paragraph newline space (point)))))) | |
284 struct) | |
285 (setq beg (or paragraph newline space (point)) | |
286 current charset | |
287 space nil | |
288 newline nil | |
289 paragraph nil))) | |
290 ;; Compute places where it might be nice to break the part. | |
291 (cond | |
292 ((memq (following-char) '(? ?\t)) | |
293 (setq space (1+ (point)))) | |
294 ((and (eq (following-char) ?\n) | |
295 (not (bobp)) | |
296 (eq (char-after (1- (point))) ?\n)) | |
297 (setq paragraph (point))) | |
298 ((eq (following-char) ?\n) | |
299 (setq newline (1+ (point))))) | |
300 (forward-char 1)) | |
301 ;; Do the final part. | |
302 (unless (= beg (point)) | |
303 (push (append orig-tag | |
304 (list (cons 'contents | |
305 (buffer-substring-no-properties | |
306 beg (point))))) | |
307 struct)) | |
308 struct)))) | |
309 | |
310 (defun mml-read-tag () | |
311 "Read a tag and return the contents." | |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
312 (let ((orig-point (point)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
313 contents name elem val) |
31717 | 314 (forward-char 2) |
315 (setq name (buffer-substring-no-properties | |
316 (point) (progn (forward-sexp 1) (point)))) | |
317 (skip-chars-forward " \t\n") | |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
318 (while (not (looking-at ">[ \t]*\n?")) |
31717 | 319 (setq elem (buffer-substring-no-properties |
320 (point) (progn (forward-sexp 1) (point)))) | |
321 (skip-chars-forward "= \t\n") | |
322 (setq val (buffer-substring-no-properties | |
323 (point) (progn (forward-sexp 1) (point)))) | |
324 (when (string-match "^\"\\(.*\\)\"$" val) | |
325 (setq val (match-string 1 val))) | |
326 (push (cons (intern elem) val) contents) | |
327 (skip-chars-forward " \t\n")) | |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
328 (goto-char (match-end 0)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
329 ;; Don't skip the leading space. |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
330 ;;(skip-chars-forward " \t\n") |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
331 ;; Put the tag location into the returned contents |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
332 (setq contents (append (list (cons 'tag-location orig-point)) contents)) |
31717 | 333 (cons (intern name) (nreverse contents)))) |
334 | |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
335 (defun mml-buffer-substring-no-properties-except-hard-newlines (start end) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
336 (let ((str (buffer-substring-no-properties start end)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
337 (bufstart start) tmp) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
338 (while (setq tmp (text-property-any start end 'hard 't)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
339 (set-text-properties (- tmp bufstart) (- tmp bufstart -1) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
340 '(hard t) str) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
341 (setq start (1+ tmp))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
342 str)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
343 |
31717 | 344 (defun mml-read-part (&optional mml) |
345 "Return the buffer up till the next part, multipart or closing part or multipart. | |
346 If MML is non-nil, return the buffer up till the correspondent mml tag." | |
347 (let ((beg (point)) (count 1)) | |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
348 ;; If the tag ended at the end of the line, we go to the next line. |
31717 | 349 (when (looking-at "[ \t]*\n") |
350 (forward-line 1)) | |
351 (if mml | |
352 (progn | |
353 (while (and (> count 0) (not (eobp))) | |
354 (if (re-search-forward "<#\\(/\\)?mml." nil t) | |
355 (setq count (+ count (if (match-beginning 1) -1 1))) | |
356 (goto-char (point-max)))) | |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
357 (mml-buffer-substring-no-properties-except-hard-newlines |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
358 beg (if (> count 0) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
359 (point) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
360 (match-beginning 0)))) |
31717 | 361 (if (re-search-forward |
362 "<#\\(/\\)?\\(multipart\\|part\\|external\\|mml\\)." nil t) | |
363 (prog1 | |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
364 (mml-buffer-substring-no-properties-except-hard-newlines |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
365 beg (match-beginning 0)) |
31717 | 366 (if (or (not (match-beginning 1)) |
367 (equal (match-string 2) "multipart")) | |
368 (goto-char (match-beginning 0)) | |
369 (when (looking-at "[ \t]*\n") | |
370 (forward-line 1)))) | |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
371 (mml-buffer-substring-no-properties-except-hard-newlines |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
372 beg (goto-char (point-max))))))) |
31717 | 373 |
374 (defvar mml-boundary nil) | |
375 (defvar mml-base-boundary "-=-=") | |
376 (defvar mml-multipart-number 0) | |
377 | |
378 (defun mml-generate-mime () | |
379 "Generate a MIME message based on the current MML document." | |
380 (let ((cont (mml-parse)) | |
381 (mml-multipart-number mml-multipart-number)) | |
382 (if (not cont) | |
383 nil | |
384 (with-temp-buffer | |
385 (if (and (consp (car cont)) | |
386 (= (length cont) 1)) | |
387 (mml-generate-mime-1 (car cont)) | |
388 (mml-generate-mime-1 (nconc (list 'multipart '(type . "mixed")) | |
389 cont))) | |
390 (buffer-string))))) | |
391 | |
392 (defun mml-generate-mime-1 (cont) | |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
393 (let ((mm-use-ultra-safe-encoding |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
394 (or mm-use-ultra-safe-encoding (assq 'sign cont)))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
395 (save-restriction |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
396 (narrow-to-region (point) (point)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
397 (mml-tweak-part cont) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
398 (cond |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
399 ((or (eq (car cont) 'part) (eq (car cont) 'mml)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
400 (let ((raw (cdr (assq 'raw cont))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
401 coded encoding charset filename type flowed) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
402 (setq type (or (cdr (assq 'type cont)) "text/plain")) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
403 (if (and (not raw) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
404 (member (car (split-string type "/")) '("text" "message"))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
405 (progn |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
406 (with-temp-buffer |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
407 (setq charset (mm-charset-to-coding-system |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
408 (cdr (assq 'charset cont)))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
409 (when (eq charset 'ascii) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
410 (setq charset nil)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
411 (cond |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
412 ((cdr (assq 'buffer cont)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
413 (insert-buffer-substring (cdr (assq 'buffer cont)))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
414 ((and (setq filename (cdr (assq 'filename cont))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
415 (not (equal (cdr (assq 'nofile cont)) "yes"))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
416 (let ((coding-system-for-read charset)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
417 (mm-insert-file-contents filename))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
418 ((eq 'mml (car cont)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
419 (insert (cdr (assq 'contents cont)))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
420 (t |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
421 (save-restriction |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
422 (narrow-to-region (point) (point)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
423 (insert (cdr (assq 'contents cont))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
424 ;; Remove quotes from quoted tags. |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
425 (goto-char (point-min)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
426 (while (re-search-forward |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
427 "<#!+/?\\(part\\|multipart\\|external\\|mml\\)" |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
428 nil t) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
429 (delete-region (+ (match-beginning 0) 2) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
430 (+ (match-beginning 0) 3)))))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
431 (cond |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
432 ((eq (car cont) 'mml) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
433 (let ((mml-boundary (mml-compute-boundary cont)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
434 (mml-generate-default-type "text/plain")) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
435 (mml-to-mime)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
436 (let ((mm-7bit-chars (concat mm-7bit-chars "\x1b"))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
437 ;; ignore 0x1b, it is part of iso-2022-jp |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
438 (setq encoding (mm-body-7-or-8)))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
439 ((string= (car (split-string type "/")) "message") |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
440 (let ((mm-7bit-chars (concat mm-7bit-chars "\x1b"))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
441 ;; ignore 0x1b, it is part of iso-2022-jp |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
442 (setq encoding (mm-body-7-or-8)))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
443 (t |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
444 ;; Only perform format=flowed filling on text/plain |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
445 ;; parts where there either isn't a format parameter |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
446 ;; in the mml tag or it says "flowed" and there |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
447 ;; actually are hard newlines in the text. |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
448 (let (use-hard-newlines) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
449 (when (and (string= type "text/plain") |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
450 (or (null (assq 'format cont)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
451 (string= (cdr (assq 'format cont)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
452 "flowed")) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
453 (setq use-hard-newlines |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
454 (text-property-any |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
455 (point-min) (point-max) 'hard 't))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
456 (fill-flowed-encode) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
457 ;; Indicate that `mml-insert-mime-headers' should |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
458 ;; insert a "; format=flowed" string unless the |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
459 ;; user has already specified it. |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
460 (setq flowed (null (assq 'format cont))))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
461 (setq charset (mm-encode-body charset)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
462 (setq encoding (mm-body-encoding |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
463 charset (cdr (assq 'encoding cont)))))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
464 (setq coded (buffer-string))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
465 (mml-insert-mime-headers cont type charset encoding flowed) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
466 (insert "\n") |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
467 (insert coded)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
468 (mm-with-unibyte-buffer |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
469 (cond |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
470 ((cdr (assq 'buffer cont)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
471 (insert-buffer-substring (cdr (assq 'buffer cont)))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
472 ((and (setq filename (cdr (assq 'filename cont))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
473 (not (equal (cdr (assq 'nofile cont)) "yes"))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
474 (let ((coding-system-for-read mm-binary-coding-system)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
475 (mm-insert-file-contents filename nil nil nil nil t))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
476 (t |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
477 (insert (cdr (assq 'contents cont))))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
478 (setq encoding (mm-encode-buffer type) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
479 coded (mm-string-as-multibyte (buffer-string)))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
480 (mml-insert-mime-headers cont type charset encoding nil) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
481 (insert "\n") |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
482 (mm-with-unibyte-current-buffer |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
483 (insert coded))))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
484 ((eq (car cont) 'external) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
485 (insert "Content-Type: message/external-body") |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
486 (let ((parameters (mml-parameter-string |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
487 cont '(expiration size permission))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
488 (name (cdr (assq 'name cont))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
489 (url (cdr (assq 'url cont)))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
490 (when name |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
491 (setq name (mml-parse-file-name name)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
492 (if (stringp name) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
493 (mml-insert-parameter |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
494 (mail-header-encode-parameter "name" name) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
495 "access-type=local-file") |
31717 | 496 (mml-insert-parameter |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
497 (mail-header-encode-parameter |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
498 "name" (file-name-nondirectory (nth 2 name))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
499 (mail-header-encode-parameter "site" (nth 1 name)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
500 (mail-header-encode-parameter |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
501 "directory" (file-name-directory (nth 2 name)))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
502 (mml-insert-parameter |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
503 (concat "access-type=" |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
504 (if (member (nth 0 name) '("ftp@" "anonymous@")) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
505 "anon-ftp" |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
506 "ftp"))))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
507 (when url |
31717 | 508 (mml-insert-parameter |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
509 (mail-header-encode-parameter "url" url) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
510 "access-type=url")) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
511 (when parameters |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
512 (mml-insert-parameter-string |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
513 cont '(expiration size permission)))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
514 (insert "\n\n") |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
515 (insert "Content-Type: " (cdr (assq 'type cont)) "\n") |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
516 (insert "Content-ID: " (message-make-message-id) "\n") |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
517 (insert "Content-Transfer-Encoding: " |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
518 (or (cdr (assq 'encoding cont)) "binary")) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
519 (insert "\n\n") |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
520 (insert (or (cdr (assq 'contents cont)))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
521 (insert "\n")) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
522 ((eq (car cont) 'multipart) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
523 (let* ((type (or (cdr (assq 'type cont)) "mixed")) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
524 (mml-generate-default-type (if (equal type "digest") |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
525 "message/rfc822" |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
526 "text/plain")) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
527 (handler (assoc type mml-generate-multipart-alist))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
528 (if handler |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
529 (funcall (cdr handler) cont) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
530 ;; No specific handler. Use default one. |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
531 (let ((mml-boundary (mml-compute-boundary cont))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
532 (insert (format "Content-Type: multipart/%s; boundary=\"%s\"" |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
533 type mml-boundary) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
534 (if (cdr (assq 'start cont)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
535 (format "; start=\"%s\"\n" (cdr (assq 'start cont))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
536 "\n")) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
537 (let ((cont cont) part) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
538 (while (setq part (pop cont)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
539 ;; Skip `multipart' and attributes. |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
540 (when (and (consp part) (consp (cdr part))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
541 (insert "\n--" mml-boundary "\n") |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
542 (mml-generate-mime-1 part)))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
543 (insert "\n--" mml-boundary "--\n"))))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
544 (t |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
545 (error "Invalid element: %S" cont))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
546 ;; handle sign & encrypt tags in a semi-smart way. |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
547 (let ((sign-item (assoc (cdr (assq 'sign cont)) mml-sign-alist)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
548 (encrypt-item (assoc (cdr (assq 'encrypt cont)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
549 mml-encrypt-alist)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
550 sender recipients) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
551 (when (or sign-item encrypt-item) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
552 (when (setq sender (cdr (assq 'sender cont))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
553 (message-options-set 'mml-sender sender) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
554 (message-options-set 'message-sender sender)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
555 (if (setq recipients (cdr (assq 'recipients cont))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
556 (message-options-set 'message-recipients recipients)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
557 (let ((style (mml-signencrypt-style (first (or sign-item encrypt-item))))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
558 ;; check if: we're both signing & encrypting, both methods |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
559 ;; are the same (why would they be different?!), and that |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
560 ;; the signencrypt style allows for combined operation. |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
561 (if (and sign-item encrypt-item (equal (first sign-item) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
562 (first encrypt-item)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
563 (equal style 'combined)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
564 (funcall (nth 1 encrypt-item) cont t) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
565 ;; otherwise, revert to the old behavior. |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
566 (when sign-item |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
567 (funcall (nth 1 sign-item) cont)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
568 (when encrypt-item |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
569 (funcall (nth 1 encrypt-item) cont))))))))) |
31717 | 570 |
571 (defun mml-compute-boundary (cont) | |
572 "Return a unique boundary that does not exist in CONT." | |
573 (let ((mml-boundary (funcall mml-boundary-function | |
574 (incf mml-multipart-number)))) | |
575 ;; This function tries again and again until it has found | |
576 ;; a unique boundary. | |
577 (while (not (catch 'not-unique | |
578 (mml-compute-boundary-1 cont)))) | |
579 mml-boundary)) | |
580 | |
581 (defun mml-compute-boundary-1 (cont) | |
582 (let (filename) | |
583 (cond | |
584 ((eq (car cont) 'part) | |
585 (with-temp-buffer | |
586 (cond | |
587 ((cdr (assq 'buffer cont)) | |
588 (insert-buffer-substring (cdr (assq 'buffer cont)))) | |
589 ((and (setq filename (cdr (assq 'filename cont))) | |
590 (not (equal (cdr (assq 'nofile cont)) "yes"))) | |
591 (mm-insert-file-contents filename)) | |
592 (t | |
593 (insert (cdr (assq 'contents cont))))) | |
594 (goto-char (point-min)) | |
595 (when (re-search-forward (concat "^--" (regexp-quote mml-boundary)) | |
596 nil t) | |
597 (setq mml-boundary (funcall mml-boundary-function | |
598 (incf mml-multipart-number))) | |
599 (throw 'not-unique nil)))) | |
600 ((eq (car cont) 'multipart) | |
601 (mapcar 'mml-compute-boundary-1 (cddr cont)))) | |
602 t)) | |
603 | |
604 (defun mml-make-boundary (number) | |
605 (concat (make-string (% number 60) ?=) | |
606 (if (> number 17) | |
607 (format "%x" number) | |
608 "") | |
609 mml-base-boundary)) | |
610 | |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
611 (defun mml-insert-mime-headers (cont type charset encoding flowed) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
612 (let (parameters id disposition description) |
31717 | 613 (setq parameters |
614 (mml-parameter-string | |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
615 cont mml-content-type-parameters)) |
31717 | 616 (when (or charset |
617 parameters | |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
618 flowed |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
619 (not (equal type mml-generate-default-type)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
620 mml-insert-mime-headers-always) |
31717 | 621 (when (consp charset) |
622 (error | |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
623 "Can't encode a part with several charsets")) |
31717 | 624 (insert "Content-Type: " type) |
625 (when charset | |
626 (insert "; " (mail-header-encode-parameter | |
627 "charset" (symbol-name charset)))) | |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
628 (when flowed |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
629 (insert "; format=flowed")) |
31717 | 630 (when parameters |
631 (mml-insert-parameter-string | |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
632 cont mml-content-type-parameters)) |
31717 | 633 (insert "\n")) |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
634 (when (setq id (cdr (assq 'id cont))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
635 (insert "Content-ID: " id "\n")) |
31717 | 636 (setq parameters |
637 (mml-parameter-string | |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
638 cont mml-content-disposition-parameters)) |
31717 | 639 (when (or (setq disposition (cdr (assq 'disposition cont))) |
640 parameters) | |
641 (insert "Content-Disposition: " (or disposition "inline")) | |
642 (when parameters | |
643 (mml-insert-parameter-string | |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
644 cont mml-content-disposition-parameters)) |
31717 | 645 (insert "\n")) |
646 (unless (eq encoding '7bit) | |
647 (insert (format "Content-Transfer-Encoding: %s\n" encoding))) | |
648 (when (setq description (cdr (assq 'description cont))) | |
649 (insert "Content-Description: " | |
650 (mail-encode-encoded-word-string description) "\n")))) | |
651 | |
652 (defun mml-parameter-string (cont types) | |
653 (let ((string "") | |
654 value type) | |
655 (while (setq type (pop types)) | |
656 (when (setq value (cdr (assq type cont))) | |
657 ;; Strip directory component from the filename parameter. | |
658 (when (eq type 'filename) | |
659 (setq value (file-name-nondirectory value))) | |
660 (setq string (concat string "; " | |
661 (mail-header-encode-parameter | |
662 (symbol-name type) value))))) | |
663 (when (not (zerop (length string))) | |
664 string))) | |
665 | |
666 (defun mml-insert-parameter-string (cont types) | |
667 (let (value type) | |
668 (while (setq type (pop types)) | |
669 (when (setq value (cdr (assq type cont))) | |
670 ;; Strip directory component from the filename parameter. | |
671 (when (eq type 'filename) | |
672 (setq value (file-name-nondirectory value))) | |
673 (mml-insert-parameter | |
674 (mail-header-encode-parameter | |
675 (symbol-name type) value)))))) | |
676 | |
33301
c1c373a70748
Put some defvars in eval-when-compile.
Dave Love <fx@gnu.org>
parents:
33124
diff
changeset
|
677 (eval-when-compile |
c1c373a70748
Put some defvars in eval-when-compile.
Dave Love <fx@gnu.org>
parents:
33124
diff
changeset
|
678 (defvar ange-ftp-name-format) |
c1c373a70748
Put some defvars in eval-when-compile.
Dave Love <fx@gnu.org>
parents:
33124
diff
changeset
|
679 (defvar efs-path-regexp)) |
31717 | 680 (defun mml-parse-file-name (path) |
681 (if (if (boundp 'efs-path-regexp) | |
682 (string-match efs-path-regexp path) | |
683 (if (boundp 'ange-ftp-name-format) | |
684 (string-match (car ange-ftp-name-format) path))) | |
685 (list (match-string 1 path) (match-string 2 path) | |
686 (substring path (1+ (match-end 2)))) | |
687 path)) | |
688 | |
689 (defun mml-insert-buffer (buffer) | |
690 "Insert BUFFER at point and quote any MML markup." | |
691 (save-restriction | |
692 (narrow-to-region (point) (point)) | |
693 (insert-buffer-substring buffer) | |
694 (mml-quote-region (point-min) (point-max)) | |
695 (goto-char (point-max)))) | |
696 | |
697 ;;; | |
698 ;;; Transforming MIME to MML | |
699 ;;; | |
700 | |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
701 (defun mime-to-mml (&optional handles) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
702 "Translate the current buffer (which should be a message) into MML. |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
703 If HANDLES is non-nil, use it instead reparsing the buffer." |
31717 | 704 ;; First decode the head. |
705 (save-restriction | |
706 (message-narrow-to-head) | |
707 (mail-decode-encoded-word-region (point-min) (point-max))) | |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
708 (unless handles |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
709 (setq handles (mm-dissect-buffer t))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
710 (goto-char (point-min)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
711 (search-forward "\n\n" nil t) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
712 (delete-region (point) (point-max)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
713 (if (stringp (car handles)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
714 (mml-insert-mime handles) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
715 (mml-insert-mime handles t)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
716 (mm-destroy-parts handles) |
31717 | 717 (save-restriction |
718 (message-narrow-to-head) | |
719 ;; Remove them, they are confusing. | |
720 (message-remove-header "Content-Type") | |
721 (message-remove-header "MIME-Version") | |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
722 (message-remove-header "Content-Disposition") |
31717 | 723 (message-remove-header "Content-Transfer-Encoding"))) |
724 | |
725 (defun mml-to-mime () | |
726 "Translate the current buffer from MML to MIME." | |
727 (message-encode-message-body) | |
728 (save-restriction | |
729 (message-narrow-to-headers-or-head) | |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
730 ;; Skip past any From_ headers. |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
731 (while (looking-at "From ") |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
732 (forward-line 1)) |
31717 | 733 (let ((mail-parse-charset message-default-charset)) |
734 (mail-encode-encoded-word-buffer)))) | |
735 | |
736 (defun mml-insert-mime (handle &optional no-markup) | |
737 (let (textp buffer mmlp) | |
738 ;; Determine type and stuff. | |
739 (unless (stringp (car handle)) | |
740 (unless (setq textp (equal (mm-handle-media-supertype handle) "text")) | |
741 (save-excursion | |
742 (set-buffer (setq buffer (mml-generate-new-buffer " *mml*"))) | |
743 (mm-insert-part handle) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
43166
diff
changeset
|
744 (if (setq mmlp (equal (mm-handle-media-type handle) |
31717 | 745 "message/rfc822")) |
746 (mime-to-mml))))) | |
747 (if mmlp | |
748 (mml-insert-mml-markup handle nil t t) | |
749 (unless (and no-markup | |
750 (equal (mm-handle-media-type handle) "text/plain")) | |
751 (mml-insert-mml-markup handle buffer textp))) | |
752 (cond | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
43166
diff
changeset
|
753 (mmlp |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
754 (insert-buffer-substring buffer) |
31717 | 755 (goto-char (point-max)) |
756 (insert "<#/mml>\n")) | |
757 ((stringp (car handle)) | |
758 (mapcar 'mml-insert-mime (cdr handle)) | |
759 (insert "<#/multipart>\n")) | |
760 (textp | |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
761 (let ((charset (mail-content-type-get |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
762 (mm-handle-type handle) 'charset)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
763 (start (point))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
764 (if (eq charset 'gnus-decoded) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
765 (mm-insert-part handle) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
766 (insert (mm-decode-string (mm-get-part handle) charset))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
767 (mml-quote-region start (point))) |
31717 | 768 (goto-char (point-max))) |
769 (t | |
770 (insert "<#/part>\n"))))) | |
771 | |
772 (defun mml-insert-mml-markup (handle &optional buffer nofile mmlp) | |
773 "Take a MIME handle and insert an MML tag." | |
774 (if (stringp (car handle)) | |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
775 (progn |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
776 (insert "<#multipart type=" (mm-handle-media-subtype handle)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
777 (let ((start (mm-handle-multipart-ctl-parameter handle 'start))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
778 (when start |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
779 (insert " start=\"" start "\""))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
780 (insert ">\n")) |
31717 | 781 (if mmlp |
782 (insert "<#mml type=" (mm-handle-media-type handle)) | |
783 (insert "<#part type=" (mm-handle-media-type handle))) | |
784 (dolist (elem (append (cdr (mm-handle-type handle)) | |
785 (cdr (mm-handle-disposition handle)))) | |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
786 (unless (symbolp (cdr elem)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
787 (insert " " (symbol-name (car elem)) "=\"" (cdr elem) "\""))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
788 (when (mm-handle-id handle) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
789 (insert " id=\"" (mm-handle-id handle) "\"")) |
31717 | 790 (when (mm-handle-disposition handle) |
791 (insert " disposition=" (car (mm-handle-disposition handle)))) | |
792 (when buffer | |
793 (insert " buffer=\"" (buffer-name buffer) "\"")) | |
794 (when nofile | |
795 (insert " nofile=yes")) | |
796 (when (mm-handle-description handle) | |
797 (insert " description=\"" (mm-handle-description handle) "\"")) | |
798 (insert ">\n"))) | |
799 | |
800 (defun mml-insert-parameter (&rest parameters) | |
801 "Insert PARAMETERS in a nice way." | |
802 (dolist (param parameters) | |
803 (insert ";") | |
804 (let ((point (point))) | |
805 (insert " " param) | |
806 (when (> (current-column) 71) | |
807 (goto-char point) | |
808 (insert "\n ") | |
809 (end-of-line))))) | |
810 | |
811 ;;; | |
812 ;;; Mode for inserting and editing MML forms | |
813 ;;; | |
814 | |
815 (defvar mml-mode-map | |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
816 (let ((sign (make-sparse-keymap)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
817 (encrypt (make-sparse-keymap)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
818 (signpart (make-sparse-keymap)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
819 (encryptpart (make-sparse-keymap)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
820 (map (make-sparse-keymap)) |
31717 | 821 (main (make-sparse-keymap))) |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
822 (define-key sign "p" 'mml-secure-message-sign-pgpmime) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
823 (define-key sign "o" 'mml-secure-message-sign-pgp) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
824 (define-key sign "s" 'mml-secure-message-sign-smime) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
825 (define-key signpart "p" 'mml-secure-sign-pgpmime) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
826 (define-key signpart "o" 'mml-secure-sign-pgp) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
827 (define-key signpart "s" 'mml-secure-sign-smime) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
828 (define-key encrypt "p" 'mml-secure-message-encrypt-pgpmime) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
829 (define-key encrypt "o" 'mml-secure-message-encrypt-pgp) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
830 (define-key encrypt "s" 'mml-secure-message-encrypt-smime) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
831 (define-key encryptpart "p" 'mml-secure-encrypt-pgpmime) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
832 (define-key encryptpart "o" 'mml-secure-encrypt-pgp) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
833 (define-key encryptpart "s" 'mml-secure-encrypt-smime) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
834 (define-key map "\C-n" 'mml-unsecure-message) |
31717 | 835 (define-key map "f" 'mml-attach-file) |
836 (define-key map "b" 'mml-attach-buffer) | |
837 (define-key map "e" 'mml-attach-external) | |
838 (define-key map "q" 'mml-quote-region) | |
839 (define-key map "m" 'mml-insert-multipart) | |
840 (define-key map "p" 'mml-insert-part) | |
841 (define-key map "v" 'mml-validate) | |
842 (define-key map "P" 'mml-preview) | |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
843 (define-key map "s" sign) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
844 (define-key map "S" signpart) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
845 (define-key map "c" encrypt) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
846 (define-key map "C" encryptpart) |
31717 | 847 ;;(define-key map "n" 'mml-narrow-to-part) |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
848 ;; `M-m' conflicts with `back-to-indentation'. |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
849 ;; (define-key main "\M-m" map) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
850 (define-key main "\C-c\C-m" map) |
31717 | 851 main)) |
852 | |
853 (easy-menu-define | |
40758 | 854 mml-menu mml-mode-map "" |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
855 `("Attachments" |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
856 ["Attach File..." mml-attach-file |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
857 ,@(if (featurep 'xemacs) '(t) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
858 '(:help "Attach a file at point"))] |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
859 ["Attach Buffer..." mml-attach-buffer t] |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
860 ["Attach External..." mml-attach-external t] |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
861 ["Insert Part..." mml-insert-part t] |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
862 ["Insert Multipart..." mml-insert-multipart t] |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
863 ["PGP/MIME Sign" mml-secure-message-sign-pgpmime t] |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
864 ["PGP/MIME Encrypt" mml-secure-message-encrypt-pgpmime t] |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
865 ["PGP Sign" mml-secure-message-sign-pgp t] |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
866 ["PGP Encrypt" mml-secure-message-encrypt-pgp t] |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
867 ["S/MIME Sign" mml-secure-message-sign-smime t] |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
868 ["S/MIME Encrypt" mml-secure-message-encrypt-smime t] |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
869 ("Secure MIME part" |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
870 ["PGP/MIME Sign Part" mml-secure-sign-pgpmime t] |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
871 ["PGP/MIME Encrypt Part" mml-secure-encrypt-pgpmime t] |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
872 ["PGP Sign Part" mml-secure-sign-pgp t] |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
873 ["PGP Encrypt Part" mml-secure-encrypt-pgp t] |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
874 ["S/MIME Sign Part" mml-secure-sign-smime t] |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
875 ["S/MIME Encrypt Part" mml-secure-encrypt-smime t]) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
876 ["Encrypt/Sign off" mml-unsecure-message t] |
40758 | 877 ;;["Narrow" mml-narrow-to-part t] |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
878 ["Quote MML" mml-quote-region t] |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
879 ["Validate MML" mml-validate t] |
40758 | 880 ["Preview" mml-preview t])) |
31717 | 881 |
882 (defvar mml-mode nil | |
883 "Minor mode for editing MML.") | |
884 | |
885 (defun mml-mode (&optional arg) | |
886 "Minor mode for editing MML. | |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
887 MML is the MIME Meta Language, a minor mode for composing MIME articles. |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
888 See Info node `(emacs-mime)Composing'. |
31717 | 889 |
890 \\{mml-mode-map}" | |
891 (interactive "P") | |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
892 (when (set (make-local-variable 'mml-mode) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
893 (if (null arg) (not mml-mode) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
894 (> (prefix-numeric-value arg) 0))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
895 (gnus-add-minor-mode 'mml-mode " MML" mml-mode-map) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
896 (easy-menu-add mml-menu mml-mode-map) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
897 (run-hooks 'mml-mode-hook))) |
31717 | 898 |
899 ;;; | |
900 ;;; Helper functions for reading MIME stuff from the minibuffer and | |
901 ;;; inserting stuff to the buffer. | |
902 ;;; | |
903 | |
904 (defun mml-minibuffer-read-file (prompt) | |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
905 (let* ((completion-ignored-extensions nil) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
906 (file (read-file-name prompt nil nil t))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
907 ;; Prevent some common errors. This is inspired by similar code in |
31717 | 908 ;; VM. |
909 (when (file-directory-p file) | |
910 (error "%s is a directory, cannot attach" file)) | |
911 (unless (file-exists-p file) | |
912 (error "No such file: %s" file)) | |
913 (unless (file-readable-p file) | |
914 (error "Permission denied: %s" file)) | |
915 file)) | |
916 | |
917 (defun mml-minibuffer-read-type (name &optional default) | |
918 (mailcap-parse-mimetypes) | |
919 (let* ((default (or default | |
920 (mm-default-file-encoding name) | |
921 ;; Perhaps here we should check what the file | |
922 ;; looks like, and offer text/plain if it looks | |
923 ;; like text/plain. | |
924 "application/octet-stream")) | |
925 (string (completing-read | |
926 (format "Content type (default %s): " default) | |
33124 | 927 (mapcar 'list (mailcap-mime-types))))) |
31717 | 928 (if (not (equal string "")) |
929 string | |
930 default))) | |
931 | |
932 (defun mml-minibuffer-read-description () | |
933 (let ((description (read-string "One line description: "))) | |
934 (when (string-match "\\`[ \t]*\\'" description) | |
935 (setq description nil)) | |
936 description)) | |
937 | |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
938 (defun mml-minibuffer-read-disposition (type &optional default) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
939 (let* ((default (or default |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
940 (if (string-match "^text/.*" type) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
941 "inline" |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
942 "attachment"))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
943 (disposition (completing-read "Disposition: " |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
944 '(("attachment") ("inline") ("")) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
945 nil |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
946 nil))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
947 (if (not (equal disposition "")) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
948 disposition |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
949 default))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
950 |
31717 | 951 (defun mml-quote-region (beg end) |
952 "Quote the MML tags in the region." | |
953 (interactive "r") | |
954 (save-excursion | |
955 (save-restriction | |
956 ;; Temporarily narrow the region to defend from changes | |
957 ;; invalidating END. | |
958 (narrow-to-region beg end) | |
959 (goto-char (point-min)) | |
960 ;; Quote parts. | |
961 (while (re-search-forward | |
962 "<#!*/?\\(multipart\\|part\\|external\\|mml\\)" nil t) | |
963 ;; Insert ! after the #. | |
964 (goto-char (+ (match-beginning 0) 2)) | |
965 (insert "!"))))) | |
966 | |
967 (defun mml-insert-tag (name &rest plist) | |
968 "Insert an MML tag described by NAME and PLIST." | |
969 (when (symbolp name) | |
970 (setq name (symbol-name name))) | |
971 (insert "<#" name) | |
972 (while plist | |
973 (let ((key (pop plist)) | |
974 (value (pop plist))) | |
975 (when value | |
976 ;; Quote VALUE if it contains suspicious characters. | |
977 (when (string-match "[\"'\\~/*;() \t\n]" value) | |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
978 (setq value (with-output-to-string |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
979 (let (print-escape-nonascii) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
980 (prin1 value))))) |
31717 | 981 (insert (format " %s=%s" key value))))) |
982 (insert ">\n")) | |
983 | |
984 (defun mml-insert-empty-tag (name &rest plist) | |
985 "Insert an empty MML tag described by NAME and PLIST." | |
986 (when (symbolp name) | |
987 (setq name (symbol-name name))) | |
988 (apply #'mml-insert-tag name plist) | |
989 (insert "<#/" name ">\n")) | |
990 | |
991 ;;; Attachment functions. | |
992 | |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
993 (defun mml-attach-file (file &optional type description disposition) |
31717 | 994 "Attach a file to the outgoing MIME message. |
995 The file is not inserted or encoded until you send the message with | |
996 `\\[message-send-and-exit]' or `\\[message-send]'. | |
997 | |
998 FILE is the name of the file to attach. TYPE is its content-type, a | |
999 string of the form \"type/subtype\". DESCRIPTION is a one-line | |
1000 description of the attachment." | |
1001 (interactive | |
1002 (let* ((file (mml-minibuffer-read-file "Attach file: ")) | |
1003 (type (mml-minibuffer-read-type file)) | |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1004 (description (mml-minibuffer-read-description)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1005 (disposition (mml-minibuffer-read-disposition type))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1006 (list file type description disposition))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1007 (mml-insert-empty-tag 'part |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1008 'type type |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1009 'filename file |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1010 'disposition (or disposition "attachment") |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1011 'description description)) |
31717 | 1012 |
1013 (defun mml-attach-buffer (buffer &optional type description) | |
1014 "Attach a buffer to the outgoing MIME message. | |
1015 See `mml-attach-file' for details of operation." | |
1016 (interactive | |
1017 (let* ((buffer (read-buffer "Attach buffer: ")) | |
1018 (type (mml-minibuffer-read-type buffer "text/plain")) | |
1019 (description (mml-minibuffer-read-description))) | |
1020 (list buffer type description))) | |
1021 (mml-insert-empty-tag 'part 'type type 'buffer buffer | |
1022 'disposition "attachment" 'description description)) | |
1023 | |
1024 (defun mml-attach-external (file &optional type description) | |
1025 "Attach an external file into the buffer. | |
1026 FILE is an ange-ftp/efs specification of the part location. | |
1027 TYPE is the MIME type to use." | |
1028 (interactive | |
1029 (let* ((file (mml-minibuffer-read-file "Attach external file: ")) | |
1030 (type (mml-minibuffer-read-type file)) | |
1031 (description (mml-minibuffer-read-description))) | |
1032 (list file type description))) | |
1033 (mml-insert-empty-tag 'external 'type type 'name file | |
1034 'disposition "attachment" 'description description)) | |
1035 | |
1036 (defun mml-insert-multipart (&optional type) | |
1037 (interactive (list (completing-read "Multipart type (default mixed): " | |
1038 '(("mixed") ("alternative") ("digest") ("parallel") | |
1039 ("signed") ("encrypted")) | |
1040 nil nil "mixed"))) | |
1041 (or type | |
1042 (setq type "mixed")) | |
1043 (mml-insert-empty-tag "multipart" 'type type) | |
1044 (forward-line -1)) | |
1045 | |
1046 (defun mml-insert-part (&optional type) | |
1047 (interactive | |
1048 (list (mml-minibuffer-read-type ""))) | |
1049 (mml-insert-tag 'part 'type type 'disposition "inline") | |
1050 (forward-line -1)) | |
1051 | |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1052 (defun mml-preview-insert-mail-followup-to () |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1053 "Insert a Mail-Followup-To header before previewing an article. |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1054 Should be adopted if code in `message-send-mail' is changed." |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1055 (when (and (message-mail-p) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1056 (message-subscribed-p) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1057 (not (mail-fetch-field "mail-followup-to")) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1058 (message-make-mail-followup-to)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1059 (message-position-on-field "Mail-Followup-To" "X-Draft-From") |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1060 (insert (message-make-mail-followup-to)))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1061 |
31717 | 1062 (defun mml-preview (&optional raw) |
1063 "Display current buffer with Gnus, in a new buffer. | |
1064 If RAW, don't highlight the article." | |
1065 (interactive "P") | |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1066 (save-excursion |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1067 (let* ((buf (current-buffer)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1068 (message-options message-options) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1069 (message-this-is-mail (message-mail-p)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1070 (message-this-is-news (message-news-p)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1071 (message-posting-charset (or (gnus-setup-posting-charset |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1072 (save-restriction |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1073 (message-narrow-to-headers-or-head) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1074 (message-fetch-field "Newsgroups"))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1075 message-posting-charset))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1076 (message-options-set-recipient) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1077 (switch-to-buffer (generate-new-buffer |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1078 (concat (if raw "*Raw MIME preview of " |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1079 "*MIME preview of ") (buffer-name)))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1080 (when (boundp 'gnus-buffers) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1081 (push (current-buffer) gnus-buffers)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1082 (erase-buffer) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1083 (insert-buffer-substring buf) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1084 (mml-preview-insert-mail-followup-to) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1085 (let ((message-deletable-headers (if (message-news-p) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1086 nil |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1087 message-deletable-headers))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1088 (message-generate-headers |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1089 (copy-sequence (if (message-news-p) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1090 message-required-news-headers |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1091 message-required-mail-headers)))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1092 (if (re-search-forward |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1093 (concat "^" (regexp-quote mail-header-separator) "\n") nil t) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1094 (replace-match "\n")) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1095 (let ((mail-header-separator ""));; mail-header-separator is removed. |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1096 (mml-to-mime)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1097 (if raw |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1098 (when (fboundp 'set-buffer-multibyte) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1099 (let ((s (buffer-string))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1100 ;; Insert the content into unibyte buffer. |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1101 (erase-buffer) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1102 (mm-disable-multibyte) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1103 (insert s))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1104 (let ((gnus-newsgroup-charset (car message-posting-charset)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1105 gnus-article-prepare-hook gnus-original-article-buffer) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1106 (run-hooks 'gnus-article-decode-hook) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1107 (let ((gnus-newsgroup-name "dummy") |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1108 (gnus-newsrc-hashtb (or gnus-newsrc-hashtb |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1109 (gnus-make-hashtable 5)))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1110 (gnus-article-prepare-display)))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1111 ;; Disable article-mode-map. |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1112 (use-local-map nil) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1113 (gnus-make-local-hook 'kill-buffer-hook) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1114 (add-hook 'kill-buffer-hook |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1115 (lambda () |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1116 (mm-destroy-parts gnus-article-mime-handles)) nil t) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1117 (setq buffer-read-only t) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1118 (local-set-key "q" (lambda () (interactive) (kill-buffer nil))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1119 (local-set-key "=" (lambda () (interactive) (delete-other-windows))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1120 (local-set-key "\r" |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1121 (lambda () |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1122 (interactive) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1123 (widget-button-press (point)))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1124 (local-set-key gnus-mouse-2 |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1125 (lambda (event) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1126 (interactive "@e") |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1127 (widget-button-press (widget-event-point event) event))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1128 (goto-char (point-min))))) |
31717 | 1129 |
1130 (defun mml-validate () | |
1131 "Validate the current MML document." | |
1132 (interactive) | |
1133 (mml-parse)) | |
1134 | |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1135 (defun mml-tweak-part (cont) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1136 "Tweak a MML part." |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1137 (let ((tweak (cdr (assq 'tweak cont))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1138 func) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1139 (cond |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1140 (tweak |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1141 (setq func |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1142 (or (cdr (assoc tweak mml-tweak-function-alist)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1143 (intern tweak)))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1144 (mml-tweak-type-alist |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1145 (let ((alist mml-tweak-type-alist) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1146 (type (or (cdr (assq 'type cont)) "text/plain"))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1147 (while alist |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1148 (if (string-match (caar alist) type) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1149 (setq func (cdar alist) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1150 alist nil) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1151 (setq alist (cdr alist))))))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1152 (if func |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1153 (funcall func cont) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1154 cont) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1155 (let ((alist mml-tweak-sexp-alist)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1156 (while alist |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1157 (if (eval (caar alist)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1158 (funcall (cdar alist) cont)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1159 (setq alist (cdr alist))))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1160 cont) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1161 |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1162 (defun mml-tweak-externalize-attachments (cont) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1163 "Tweak attached files as external parts." |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1164 (let (filename-cons) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1165 (when (and (eq (car cont) 'part) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1166 (not (cdr (assq 'buffer cont))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1167 (and (setq filename-cons (assq 'filename cont)) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1168 (not (equal (cdr (assq 'nofile cont)) "yes")))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1169 (setcar cont 'external) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1170 (setcar filename-cons 'name)))) |
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
1171 |
31717 | 1172 (provide 'mml) |
1173 | |
52401 | 1174 ;;; arch-tag: 583c96cf-1ffe-451b-a5e5-4733ae9ddd12 |
31717 | 1175 ;;; mml.el ends here |