comparison lisp/tm/tm-edit.el @ 70:131b0175ea99 r20-0b30

Import from CVS: tag r20-0b30
author cvs
date Mon, 13 Aug 2007 09:02:59 +0200
parents 56c54cf7c5b6
children 54cc21c15cbb
comparison
equal deleted inserted replaced
69:804d1389bcd6 70:131b0175ea99
1 ;;; tm-edit.el --- Simple MIME Composer for GNU Emacs 1 ;;; tm-edit.el --- Simple MIME Composer for GNU Emacs
2 2
3 ;; Copyright (C) 1993,1994,1995,1996,1997 Free Software Foundation, Inc. 3 ;; Copyright (C) 1993 .. 1996 Free Software Foundation, Inc.
4 4
5 ;; Author: UMEDA Masanobu <umerin@mse.kyutech.ac.jp> 5 ;; Author: UMEDA Masanobu <umerin@mse.kyutech.ac.jp>
6 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp> 6 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
7 ;; Maintainer: MORIOKA Tomohiko <morioka@jaist.ac.jp> 7 ;; Maintainer: MORIOKA Tomohiko <morioka@jaist.ac.jp>
8 ;; Created: 1994/08/21 renamed from mime.el 8 ;; Created: 1994/08/21 renamed from mime.el
9 ;; Version: $Revision: 1.8 $ 9 ;; Version: $Revision: 1.1.1.1 $
10 ;; Keywords: mail, news, MIME, multimedia, multilingual 10 ;; Keywords: mail, news, MIME, multimedia, multilingual
11 11
12 ;; This file is part of tm (Tools for MIME). 12 ;; This file is part of tm (Tools for MIME).
13 13
14 ;; This program is free software; you can redistribute it and/or 14 ;; This program is free software; you can redistribute it and/or
27 ;; Boston, MA 02111-1307, USA. 27 ;; Boston, MA 02111-1307, USA.
28 28
29 ;;; Commentary: 29 ;;; Commentary:
30 30
31 ;; This is an Emacs minor mode for editing Internet multimedia 31 ;; This is an Emacs minor mode for editing Internet multimedia
32 ;; messages formatted in MIME (RFC 2045, 2046, 2047, 2048 and 2049). 32 ;; messages formatted in MIME (RFC 1521 and RFC 1522). All messages in
33 ;; All messages in this mode are composed in the tagged MIME format, 33 ;; this mode are composed in the tagged MIME format, that are
34 ;; that are described in the following examples. The messages 34 ;; described in the following examples. The messages composed in the
35 ;; composed in the tagged MIME format are automatically translated 35 ;; tagged MIME format are automatically translated into a MIME
36 ;; into a MIME compliant message when exiting the mode. 36 ;; compliant message when exiting the mode.
37 37
38 ;; Mule (a multilingual extension to Emacs 18 and 19) has a capability 38 ;; Mule (a multilingual extension to Emacs 18 and 19) has a capability
39 ;; of handling multilingual text in limited ISO-2022 manner that is 39 ;; of handling multilingual text in limited ISO-2022 manner that is
40 ;; based on early experiences in Japanese Internet community and 40 ;; based on early experiences in Japanese Internet community and
41 ;; resulted in RFC 1468 (ISO-2022-JP charset for MIME). In order to 41 ;; resulted in RFC 1468 (ISO-2022-JP charset for MIME). In order to
42 ;; enable multilingual capability in single text message in MIME, 42 ;; enable multilingual capability in single text message in MIME,
43 ;; charset of multilingual text written in Mule is declared as either 43 ;; charset of multilingual text written in Mule is declared as either
44 ;; `ISO-2022-JP-2' [RFC 1554]. Mule is required for reading the such 44 ;; `ISO-2022-JP-2' [RFC 1554] or `ISO-2022-INT-1'. Mule is required
45 ;; messages. 45 ;; for reading the such messages.
46 46
47 ;; This MIME composer can work with Mail mode, mh-e letter Mode, and 47 ;; This MIME composer can work with Mail mode, mh-e letter Mode, and
48 ;; News mode. First of all, you need the following autoload 48 ;; News mode. First of all, you need the following autoload
49 ;; definition to load mime/editor-mode automatically: 49 ;; definition to load mime/editor-mode automatically:
50 ;; 50 ;;
92 ;; This is a conventional plain text. It should be translated into 92 ;; This is a conventional plain text. It should be translated into
93 ;; text/plain. 93 ;; text/plain.
94 ;; 94 ;;
95 ;;--[[text/plain]] 95 ;;--[[text/plain]]
96 ;; This is also a plain text. But, it is explicitly specified as is. 96 ;; This is also a plain text. But, it is explicitly specified as is.
97 ;;--[[text/plain; charset=ISO-8859-1]]
98 ;; This is also a plain text. But charset is specified as iso-8859-1.
99 ;; 97 ;;
100 ;; ¡Hola! Buenos días. ¿Cómo está usted? 98 ;;--[[text/plain; charset=ISO-2022-JP]]
101 ;;--[[text/enriched]] 99 ;; $B$3$l$O(B charset $B$r(B ISO-2022-JP $B$K;XDj$7$?F|K\8l$N(B plain $B/home/mrb/e/w/editor/lisp/tm/SCCS/s.tm-edit.el-%9%H$G$9(B.
100 ;;
101 ;;--[[text/richtext]]
102 ;; <center>This is a richtext.</center> 102 ;; <center>This is a richtext.</center>
103 ;; 103 ;;
104 ;;--[[image/gif][base64]]^M...image encoded in base64 comes here... 104 ;;--[[image/gif][base64]]^M...image encoded in base64 comes here...
105 ;; 105 ;;
106 ;;--[[audio/basic][base64]]^M...audio encoded in base64 comes here... 106 ;;--[[audio/basic][base64]]^M...audio encoded in base64 comes here...
108 ;;; Code: 108 ;;; Code:
109 109
110 (require 'sendmail) 110 (require 'sendmail)
111 (require 'mail-utils) 111 (require 'mail-utils)
112 (require 'mel) 112 (require 'mel)
113 (require 'tl-822)
113 (require 'tl-list) 114 (require 'tl-list)
114 (require 'tm-view) 115 (require 'tm-view)
115 (require 'tm-ew-e) 116 (require 'tm-ew-e)
116 (require 'signature) 117 (require 'signature)
117 118
118 119
119 ;;; @ version 120 ;;; @ version
120 ;;; 121 ;;;
121 122
122 (defconst mime-editor/RCS-ID 123 (defconst mime-editor/RCS-ID
123 "$Id: tm-edit.el,v 1.8 1997/08/21 06:24:11 steve Exp $") 124 "$Id: tm-edit.el,v 1.1.1.1 1996/12/18 22:43:37 steve Exp $")
124 125
125 (defconst mime-editor/version (get-version-string mime-editor/RCS-ID)) 126 (defconst mime-editor/version (get-version-string mime-editor/RCS-ID))
126 127
127 (defconst mime-editor/version-name 128 (defconst mime-editor/version-name
128 (concat "tm-edit " mime-editor/version)) 129 (concat "tm-edit " mime-editor/version))
208 ("postscript") 209 ("postscript")
209 ("x-kiss" ("x-cnf"))) 210 ("x-kiss" ("x-cnf")))
210 ("image" 211 ("image"
211 ("gif") 212 ("gif")
212 ("jpeg") 213 ("jpeg")
213 ("png")
214 ("tiff") 214 ("tiff")
215 ("x-pic") 215 ("x-pic")
216 ("x-mag") 216 ("x-mag")
217 ("x-xwd") 217 ("x-xwd")
218 ("x-xbm") 218 ("x-xbm")
241 "base64" 241 "base64"
242 "inline" (("filename" . file)) 242 "inline" (("filename" . file))
243 ) 243 )
244 ("\\.gif$" 244 ("\\.gif$"
245 "image" "gif" nil 245 "image" "gif" nil
246 "base64"
247 "inline" (("filename" . file))
248 )
249 ("\\.png$"
250 "image" "png" nil
251 "base64" 246 "base64"
252 "inline" (("filename" . file)) 247 "inline" (("filename" . file))
253 ) 248 )
254 ("\\.tiff$" 249 ("\\.tiff$"
255 "image" "tiff" nil 250 "image" "tiff" nil
296 "7bit" 291 "7bit"
297 "attachment" (("filename" . file)) 292 "attachment" (("filename" . file))
298 ) 293 )
299 ("\\.tar\\.gz$" 294 ("\\.tar\\.gz$"
300 "application" "octet-stream" (("type" . "tar+gzip")) 295 "application" "octet-stream" (("type" . "tar+gzip"))
301 "base64" 296 nil
302 "attachment" (("filename" . file)) 297 "attachment" (("filename" . file))
303 ) 298 )
304 ("\\.tgz$" 299 ("\\.tgz$"
305 "application" "octet-stream" (("type" . "tar+gzip")) 300 "application" "octet-stream" (("type" . "tar+gzip"))
306 "base64" 301 nil
307 "attachment" (("filename" . file)) 302 "attachment" (("filename" . file))
308 ) 303 )
309 ("\\.tar\\.Z$" 304 ("\\.tar\\.Z$"
310 "application" "octet-stream" (("type" . "tar+compress")) 305 "application" "octet-stream" (("type" . "tar+compress"))
311 "base64" 306 nil
312 "attachment" (("filename" . file)) 307 "attachment" (("filename" . file))
313 ) 308 )
314 ("\\.taz$" 309 ("\\.taz$"
315 "application" "octet-stream" (("type" . "tar+compress")) 310 "application" "octet-stream" (("type" . "tar+compress"))
316 "base64" 311 nil
317 "attachment" (("filename" . file)) 312 "attachment" (("filename" . file))
318 ) 313 )
319 ("\\.gz$" 314 ("\\.gz$"
320 "application" "octet-stream" (("type" . "gzip")) 315 "application" "octet-stream" (("type" . "gzip"))
321 "base64" 316 nil
322 "attachment" (("filename" . file)) 317 "attachment" (("filename" . file))
323 ) 318 )
324 ("\\.Z$" 319 ("\\.Z$"
325 "application" "octet-stream" (("type" . "compress")) 320 "application" "octet-stream" (("type" . "compress"))
326 "base64" 321 nil
327 "attachment" (("filename" . file)) 322 "attachment" (("filename" . file))
328 ) 323 )
329 ("\\.lzh$" 324 ("\\.lzh$"
330 "application" "octet-stream" (("type" . "lha")) 325 "application" "octet-stream" (("type" . "lha"))
331 "base64" 326 nil
332 "attachment" (("filename" . file)) 327 "attachment" (("filename" . file))
333 ) 328 )
334 ("\\.zip$" 329 ("\\.zip$"
335 "application" "zip" nil 330 "application" "zip" nil
336 "base64" 331 nil
337 "attachment" (("filename" . file)) 332 "attachment" (("filename" . file))
338 ) 333 )
339 ("\\.diff$" 334 ("\\.diff$"
340 "application" "octet-stream" (("type" . "patch")) 335 "application" "octet-stream" (("type" . "patch"))
341 nil 336 nil
359 354
360 ;;; @@ about charset, encoding and transfer-level 355 ;;; @@ about charset, encoding and transfer-level
361 ;;; 356 ;;;
362 357
363 (defvar mime-editor/transfer-level 7 358 (defvar mime-editor/transfer-level 7
364 "*A number of network transfer level. It should be bigger than 7.") 359 "*A number of network transfer level. It should be bigger than 7.")
365 (make-variable-buffer-local 'mime-editor/transfer-level) 360 (make-variable-buffer-local 'mime-editor/transfer-level)
366 361
367 (defvar mime-editor/transfer-level-string 362 (defvar mime-editor/transfer-level-string
368 (mime/encoding-name mime-editor/transfer-level 'not-omit) 363 (mime/encoding-name mime-editor/transfer-level 'not-omit)
369 "*A string formatted version of mime/defaul-transfer-level") 364 "*A string formatted version of mime/defaul-transfer-level")
436 (defvar mime-editor/signing-type 'pgp-elkins 431 (defvar mime-editor/signing-type 'pgp-elkins
437 "*PGP signing type (pgp-elkins, pgp-kazu or nil). [tm-edit.el]") 432 "*PGP signing type (pgp-elkins, pgp-kazu or nil). [tm-edit.el]")
438 433
439 (defvar mime-editor/encrypting-type 'pgp-elkins 434 (defvar mime-editor/encrypting-type 'pgp-elkins
440 "*PGP encrypting type (pgp-elkins, pgp-kazu or nil). [tm-edit.el]") 435 "*PGP encrypting type (pgp-elkins, pgp-kazu or nil). [tm-edit.el]")
436
437 (defvar mime-editor/pgp-sign-function 'tm:mc-pgp-sign-region)
438 (defvar mime-editor/pgp-encrypt-function 'tm:mc-pgp-encrypt-region)
439 (defvar mime-editor/traditional-pgp-sign-function 'mc-pgp-sign-region)
440 (defvar mime-editor/pgp-insert-public-key-function 'mc-insert-public-key)
441
442 (autoload mime-editor/pgp-sign-function "tm-edit-mc")
443 (autoload mime-editor/pgp-encrypt-function "tm-edit-mc")
444 (autoload mime-editor/traditional-pgp-sign-function "mc-pgp")
445 (autoload mime-editor/pgp-insert-public-key-function "mc-toplev")
441 446
442 447
443 ;;; @@ about tag 448 ;;; @@ about tag
444 ;;; 449 ;;;
445 450
651 "MIME minor mode for editing the tagged MIME message. 656 "MIME minor mode for editing the tagged MIME message.
652 657
653 In this mode, basically, the message is composed in the tagged MIME 658 In this mode, basically, the message is composed in the tagged MIME
654 format. The message tag looks like: 659 format. The message tag looks like:
655 660
656 --[[text/plain; charset=ISO-2022-JP][7bit]] 661 `--[[text/plain; charset=ISO-2022-JP][7bit]]'.
657 662
658 The tag specifies the MIME content type, subtype, optional parameters 663 The tag specifies the MIME content type, subtype, optional parameters
659 and transfer encoding of the message following the tag. Messages 664 and transfer encoding of the message following the tag. Messages
660 without any tag are treated as `text/plain' by default. Charset and 665 without any tag are treated as `text/plain' by default. Charset and
661 transfer encoding are automatically defined unless explicitly 666 transfer encoding are automatically defined unless explicitly
691 coding-system is different as MIME charset, please set variable 696 coding-system is different as MIME charset, please set variable
692 `mime-charset-coding-system-alist'. This variable must be alist of 697 `mime-charset-coding-system-alist'. This variable must be alist of
693 which key is MIME charset and value is coding-system. 698 which key is MIME charset and value is coding-system.
694 699
695 Following commands are available in addition to major mode commands: 700 Following commands are available in addition to major mode commands:
696
697 \[make single part\]
698 \\[mime-editor/insert-text] insert a text message. 701 \\[mime-editor/insert-text] insert a text message.
699 \\[mime-editor/insert-file] insert a (binary) file. 702 \\[mime-editor/insert-file] insert a (binary) file.
700 \\[mime-editor/insert-external] insert a reference to external body. 703 \\[mime-editor/insert-external] insert a reference to external body.
701 \\[mime-editor/insert-voice] insert a voice message. 704 \\[mime-editor/insert-voice] insert a voice message.
702 \\[mime-editor/insert-message] insert a mail or news message. 705 \\[mime-editor/insert-message] insert a mail or news message.
703 \\[mime-editor/insert-mail] insert a mail message. 706 \\[mime-editor/insert-mail] insert a mail message.
704 \\[mime-editor/insert-signature] insert a signature file at end. 707 \\[mime-editor/insert-signature] insert a signature file at end.
705 \\[mime-editor/insert-key] insert PGP public key.
706 \\[mime-editor/insert-tag] insert a new MIME tag. 708 \\[mime-editor/insert-tag] insert a new MIME tag.
707
708 \[make enclosure (maybe multipart)\]
709 \\[mime-editor/enclose-alternative-region] enclose as multipart/alternative. 709 \\[mime-editor/enclose-alternative-region] enclose as multipart/alternative.
710 \\[mime-editor/enclose-parallel-region] enclose as multipart/parallel. 710 \\[mime-editor/enclose-parallel-region] enclose as multipart/parallel.
711 \\[mime-editor/enclose-mixed-region] enclose as multipart/mixed. 711 \\[mime-editor/enclose-mixed-region] enclose as multipart/mixed.
712 \\[mime-editor/enclose-digest-region] enclose as multipart/digest. 712 \\[mime-editor/enclose-digest-region] enclose as multipart/digest.
713 \\[mime-editor/enclose-signed-region] enclose as PGP signed. 713 \\[mime-editor/enclose-signed-region] enclose as PGP signed.
714 \\[mime-editor/enclose-encrypted-region] enclose as PGP encrypted. 714 \\[mime-editor/enclose-encrypted-region] enclose as PGP encrypted.
715 \\[mime-editor/enclose-quote-region] enclose as verbose mode (to avoid to expand tags) 715 \\[mime-editor/insert-key] insert PGP public key.
716
717 \[other commands\]
718 \\[mime-editor/set-transfer-level-7bit] set transfer-level as 7.
719 \\[mime-editor/set-transfer-level-8bit] set transfer-level as 8.
720 \\[mime-editor/set-split] set message splitting mode.
721 \\[mime-editor/set-sign] set PGP-sign mode.
722 \\[mime-editor/set-encrypt] set PGP-encryption mode.
723 \\[mime-editor/preview-message] preview editing MIME message. 716 \\[mime-editor/preview-message] preview editing MIME message.
724 \\[mime-editor/exit] exit and translate into a MIME compliant message. 717 \\[mime-editor/exit] exit and translate into a MIME compliant message.
718 \\[mime-editor/maybe-translate] exit and translate if in MIME mode, then split.
725 \\[mime-editor/help] show this help. 719 \\[mime-editor/help] show this help.
726 \\[mime-editor/maybe-translate] exit and translate if in MIME mode, then split.
727 720
728 Additional commands are available in some major modes: 721 Additional commands are available in some major modes:
729 C-c C-c exit, translate and run the original command. 722 C-c C-c exit, translate and run the original command.
730 C-c C-s exit, translate and run the original command. 723 C-c C-s exit, translate and run the original command.
731 724
735 This is a conventional plain text. It should be translated 728 This is a conventional plain text. It should be translated
736 into text/plain. 729 into text/plain.
737 --[[text/plain]] 730 --[[text/plain]]
738 This is also a plain text. But, it is explicitly specified as 731 This is also a plain text. But, it is explicitly specified as
739 is. 732 is.
740 --[[text/plain; charset=ISO-8859-1]] 733 --[[text/plain; charset=ISO-2022-JP]]
741 This is also a plain text. But charset is specified as 734 $B$3$l$O(B charset $B$r(B ISO-2022-JP $B$K;XDj$7$?F|K\8l$N(B plain $B/home/mrb/e/w/editor/lisp/tm/SCCS/s.tm-edit.el-%9(B
742 iso-8859-1. 735 $B%H$G$9(B.
743 736 --[[text/richtext]]
744 ¡Hola! Buenos días. ¿Cómo está usted? 737 <center>This is a richtext.</center>
745 --[[text/enriched]] 738 --[[image/gif][base64]]^M...image encoded in base64 here...
746 This is a <bold>enriched text</bold>. 739 --[[audio/basic][base64]]^M...audio encoded in base64 here...
747 --[[image/gif][base64]]...image encoded in base64 here...
748 --[[audio/basic][base64]]...audio encoded in base64 here...
749 740
750 User customizable variables (not documented all of them): 741 User customizable variables (not documented all of them):
751 mime-prefix 742 mime-prefix
752 Specifies a key prefix for MIME minor mode commands. 743 Specifies a key prefix for MIME minor mode commands.
753 744
755 Preceding white spaces in a message body are ignored if non-nil. 746 Preceding white spaces in a message body are ignored if non-nil.
756 747
757 mime-ignore-trailing-spaces 748 mime-ignore-trailing-spaces
758 Trailing white spaces in a message body are ignored if non-nil. 749 Trailing white spaces in a message body are ignored if non-nil.
759 750
751 mime-auto-fill-header
752 Fill header fields that contain encoded-words if non-nil.
753
760 mime-auto-hide-body 754 mime-auto-hide-body
761 Hide a non-textual body message encoded in base64 after insertion 755 Hide a non-textual body message encoded in base64 after insertion
762 if non-nil. 756 if non-nil.
763
764 mime-editor/transfer-level
765 A number of network transfer level. It should be bigger than 7.
766 If you are in 8bit-through environment, please set 8.
767 757
768 mime-editor/voice-recorder 758 mime-editor/voice-recorder
769 Specifies a function to record a voice message and encode it. 759 Specifies a function to record a voice message and encode it.
770 The function `mime-editor/voice-recorder-for-sun' is for Sun 760 The function `mime-editor/voice-recorder-for-sun' is for Sun
771 SparcStations. 761 SparcStations.
847 (run-hooks 'mime-editor/translate-hook) 837 (run-hooks 'mime-editor/translate-hook)
848 (mime-editor/translate-buffer))) 838 (mime-editor/translate-buffer)))
849 ;; Restore previous state. 839 ;; Restore previous state.
850 (setq mime/editor-mode-flag nil) 840 (setq mime/editor-mode-flag nil)
851 (cond (running-xemacs 841 (cond (running-xemacs
852 (if (featurep 'menubar) 842 (delete-menu-item (list mime-editor/menu-title)))
853 (delete-menu-item (list mime-editor/menu-title))))
854 (t 843 (t
855 (use-local-map mime/editor-mode-old-local-map))) 844 (use-local-map mime/editor-mode-old-local-map)))
856 845
857 (end-of-invisible) 846 (end-of-invisible)
858 (set-buffer-modified-p (buffer-modified-p)) 847 (set-buffer-modified-p (buffer-modified-p))
874 (princ (documentation 'mime/editor-mode)) 863 (princ (documentation 'mime/editor-mode))
875 (print-help-return-message))) 864 (print-help-return-message)))
876 865
877 (defun mime-editor/insert-text () 866 (defun mime-editor/insert-text ()
878 "Insert a text message. 867 "Insert a text message.
879 Charset is automatically obtained from the `charsets-mime-charset-alist'." 868 Charset is automatically obtained from the `mime/lc-charset-alist'."
880 (interactive) 869 (interactive)
881 (let ((ret (mime-editor/insert-tag "text" nil nil))) 870 (let ((ret (mime-editor/insert-tag "text" nil nil)))
882 (if ret 871 (if ret
883 (progn 872 (progn
884 (if (looking-at mime-editor/single-part-tag-regexp) 873 (if (looking-at mime-editor/single-part-tag-regexp)
893 (enriched-mode t) 882 (enriched-mode t)
894 (if (boundp 'enriched-mode) 883 (if (boundp 'enriched-mode)
895 (enriched-mode nil) 884 (enriched-mode nil)
896 )))))) 885 ))))))
897 886
898 (defun mime-editor/insert-file (file &optional verbose) 887 (defun mime-editor/insert-file (file)
899 "Insert a message from a file." 888 "Insert a message from a file."
900 (interactive "fInsert file as MIME message: \nP") 889 (interactive "fInsert file as MIME message: ")
901 (let* ((guess (mime-find-file-type file)) 890 (let* ((guess (mime-find-file-type file))
902 (type (nth 0 guess)) 891 (pritype (nth 0 guess))
903 (subtype (nth 1 guess)) 892 (subtype (nth 1 guess))
904 (parameters (nth 2 guess)) 893 (parameters (nth 2 guess))
905 (encoding (nth 3 guess)) 894 (default (nth 3 guess)) ;Guess encoding from its file name.
906 (disposition-type (nth 4 guess)) 895 (disposition-type (nth 4 guess))
907 (disposition-params (nth 5 guess)) 896 (disposition-params (nth 5 guess))
908 ) 897 (encoding
909 (if verbose 898 (if (not (interactive-p))
910 (setq type (mime-prompt-for-type type) 899 default
911 subtype (mime-prompt-for-subtype type subtype) 900 (completing-read
912 )) 901 (concat "What transfer encoding"
913 (if (or (interactive-p) verbose) 902 (if default
914 (setq encoding (mime-prompt-for-encoding encoding)) 903 (concat " (default "
915 ) 904 (if (string-equal default "")
905 "\"\""
906 default)
907 ")"
908 ))
909 ": ")
910 mime-file-encoding-method-alist nil t nil))))
911 (if (string-equal encoding "")
912 (setq encoding default))
916 (if (or (consp parameters) (stringp disposition-type)) 913 (if (or (consp parameters) (stringp disposition-type))
917 (let ((rest parameters) cell attribute value) 914 (let ((rest parameters) cell attribute value)
918 (setq parameters "") 915 (setq parameters "")
919 (while rest 916 (while rest
920 (setq cell (car rest)) 917 (setq cell (car rest))
945 (concat parameters "; " attribute "=" value)) 942 (concat parameters "; " attribute "=" value))
946 (setq rest (cdr rest)) 943 (setq rest (cdr rest))
947 ) 944 )
948 )) 945 ))
949 )) 946 ))
950 (mime-editor/insert-tag type subtype parameters) 947 (mime-editor/insert-tag pritype subtype parameters)
951 (mime-editor/insert-binary-file file encoding) 948 (mime-editor/insert-binary-file file encoding)
952 )) 949 ))
953 950
954 (defun mime-editor/insert-external () 951 (defun mime-editor/insert-external ()
955 "Insert a reference to external body." 952 "Insert a reference to external body."
1298 (setq guess (cdr (car guesses)))) 1295 (setq guess (cdr (car guesses))))
1299 (setq guesses (cdr guesses))) 1296 (setq guesses (cdr guesses)))
1300 guess 1297 guess
1301 )) 1298 ))
1302 1299
1303 (defun mime-prompt-for-type (&optional default) 1300 (defun mime-prompt-for-type ()
1304 "Ask for Content-type." 1301 "Ask for Content-type."
1305 (let ((type "")) 1302 (let ((type ""))
1306 ;; Repeat until primary content type is specified. 1303 ;; Repeat until primary content type is specified.
1307 (while (string-equal type "") 1304 (while (string-equal type "")
1308 (setq type 1305 (setq type
1309 (completing-read "What content type: " 1306 (completing-read "What content type: "
1310 mime-content-types 1307 mime-content-types
1311 nil 1308 nil
1312 'require-match ;Type must be specified. 1309 'require-match ;Type must be specified.
1313 default 1310 nil
1314 )) 1311 ))
1315 (if (string-equal type "") 1312 (if (string-equal type "")
1316 (progn 1313 (progn
1317 (message "Content type is required.") 1314 (message "Content type is required.")
1318 (beep) 1315 (beep)
1319 (sit-for 1) 1316 (sit-for 1)
1320 )) 1317 ))
1321 ) 1318 )
1322 type)) 1319 type
1323 1320 ))
1324 (defun mime-prompt-for-subtype (type &optional default) 1321
1325 "Ask for subtype of media-type TYPE." 1322 (defun mime-prompt-for-subtype (pritype)
1326 (let ((subtypes (cdr (assoc type mime-content-types)))) 1323 "Ask for Content-type subtype of Content-Type PRITYPE."
1327 (or (and default 1324 (let* ((default (car (car (cdr (assoc pritype mime-content-types)))))
1328 (assoc default subtypes)) 1325 (answer
1329 (setq default (car (car subtypes)))
1330 ))
1331 (let* ((answer
1332 (completing-read 1326 (completing-read
1333 (if default 1327 (if default
1334 (concat 1328 (concat
1335 "What content subtype: (default " default ") ") 1329 "What content subtype: (default " default ") ")
1336 "What content subtype: ") 1330 "What content subtype: ")
1337 (cdr (assoc type mime-content-types)) 1331 (cdr (assoc pritype mime-content-types))
1338 nil 1332 nil
1339 'require-match ;Subtype must be specified. 1333 'require-match ;Subtype must be specified.
1340 nil 1334 nil
1341 ))) 1335 )))
1342 (if (string-equal answer "") default answer))) 1336 (if (string-equal answer "") default answer)))
1395 (if (string-match mime-tspecials-regexp answer) 1389 (if (string-match mime-tspecials-regexp answer)
1396 (concat "\"" answer "\"") answer))) 1390 (concat "\"" answer "\"") answer)))
1397 (mime-prompt-for-parameters-1 (cdr (assoc answer (cdr parameter))))) 1391 (mime-prompt-for-parameters-1 (cdr (assoc answer (cdr parameter)))))
1398 )) 1392 ))
1399 1393
1400 (defun mime-prompt-for-encoding (default) 1394 (defun mime-flag-region (from to flag)
1401 "Ask for Content-Transfer-Encoding. [tm-edit.el]" 1395 "Hides or shows lines from FROM to TO, according to FLAG.
1402 (let (encoding) 1396 If FLAG is `\\n' (newline character) then text is shown,
1403 (while (string= 1397 while if FLAG is `\\^M' (control-M) the text is hidden."
1404 (setq encoding 1398 (let ((buffer-read-only nil) ;Okay even if write protected.
1405 (completing-read 1399 (modp (buffer-modified-p)))
1406 "What transfer encoding: " 1400 (unwind-protect
1407 mime-file-encoding-method-alist nil t default) 1401 (subst-char-in-region from to
1408 ) 1402 (if (= flag ?\n) ?\^M ?\n)
1409 "")) 1403 flag t)
1410 encoding)) 1404 (set-buffer-modified-p modp))))
1411 1405
1412 1406
1413 ;;; @ Translate the tagged MIME messages into a MIME compliant message. 1407 ;;; @ Translate the tagged MIME messages into a MIME compliant message.
1414 ;;; 1408 ;;;
1415 1409
1552 (insert (format "Content-Type: %s\n" ctype)) 1546 (insert (format "Content-Type: %s\n" ctype))
1553 (if encoding 1547 (if encoding
1554 (insert (format "Content-Transfer-Encoding: %s\n" encoding)) 1548 (insert (format "Content-Transfer-Encoding: %s\n" encoding))
1555 ) 1549 )
1556 (insert "\n") 1550 (insert "\n")
1557 (or (funcall (pgp-function 'mime-sign) 1551 (or (funcall mime-editor/pgp-sign-function
1558 (point-min)(point-max) nil nil pgp-boundary) 1552 (point-min)(point-max) nil nil pgp-boundary)
1559 (throw 'mime-editor/error 'pgp-error) 1553 (throw 'mime-editor/error 'pgp-error)
1560 ) 1554 )
1561 )))) 1555 ))))
1562 1556
1616 (insert (format "Content-Type: %s\n" ctype)) 1610 (insert (format "Content-Type: %s\n" ctype))
1617 (if encoding 1611 (if encoding
1618 (insert (format "Content-Transfer-Encoding: %s\n" encoding)) 1612 (insert (format "Content-Transfer-Encoding: %s\n" encoding))
1619 ) 1613 )
1620 (insert "\n") 1614 (insert "\n")
1621 (or (funcall (pgp-function 'encrypt) 1615 (or (funcall mime-editor/pgp-encrypt-function
1622 recipients (point-min) (point-max) from) 1616 recipients (point-min) (point-max) from)
1623 (throw 'mime-editor/error 'pgp-error) 1617 (throw 'mime-editor/error 'pgp-error)
1624 ) 1618 )
1625 (goto-char beg) 1619 (goto-char beg)
1626 (insert (format "--[[multipart/encrypted; 1620 (insert (format "--[[multipart/encrypted;
1653 (if encoding 1647 (if encoding
1654 (insert (format "Content-Transfer-Encoding: %s\n" encoding)) 1648 (insert (format "Content-Transfer-Encoding: %s\n" encoding))
1655 ) 1649 )
1656 (insert "\n") 1650 (insert "\n")
1657 (or (as-binary-process 1651 (or (as-binary-process
1658 (funcall (pgp-function 'traditional-sign) 1652 (funcall mime-editor/traditional-pgp-sign-function
1659 beg (point-max))) 1653 beg (point-max)))
1660 (throw 'mime-editor/error 'pgp-error) 1654 (throw 'mime-editor/error 'pgp-error)
1661 ) 1655 )
1662 (goto-char beg) 1656 (goto-char beg)
1663 (insert 1657 (insert
1687 (if encoding 1681 (if encoding
1688 (insert (format "Content-Transfer-Encoding: %s\n" encoding)) 1682 (insert (format "Content-Transfer-Encoding: %s\n" encoding))
1689 ) 1683 )
1690 (insert "\n") 1684 (insert "\n")
1691 (or (as-binary-process 1685 (or (as-binary-process
1692 (funcall (pgp-function 'encrypt) 1686 (funcall mime-editor/pgp-encrypt-function
1693 recipients beg (point-max) nil 'maybe) 1687 recipients beg (point-max) nil 'maybe)
1694 ) 1688 )
1695 (throw 'mime-editor/error 'pgp-error) 1689 (throw 'mime-editor/error 'pgp-error)
1696 ) 1690 )
1697 (goto-char beg) 1691 (goto-char beg)
1764 (let* ((beg (match-beginning 0)) 1758 (let* ((beg (match-beginning 0))
1765 (end (match-end 0)) 1759 (end (match-end 0))
1766 (tag (buffer-substring beg end)) 1760 (tag (buffer-substring beg end))
1767 ) 1761 )
1768 (delete-region beg end) 1762 (delete-region beg end)
1769 (let ((contype (mime-editor/get-contype tag)) 1763 (setq contype (mime-editor/get-contype tag))
1770 (encoding (mime-editor/get-encoding tag)) 1764 (setq encoding (mime-editor/get-encoding tag))
1771 ) 1765 (insert (concat prefix "--" boundary "\n"))
1772 (insert (concat prefix "--" boundary "\n")) 1766 (save-restriction
1773 (save-restriction 1767 (narrow-to-region (point)(point))
1774 (narrow-to-region (point)(point)) 1768 (insert "Content-Type: " contype "\n")
1775 (insert "Content-Type: " contype "\n") 1769 (if encoding
1776 (if encoding 1770 (insert "Content-Transfer-Encoding: " encoding "\n"))
1777 (insert "Content-Transfer-Encoding: " encoding "\n")) 1771 (mime/encode-message-header)
1778 (mime/encode-message-header) 1772 )
1779 ))
1780 t))) 1773 t)))
1781 1774
1782 (defun mime-editor/translate-region (beg end &optional boundary multipart) 1775 (defun mime-editor/translate-region (beg end &optional boundary multipart)
1783 (if (null boundary) 1776 (if (null boundary)
1784 (setq boundary 1777 (setq boundary
2069 (defun mime-editor/insert-key (&optional arg) 2062 (defun mime-editor/insert-key (&optional arg)
2070 "Insert a pgp public key." 2063 "Insert a pgp public key."
2071 (interactive "P") 2064 (interactive "P")
2072 (mime-editor/insert-tag "application" "pgp-keys") 2065 (mime-editor/insert-tag "application" "pgp-keys")
2073 (mime-editor/define-encoding "7bit") 2066 (mime-editor/define-encoding "7bit")
2074 (funcall (pgp-function 'insert-key)) 2067 (funcall mime-editor/pgp-insert-public-key-function)
2075 ) 2068 )
2076 2069
2077 2070
2078 ;;; @ flag setting 2071 ;;; @ flag setting
2079 ;;; 2072 ;;;
2439 (setq stype (substring ctype (match-end 0))) 2432 (setq stype (substring ctype (match-end 0)))
2440 ) 2433 )
2441 (setq type ctype) 2434 (setq type ctype)
2442 ) 2435 )
2443 (cond 2436 (cond
2444 ((string= ctype "application/pgp-signature") 2437 ((string-equal type "multipart")
2445 (delete-region (point-min)(point-max))
2446 )
2447 ((string= type "multipart")
2448 (let* ((boundary (assoc-value "boundary" params)) 2438 (let* ((boundary (assoc-value "boundary" params))
2449 (boundary-pat 2439 (boundary-pat
2450 (concat "\n--" (regexp-quote boundary) "[ \t]*\n")) 2440 (concat "\n--" (regexp-quote boundary) "[ \t]*\n"))
2451 ) 2441 )
2452 (re-search-forward boundary-pat nil t) 2442 (re-search-forward boundary-pat nil t)
2487 ))) 2477 )))
2488 )) 2478 ))
2489 (t 2479 (t
2490 (let* (charset 2480 (let* (charset
2491 (pstr 2481 (pstr
2492 (let ((bytes (+ 14 (length ctype)))) 2482 (mapconcat (function
2493 (mapconcat (function 2483 (lambda (attr)
2494 (lambda (attr) 2484 (if (string-equal (car attr)
2495 (if (string-equal (car attr) "charset") 2485 "charset")
2496 (progn 2486 (progn
2497 (setq charset (cdr attr)) 2487 (setq charset (cdr attr))
2498 "") 2488 "")
2499 (let* ((str 2489 (concat ";" (car attr)
2500 (concat (car attr) 2490 "=" (cdr attr))
2501 "=" (cdr attr)) 2491 )
2502 ) 2492 ))
2503 (bs (length str)) 2493 params ""))
2504 )
2505 (setq bytes (+ bytes bs 2))
2506 (if (< bytes 76)
2507 (concat "; " str)
2508 (setq bytes (+ bs 1))
2509 (concat ";\n " str)
2510 )
2511 ))))
2512 params "")))
2513 encoding 2494 encoding
2514 encoded) 2495 encoded)
2515 (save-excursion 2496 (save-excursion
2516 (if (re-search-forward 2497 (if (re-search-forward
2517 "Content-Transfer-Encoding:" nil t) 2498 "Content-Transfer-Encoding:" nil t)