comparison lisp/tm/tm-edit.el @ 10:49a24b4fd526 r19-15b6

Import from CVS: tag r19-15b6
author cvs
date Mon, 13 Aug 2007 08:47:52 +0200
parents 4b173ad71786
children bcdc7deadc19
comparison
equal deleted inserted replaced
9:6f2bbbbbe05a 10:49a24b4fd526
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.2 $ 9 ;; Version: $Revision: 1.3 $
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
118 118
119 ;;; @ version 119 ;;; @ version
120 ;;; 120 ;;;
121 121
122 (defconst mime-editor/RCS-ID 122 (defconst mime-editor/RCS-ID
123 "$Id: tm-edit.el,v 1.2 1996/12/22 00:29:39 steve Exp $") 123 "$Id: tm-edit.el,v 1.3 1996/12/29 00:15:13 steve Exp $")
124 124
125 (defconst mime-editor/version (get-version-string mime-editor/RCS-ID)) 125 (defconst mime-editor/version (get-version-string mime-editor/RCS-ID))
126 126
127 (defconst mime-editor/version-name 127 (defconst mime-editor/version-name
128 (concat "tm-edit " mime-editor/version)) 128 (concat "tm-edit " mime-editor/version))
290 "7bit" 290 "7bit"
291 "attachment" (("filename" . file)) 291 "attachment" (("filename" . file))
292 ) 292 )
293 ("\\.tar\\.gz$" 293 ("\\.tar\\.gz$"
294 "application" "octet-stream" (("type" . "tar+gzip")) 294 "application" "octet-stream" (("type" . "tar+gzip"))
295 nil 295 "base64"
296 "attachment" (("filename" . file)) 296 "attachment" (("filename" . file))
297 ) 297 )
298 ("\\.tgz$" 298 ("\\.tgz$"
299 "application" "octet-stream" (("type" . "tar+gzip")) 299 "application" "octet-stream" (("type" . "tar+gzip"))
300 nil 300 "base64"
301 "attachment" (("filename" . file)) 301 "attachment" (("filename" . file))
302 ) 302 )
303 ("\\.tar\\.Z$" 303 ("\\.tar\\.Z$"
304 "application" "octet-stream" (("type" . "tar+compress")) 304 "application" "octet-stream" (("type" . "tar+compress"))
305 nil 305 "base64"
306 "attachment" (("filename" . file)) 306 "attachment" (("filename" . file))
307 ) 307 )
308 ("\\.taz$" 308 ("\\.taz$"
309 "application" "octet-stream" (("type" . "tar+compress")) 309 "application" "octet-stream" (("type" . "tar+compress"))
310 nil 310 "base64"
311 "attachment" (("filename" . file)) 311 "attachment" (("filename" . file))
312 ) 312 )
313 ("\\.gz$" 313 ("\\.gz$"
314 "application" "octet-stream" (("type" . "gzip")) 314 "application" "octet-stream" (("type" . "gzip"))
315 nil 315 "base64"
316 "attachment" (("filename" . file)) 316 "attachment" (("filename" . file))
317 ) 317 )
318 ("\\.Z$" 318 ("\\.Z$"
319 "application" "octet-stream" (("type" . "compress")) 319 "application" "octet-stream" (("type" . "compress"))
320 nil 320 "base64"
321 "attachment" (("filename" . file)) 321 "attachment" (("filename" . file))
322 ) 322 )
323 ("\\.lzh$" 323 ("\\.lzh$"
324 "application" "octet-stream" (("type" . "lha")) 324 "application" "octet-stream" (("type" . "lha"))
325 nil 325 "base64"
326 "attachment" (("filename" . file)) 326 "attachment" (("filename" . file))
327 ) 327 )
328 ("\\.zip$" 328 ("\\.zip$"
329 "application" "zip" nil 329 "application" "zip" nil
330 nil 330 "base64"
331 "attachment" (("filename" . file)) 331 "attachment" (("filename" . file))
332 ) 332 )
333 ("\\.diff$" 333 ("\\.diff$"
334 "application" "octet-stream" (("type" . "patch")) 334 "application" "octet-stream" (("type" . "patch"))
335 nil 335 nil
353 353
354 ;;; @@ about charset, encoding and transfer-level 354 ;;; @@ about charset, encoding and transfer-level
355 ;;; 355 ;;;
356 356
357 (defvar mime-editor/transfer-level 7 357 (defvar mime-editor/transfer-level 7
358 "*A number of network transfer level. It should be bigger than 7.") 358 "*A number of network transfer level. It should be bigger than 7.")
359 (make-variable-buffer-local 'mime-editor/transfer-level) 359 (make-variable-buffer-local 'mime-editor/transfer-level)
360 360
361 (defvar mime-editor/transfer-level-string 361 (defvar mime-editor/transfer-level-string
362 (mime/encoding-name mime-editor/transfer-level 'not-omit) 362 (mime/encoding-name mime-editor/transfer-level 'not-omit)
363 "*A string formatted version of mime/defaul-transfer-level") 363 "*A string formatted version of mime/defaul-transfer-level")
655 "MIME minor mode for editing the tagged MIME message. 655 "MIME minor mode for editing the tagged MIME message.
656 656
657 In this mode, basically, the message is composed in the tagged MIME 657 In this mode, basically, the message is composed in the tagged MIME
658 format. The message tag looks like: 658 format. The message tag looks like:
659 659
660 `--[[text/plain; charset=ISO-2022-JP][7bit]]'. 660 --[[text/plain; charset=ISO-2022-JP][7bit]]
661 661
662 The tag specifies the MIME content type, subtype, optional parameters 662 The tag specifies the MIME content type, subtype, optional parameters
663 and transfer encoding of the message following the tag. Messages 663 and transfer encoding of the message following the tag. Messages
664 without any tag are treated as `text/plain' by default. Charset and 664 without any tag are treated as `text/plain' by default. Charset and
665 transfer encoding are automatically defined unless explicitly 665 transfer encoding are automatically defined unless explicitly
695 coding-system is different as MIME charset, please set variable 695 coding-system is different as MIME charset, please set variable
696 `mime-charset-coding-system-alist'. This variable must be alist of 696 `mime-charset-coding-system-alist'. This variable must be alist of
697 which key is MIME charset and value is coding-system. 697 which key is MIME charset and value is coding-system.
698 698
699 Following commands are available in addition to major mode commands: 699 Following commands are available in addition to major mode commands:
700
701 \[make single part\]
700 \\[mime-editor/insert-text] insert a text message. 702 \\[mime-editor/insert-text] insert a text message.
701 \\[mime-editor/insert-file] insert a (binary) file. 703 \\[mime-editor/insert-file] insert a (binary) file.
702 \\[mime-editor/insert-external] insert a reference to external body. 704 \\[mime-editor/insert-external] insert a reference to external body.
703 \\[mime-editor/insert-voice] insert a voice message. 705 \\[mime-editor/insert-voice] insert a voice message.
704 \\[mime-editor/insert-message] insert a mail or news message. 706 \\[mime-editor/insert-message] insert a mail or news message.
705 \\[mime-editor/insert-mail] insert a mail message. 707 \\[mime-editor/insert-mail] insert a mail message.
706 \\[mime-editor/insert-signature] insert a signature file at end. 708 \\[mime-editor/insert-signature] insert a signature file at end.
709 \\[mime-editor/insert-key] insert PGP public key.
707 \\[mime-editor/insert-tag] insert a new MIME tag. 710 \\[mime-editor/insert-tag] insert a new MIME tag.
711
712 \[make enclosure (maybe multipart)\]
708 \\[mime-editor/enclose-alternative-region] enclose as multipart/alternative. 713 \\[mime-editor/enclose-alternative-region] enclose as multipart/alternative.
709 \\[mime-editor/enclose-parallel-region] enclose as multipart/parallel. 714 \\[mime-editor/enclose-parallel-region] enclose as multipart/parallel.
710 \\[mime-editor/enclose-mixed-region] enclose as multipart/mixed. 715 \\[mime-editor/enclose-mixed-region] enclose as multipart/mixed.
711 \\[mime-editor/enclose-digest-region] enclose as multipart/digest. 716 \\[mime-editor/enclose-digest-region] enclose as multipart/digest.
712 \\[mime-editor/enclose-signed-region] enclose as PGP signed. 717 \\[mime-editor/enclose-signed-region] enclose as PGP signed.
713 \\[mime-editor/enclose-encrypted-region] enclose as PGP encrypted. 718 \\[mime-editor/enclose-encrypted-region] enclose as PGP encrypted.
714 \\[mime-editor/insert-key] insert PGP public key. 719 \\[mime-editor/enclose-quote-region] enclose as verbose mode (to avoid to expand tags)
720
721 \[other commands\]
722 \\[mime-editor/set-transfer-level-7bit] set transfer-level as 7.
723 \\[mime-editor/set-transfer-level-8bit] set transfer-level as 8.
724 \\[mime-editor/set-split] set message splitting mode.
725 \\[mime-editor/set-sign] set PGP-sign mode.
726 \\[mime-editor/set-encrypt] set PGP-encryption mode.
715 \\[mime-editor/preview-message] preview editing MIME message. 727 \\[mime-editor/preview-message] preview editing MIME message.
716 \\[mime-editor/exit] exit and translate into a MIME compliant message. 728 \\[mime-editor/exit] exit and translate into a MIME compliant message.
729 \\[mime-editor/help] show this help.
717 \\[mime-editor/maybe-translate] exit and translate if in MIME mode, then split. 730 \\[mime-editor/maybe-translate] exit and translate if in MIME mode, then split.
718 \\[mime-editor/help] show this help.
719 731
720 Additional commands are available in some major modes: 732 Additional commands are available in some major modes:
721 C-c C-c exit, translate and run the original command. 733 C-c C-c exit, translate and run the original command.
722 C-c C-s exit, translate and run the original command. 734 C-c C-s exit, translate and run the original command.
723 735
745 Preceding white spaces in a message body are ignored if non-nil. 757 Preceding white spaces in a message body are ignored if non-nil.
746 758
747 mime-ignore-trailing-spaces 759 mime-ignore-trailing-spaces
748 Trailing white spaces in a message body are ignored if non-nil. 760 Trailing white spaces in a message body are ignored if non-nil.
749 761
750 mime-auto-fill-header
751 Fill header fields that contain encoded-words if non-nil.
752
753 mime-auto-hide-body 762 mime-auto-hide-body
754 Hide a non-textual body message encoded in base64 after insertion 763 Hide a non-textual body message encoded in base64 after insertion
755 if non-nil. 764 if non-nil.
765
766 mime-editor/transfer-level
767 A number of network transfer level. It should be bigger than 7.
768 If you are in 8bit-through environment, please set 8.
756 769
757 mime-editor/voice-recorder 770 mime-editor/voice-recorder
758 Specifies a function to record a voice message and encode it. 771 Specifies a function to record a voice message and encode it.
759 The function `mime-editor/voice-recorder-for-sun' is for Sun 772 The function `mime-editor/voice-recorder-for-sun' is for Sun
760 SparcStations. 773 SparcStations.
881 (enriched-mode t) 894 (enriched-mode t)
882 (if (boundp 'enriched-mode) 895 (if (boundp 'enriched-mode)
883 (enriched-mode nil) 896 (enriched-mode nil)
884 )))))) 897 ))))))
885 898
886 (defun mime-editor/insert-file (file) 899 (defun mime-editor/insert-file (file &optional verbose)
887 "Insert a message from a file." 900 "Insert a message from a file."
888 (interactive "fInsert file as MIME message: ") 901 (interactive "fInsert file as MIME message: \nP")
889 (let* ((guess (mime-find-file-type file)) 902 (let* ((guess (mime-find-file-type file))
890 (pritype (nth 0 guess)) 903 (type (nth 0 guess))
891 (subtype (nth 1 guess)) 904 (subtype (nth 1 guess))
892 (parameters (nth 2 guess)) 905 (parameters (nth 2 guess))
893 (default (nth 3 guess)) ;Guess encoding from its file name. 906 (encoding (nth 3 guess))
894 (disposition-type (nth 4 guess)) 907 (disposition-type (nth 4 guess))
895 (disposition-params (nth 5 guess)) 908 (disposition-params (nth 5 guess))
896 (encoding 909 )
897 (if (not (interactive-p)) 910 (if verbose
898 default 911 (setq type (mime-prompt-for-type type)
899 (completing-read 912 subtype (mime-prompt-for-subtype type subtype)
900 (concat "What transfer encoding" 913 ))
901 (if default 914 (if (or (interactive-p) verbose)
902 (concat " (default " 915 (setq encoding (mime-prompt-for-encoding encoding))
903 (if (string-equal default "") 916 )
904 "\"\""
905 default)
906 ")"
907 ))
908 ": ")
909 mime-file-encoding-method-alist nil t nil))))
910 (if (string-equal encoding "")
911 (setq encoding default))
912 (if (or (consp parameters) (stringp disposition-type)) 917 (if (or (consp parameters) (stringp disposition-type))
913 (let ((rest parameters) cell attribute value) 918 (let ((rest parameters) cell attribute value)
914 (setq parameters "") 919 (setq parameters "")
915 (while rest 920 (while rest
916 (setq cell (car rest)) 921 (setq cell (car rest))
941 (concat parameters "; " attribute "=" value)) 946 (concat parameters "; " attribute "=" value))
942 (setq rest (cdr rest)) 947 (setq rest (cdr rest))
943 ) 948 )
944 )) 949 ))
945 )) 950 ))
946 (mime-editor/insert-tag pritype subtype parameters) 951 (mime-editor/insert-tag type subtype parameters)
947 (mime-editor/insert-binary-file file encoding) 952 (mime-editor/insert-binary-file file encoding)
948 )) 953 ))
949 954
950 (defun mime-editor/insert-external () 955 (defun mime-editor/insert-external ()
951 "Insert a reference to external body." 956 "Insert a reference to external body."
1294 (setq guess (cdr (car guesses)))) 1299 (setq guess (cdr (car guesses))))
1295 (setq guesses (cdr guesses))) 1300 (setq guesses (cdr guesses)))
1296 guess 1301 guess
1297 )) 1302 ))
1298 1303
1299 (defun mime-prompt-for-type () 1304 (defun mime-prompt-for-type (&optional default)
1300 "Ask for Content-type." 1305 "Ask for Content-type."
1301 (let ((type "")) 1306 (let ((type ""))
1302 ;; Repeat until primary content type is specified. 1307 ;; Repeat until primary content type is specified.
1303 (while (string-equal type "") 1308 (while (string-equal type "")
1304 (setq type 1309 (setq type
1305 (completing-read "What content type: " 1310 (completing-read "What content type: "
1306 mime-content-types 1311 mime-content-types
1307 nil 1312 nil
1308 'require-match ;Type must be specified. 1313 'require-match ;Type must be specified.
1309 nil 1314 default
1310 )) 1315 ))
1311 (if (string-equal type "") 1316 (if (string-equal type "")
1312 (progn 1317 (progn
1313 (message "Content type is required.") 1318 (message "Content type is required.")
1314 (beep) 1319 (beep)
1315 (sit-for 1) 1320 (sit-for 1)
1316 )) 1321 ))
1317 ) 1322 )
1318 type 1323 type))
1319 )) 1324
1320 1325 (defun mime-prompt-for-subtype (type &optional default)
1321 (defun mime-prompt-for-subtype (pritype) 1326 "Ask for subtype of media-type TYPE."
1322 "Ask for Content-type subtype of Content-Type PRITYPE." 1327 (let ((subtypes (cdr (assoc type mime-content-types))))
1323 (let* ((default (car (car (cdr (assoc pritype mime-content-types))))) 1328 (or (and default
1324 (answer 1329 (assoc default subtypes))
1330 (setq default (car (car subtypes)))
1331 ))
1332 (let* ((answer
1325 (completing-read 1333 (completing-read
1326 (if default 1334 (if default
1327 (concat 1335 (concat
1328 "What content subtype: (default " default ") ") 1336 "What content subtype: (default " default ") ")
1329 "What content subtype: ") 1337 "What content subtype: ")
1330 (cdr (assoc pritype mime-content-types)) 1338 (cdr (assoc type mime-content-types))
1331 nil 1339 nil
1332 'require-match ;Subtype must be specified. 1340 'require-match ;Subtype must be specified.
1333 nil 1341 nil
1334 ))) 1342 )))
1335 (if (string-equal answer "") default answer))) 1343 (if (string-equal answer "") default answer)))
1388 (if (string-match mime-tspecials-regexp answer) 1396 (if (string-match mime-tspecials-regexp answer)
1389 (concat "\"" answer "\"") answer))) 1397 (concat "\"" answer "\"") answer)))
1390 (mime-prompt-for-parameters-1 (cdr (assoc answer (cdr parameter))))) 1398 (mime-prompt-for-parameters-1 (cdr (assoc answer (cdr parameter)))))
1391 )) 1399 ))
1392 1400
1393 (defun mime-flag-region (from to flag) 1401 (defun mime-prompt-for-encoding (default)
1394 "Hides or shows lines from FROM to TO, according to FLAG. 1402 "Ask for Content-Transfer-Encoding. [tm-edit.el]"
1395 If FLAG is `\\n' (newline character) then text is shown, 1403 (let (encoding)
1396 while if FLAG is `\\^M' (control-M) the text is hidden." 1404 (while (string=
1397 (let ((buffer-read-only nil) ;Okay even if write protected. 1405 (setq encoding
1398 (modp (buffer-modified-p))) 1406 (completing-read
1399 (unwind-protect 1407 "What transfer encoding: "
1400 (subst-char-in-region from to 1408 mime-file-encoding-method-alist nil t default)
1401 (if (= flag ?\n) ?\^M ?\n) 1409 )
1402 flag t) 1410 ""))
1403 (set-buffer-modified-p modp)))) 1411 encoding))
1404 1412
1405 1413
1406 ;;; @ Translate the tagged MIME messages into a MIME compliant message. 1414 ;;; @ Translate the tagged MIME messages into a MIME compliant message.
1407 ;;; 1415 ;;;
1408 1416