Mercurial > hg > xemacs-beta
comparison lisp/tm/tm-edit.el @ 76:c0c698873ce1 r20-0b33
Import from CVS: tag r20-0b33
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:05:10 +0200 |
parents | 54cc21c15cbb |
children | c7528f8e288d |
comparison
equal
deleted
inserted
replaced
75:a4e0195b387b | 76:c0c698873ce1 |
---|---|
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.1.1.2 $ | 9 ;; Version: $Revision: 1.2 $ |
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.1.1.2 1996/12/21 20:50:44 steve Exp $") | 123 "$Id: tm-edit.el,v 1.2 1996/12/28 21:03: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") |
648 | 648 |
649 | 649 |
650 ;;; @ functions | 650 ;;; @ functions |
651 ;;; | 651 ;;; |
652 | 652 |
653 ;; The following text was removed from the docstring of the subsequent | |
654 ;; functions due to problems with the resulting autoload file. -sb | |
655 | |
656 ;; --[[text/plain; charset=ISO-2022-JP]] | |
657 ;; これは charset を ISO-2022-JP に指定した日本語の plain テキス | |
658 ;; トです. | |
659 | |
660 | |
653 ;;;###autoload | 661 ;;;###autoload |
654 (defun mime/editor-mode () | 662 (defun mime/editor-mode () |
655 "MIME minor mode for editing the tagged MIME message. | 663 "MIME minor mode for editing the tagged MIME message. |
656 | 664 |
657 In this mode, basically, the message is composed in the tagged MIME | 665 In this mode, basically, the message is composed in the tagged MIME |
658 format. The message tag looks like: | 666 format. The message tag looks like: |
659 | 667 |
660 `--[[text/plain; charset=ISO-2022-JP][7bit]]'. | 668 --[[text/plain; charset=ISO-2022-JP][7bit]] |
661 | 669 |
662 The tag specifies the MIME content type, subtype, optional parameters | 670 The tag specifies the MIME content type, subtype, optional parameters |
663 and transfer encoding of the message following the tag. Messages | 671 and transfer encoding of the message following the tag. Messages |
664 without any tag are treated as `text/plain' by default. Charset and | 672 without any tag are treated as `text/plain' by default. Charset and |
665 transfer encoding are automatically defined unless explicitly | 673 transfer encoding are automatically defined unless explicitly |
695 coding-system is different as MIME charset, please set variable | 703 coding-system is different as MIME charset, please set variable |
696 `mime-charset-coding-system-alist'. This variable must be alist of | 704 `mime-charset-coding-system-alist'. This variable must be alist of |
697 which key is MIME charset and value is coding-system. | 705 which key is MIME charset and value is coding-system. |
698 | 706 |
699 Following commands are available in addition to major mode commands: | 707 Following commands are available in addition to major mode commands: |
708 | |
709 \[make single part\] | |
700 \\[mime-editor/insert-text] insert a text message. | 710 \\[mime-editor/insert-text] insert a text message. |
701 \\[mime-editor/insert-file] insert a (binary) file. | 711 \\[mime-editor/insert-file] insert a (binary) file. |
702 \\[mime-editor/insert-external] insert a reference to external body. | 712 \\[mime-editor/insert-external] insert a reference to external body. |
703 \\[mime-editor/insert-voice] insert a voice message. | 713 \\[mime-editor/insert-voice] insert a voice message. |
704 \\[mime-editor/insert-message] insert a mail or news message. | 714 \\[mime-editor/insert-message] insert a mail or news message. |
705 \\[mime-editor/insert-mail] insert a mail message. | 715 \\[mime-editor/insert-mail] insert a mail message. |
706 \\[mime-editor/insert-signature] insert a signature file at end. | 716 \\[mime-editor/insert-signature] insert a signature file at end. |
717 \\[mime-editor/insert-key] insert PGP public key. | |
707 \\[mime-editor/insert-tag] insert a new MIME tag. | 718 \\[mime-editor/insert-tag] insert a new MIME tag. |
719 | |
720 \[make enclosure (maybe multipart)\] | |
708 \\[mime-editor/enclose-alternative-region] enclose as multipart/alternative. | 721 \\[mime-editor/enclose-alternative-region] enclose as multipart/alternative. |
709 \\[mime-editor/enclose-parallel-region] enclose as multipart/parallel. | 722 \\[mime-editor/enclose-parallel-region] enclose as multipart/parallel. |
710 \\[mime-editor/enclose-mixed-region] enclose as multipart/mixed. | 723 \\[mime-editor/enclose-mixed-region] enclose as multipart/mixed. |
711 \\[mime-editor/enclose-digest-region] enclose as multipart/digest. | 724 \\[mime-editor/enclose-digest-region] enclose as multipart/digest. |
712 \\[mime-editor/enclose-signed-region] enclose as PGP signed. | 725 \\[mime-editor/enclose-signed-region] enclose as PGP signed. |
713 \\[mime-editor/enclose-encrypted-region] enclose as PGP encrypted. | 726 \\[mime-editor/enclose-encrypted-region] enclose as PGP encrypted. |
714 \\[mime-editor/insert-key] insert PGP public key. | 727 \\[mime-editor/enclose-quote-region] enclose as verbose mode (to avoid to expand tags) |
728 | |
729 \[other commands\] | |
730 \\[mime-editor/set-transfer-level-7bit] set transfer-level as 7. | |
731 \\[mime-editor/set-transfer-level-8bit] set transfer-level as 8. | |
732 \\[mime-editor/set-split] set message splitting mode. | |
733 \\[mime-editor/set-sign] set PGP-sign mode. | |
734 \\[mime-editor/set-encrypt] set PGP-encryption mode. | |
715 \\[mime-editor/preview-message] preview editing MIME message. | 735 \\[mime-editor/preview-message] preview editing MIME message. |
716 \\[mime-editor/exit] exit and translate into a MIME compliant message. | 736 \\[mime-editor/exit] exit and translate into a MIME compliant message. |
737 \\[mime-editor/help] show this help. | |
717 \\[mime-editor/maybe-translate] exit and translate if in MIME mode, then split. | 738 \\[mime-editor/maybe-translate] exit and translate if in MIME mode, then split. |
718 \\[mime-editor/help] show this help. | |
719 | 739 |
720 Additional commands are available in some major modes: | 740 Additional commands are available in some major modes: |
721 C-c C-c exit, translate and run the original command. | 741 C-c C-c exit, translate and run the original command. |
722 C-c C-s exit, translate and run the original command. | 742 C-c C-s exit, translate and run the original command. |
723 | 743 |
727 This is a conventional plain text. It should be translated | 747 This is a conventional plain text. It should be translated |
728 into text/plain. | 748 into text/plain. |
729 --[[text/plain]] | 749 --[[text/plain]] |
730 This is also a plain text. But, it is explicitly specified as | 750 This is also a plain text. But, it is explicitly specified as |
731 is. | 751 is. |
732 --[[text/plain; charset=ISO-2022-JP]] | |
733 これは charset を ISO-2022-JP に指定した日本語の plain テキス | |
734 トです. | |
735 --[[text/richtext]] | 752 --[[text/richtext]] |
736 <center>This is a richtext.</center> | 753 <center>This is a richtext.</center> |
737 --[[image/gif][base64]]^M...image encoded in base64 here... | 754 --[[image/gif][base64]]^M...image encoded in base64 here... |
738 --[[audio/basic][base64]]^M...audio encoded in base64 here... | 755 --[[audio/basic][base64]]^M...audio encoded in base64 here... |
739 | 756 |
745 Preceding white spaces in a message body are ignored if non-nil. | 762 Preceding white spaces in a message body are ignored if non-nil. |
746 | 763 |
747 mime-ignore-trailing-spaces | 764 mime-ignore-trailing-spaces |
748 Trailing white spaces in a message body are ignored if non-nil. | 765 Trailing white spaces in a message body are ignored if non-nil. |
749 | 766 |
750 mime-auto-fill-header | |
751 Fill header fields that contain encoded-words if non-nil. | |
752 | |
753 mime-auto-hide-body | 767 mime-auto-hide-body |
754 Hide a non-textual body message encoded in base64 after insertion | 768 Hide a non-textual body message encoded in base64 after insertion |
755 if non-nil. | 769 if non-nil. |
770 | |
771 mime-editor/transfer-level | |
772 A number of network transfer level. It should be bigger than 7. | |
773 If you are in 8bit-through environment, please set 8. | |
756 | 774 |
757 mime-editor/voice-recorder | 775 mime-editor/voice-recorder |
758 Specifies a function to record a voice message and encode it. | 776 Specifies a function to record a voice message and encode it. |
759 The function `mime-editor/voice-recorder-for-sun' is for Sun | 777 The function `mime-editor/voice-recorder-for-sun' is for Sun |
760 SparcStations. | 778 SparcStations. |
881 (enriched-mode t) | 899 (enriched-mode t) |
882 (if (boundp 'enriched-mode) | 900 (if (boundp 'enriched-mode) |
883 (enriched-mode nil) | 901 (enriched-mode nil) |
884 )))))) | 902 )))))) |
885 | 903 |
886 (defun mime-editor/insert-file (file) | 904 (defun mime-editor/insert-file (file &optional verbose) |
887 "Insert a message from a file." | 905 "Insert a message from a file." |
888 (interactive "fInsert file as MIME message: ") | 906 (interactive "fInsert file as MIME message: \nP") |
889 (let* ((guess (mime-find-file-type file)) | 907 (let* ((guess (mime-find-file-type file)) |
890 (pritype (nth 0 guess)) | 908 (type (nth 0 guess)) |
891 (subtype (nth 1 guess)) | 909 (subtype (nth 1 guess)) |
892 (parameters (nth 2 guess)) | 910 (parameters (nth 2 guess)) |
893 (default (nth 3 guess)) ;Guess encoding from its file name. | 911 (encoding (nth 3 guess)) |
894 (disposition-type (nth 4 guess)) | 912 (disposition-type (nth 4 guess)) |
895 (disposition-params (nth 5 guess)) | 913 (disposition-params (nth 5 guess)) |
896 (encoding | 914 ) |
897 (if (not (interactive-p)) | 915 (if verbose |
898 default | 916 (setq type (mime-prompt-for-type type) |
899 (completing-read | 917 subtype (mime-prompt-for-subtype type subtype) |
900 (concat "What transfer encoding" | 918 )) |
901 (if default | 919 (if (or (interactive-p) verbose) |
902 (concat " (default " | 920 (setq encoding (mime-prompt-for-encoding encoding)) |
903 (if (string-equal default "") | 921 ) |
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)) | 922 (if (or (consp parameters) (stringp disposition-type)) |
913 (let ((rest parameters) cell attribute value) | 923 (let ((rest parameters) cell attribute value) |
914 (setq parameters "") | 924 (setq parameters "") |
915 (while rest | 925 (while rest |
916 (setq cell (car rest)) | 926 (setq cell (car rest)) |
941 (concat parameters "; " attribute "=" value)) | 951 (concat parameters "; " attribute "=" value)) |
942 (setq rest (cdr rest)) | 952 (setq rest (cdr rest)) |
943 ) | 953 ) |
944 )) | 954 )) |
945 )) | 955 )) |
946 (mime-editor/insert-tag pritype subtype parameters) | 956 (mime-editor/insert-tag type subtype parameters) |
947 (mime-editor/insert-binary-file file encoding) | 957 (mime-editor/insert-binary-file file encoding) |
948 )) | 958 )) |
949 | 959 |
950 (defun mime-editor/insert-external () | 960 (defun mime-editor/insert-external () |
951 "Insert a reference to external body." | 961 "Insert a reference to external body." |
1294 (setq guess (cdr (car guesses)))) | 1304 (setq guess (cdr (car guesses)))) |
1295 (setq guesses (cdr guesses))) | 1305 (setq guesses (cdr guesses))) |
1296 guess | 1306 guess |
1297 )) | 1307 )) |
1298 | 1308 |
1299 (defun mime-prompt-for-type () | 1309 (defun mime-prompt-for-type (&optional default) |
1300 "Ask for Content-type." | 1310 "Ask for Content-type." |
1301 (let ((type "")) | 1311 (let ((type "")) |
1302 ;; Repeat until primary content type is specified. | 1312 ;; Repeat until primary content type is specified. |
1303 (while (string-equal type "") | 1313 (while (string-equal type "") |
1304 (setq type | 1314 (setq type |
1305 (completing-read "What content type: " | 1315 (completing-read "What content type: " |
1306 mime-content-types | 1316 mime-content-types |
1307 nil | 1317 nil |
1308 'require-match ;Type must be specified. | 1318 'require-match ;Type must be specified. |
1309 nil | 1319 default |
1310 )) | 1320 )) |
1311 (if (string-equal type "") | 1321 (if (string-equal type "") |
1312 (progn | 1322 (progn |
1313 (message "Content type is required.") | 1323 (message "Content type is required.") |
1314 (beep) | 1324 (beep) |
1315 (sit-for 1) | 1325 (sit-for 1) |
1316 )) | 1326 )) |
1317 ) | 1327 ) |
1318 type | 1328 type)) |
1319 )) | 1329 |
1320 | 1330 (defun mime-prompt-for-subtype (type &optional default) |
1321 (defun mime-prompt-for-subtype (pritype) | 1331 "Ask for subtype of media-type TYPE." |
1322 "Ask for Content-type subtype of Content-Type PRITYPE." | 1332 (let ((subtypes (cdr (assoc type mime-content-types)))) |
1323 (let* ((default (car (car (cdr (assoc pritype mime-content-types))))) | 1333 (or (and default |
1324 (answer | 1334 (assoc default subtypes)) |
1335 (setq default (car (car subtypes))) | |
1336 )) | |
1337 (let* ((answer | |
1325 (completing-read | 1338 (completing-read |
1326 (if default | 1339 (if default |
1327 (concat | 1340 (concat |
1328 "What content subtype: (default " default ") ") | 1341 "What content subtype: (default " default ") ") |
1329 "What content subtype: ") | 1342 "What content subtype: ") |
1330 (cdr (assoc pritype mime-content-types)) | 1343 (cdr (assoc type mime-content-types)) |
1331 nil | 1344 nil |
1332 'require-match ;Subtype must be specified. | 1345 'require-match ;Subtype must be specified. |
1333 nil | 1346 nil |
1334 ))) | 1347 ))) |
1335 (if (string-equal answer "") default answer))) | 1348 (if (string-equal answer "") default answer))) |
1388 (if (string-match mime-tspecials-regexp answer) | 1401 (if (string-match mime-tspecials-regexp answer) |
1389 (concat "\"" answer "\"") answer))) | 1402 (concat "\"" answer "\"") answer))) |
1390 (mime-prompt-for-parameters-1 (cdr (assoc answer (cdr parameter))))) | 1403 (mime-prompt-for-parameters-1 (cdr (assoc answer (cdr parameter))))) |
1391 )) | 1404 )) |
1392 | 1405 |
1393 (defun mime-flag-region (from to flag) | 1406 (defun mime-prompt-for-encoding (default) |
1394 "Hides or shows lines from FROM to TO, according to FLAG. | 1407 "Ask for Content-Transfer-Encoding. [tm-edit.el]" |
1395 If FLAG is `\\n' (newline character) then text is shown, | 1408 (let (encoding) |
1396 while if FLAG is `\\^M' (control-M) the text is hidden." | 1409 (while (string= |
1397 (let ((buffer-read-only nil) ;Okay even if write protected. | 1410 (setq encoding |
1398 (modp (buffer-modified-p))) | 1411 (completing-read |
1399 (unwind-protect | 1412 "What transfer encoding: " |
1400 (subst-char-in-region from to | 1413 mime-file-encoding-method-alist nil t default) |
1401 (if (= flag ?\n) ?\^M ?\n) | 1414 ) |
1402 flag t) | 1415 "")) |
1403 (set-buffer-modified-p modp)))) | 1416 encoding)) |
1404 | 1417 |
1405 | 1418 |
1406 ;;; @ Translate the tagged MIME messages into a MIME compliant message. | 1419 ;;; @ Translate the tagged MIME messages into a MIME compliant message. |
1407 ;;; | 1420 ;;; |
1408 | 1421 |