update.
[elisp/semi.git] / mime-edit.el
index 439707a..c4f69d2 100644 (file)
@@ -1,16 +1,15 @@
 ;;; mime-edit.el --- Simple MIME Composer for GNU Emacs
 
-;; Copyright (C) 1993,1994,1995,1996,1997 Free Software Foundation, Inc.
+;; Copyright (C) 1993,1994,1995,1996,1997,1998 Free Software Foundation, Inc.
 
 ;; Author: UMEDA Masanobu <umerin@mse.kyutech.ac.jp>
 ;;         MORIOKA Tomohiko <morioka@jaist.ac.jp>
 ;; Maintainer: MORIOKA Tomohiko <morioka@jaist.ac.jp>
 ;; Created: 1994/08/21 renamed from mime.el
 ;;     Renamed: 1997/2/21 from tm-edit.el
-;; Version: $Revision: 0.100 $
 ;; Keywords: MIME, multimedia, multilingual, mail, news
 
-;; This file is part of SEMI (SEMI is Emacs MIME Interfaces).
+;; This file is part of SEMI (Sophisticated Emacs MIME Interfaces).
 
 ;; This program is free software; you can redistribute it and/or
 ;; modify it under the terms of the GNU General Public License as
 ;;; @ version
 ;;;
 
-(defconst mime-edit-RCS-ID
-  "$Id: mime-edit.el,v 0.100 1998-02-06 00:39:23 morioka Exp $")
-
-(defconst mime-edit-version `,(get-version-string mime-edit-RCS-ID))
-
-(defconst mime-edit-version-name
-  `,(concat "SEMI MIME-Edit " mime-edit-version
-           " - \"" semi-version-name "\""))
+(defconst mime-edit-version-string
+  `,(concat (car mime-module-version) " "
+           (mapconcat #'number-to-string (cddr mime-module-version) ".")
+           " - \"" (cadr mime-module-version) "\""))
 
 
 ;;; @ variables
@@ -242,8 +237,18 @@ To insert a signature file automatically, call the function
     )
   "*Alist of content-type, subtype, parameters and its values.")
 
-(defvar mime-file-types
-  '(("\\.rtf$"
+(defcustom mime-file-types
+  '(("\\.txt$"
+     "text"    "plain"         nil
+     nil
+     "inline"          (("filename" . file))
+     )
+    ("\\.pln$"
+     "text"    "plain"         nil
+     nil
+     "inline"          (("filename" . file))
+     )
+    ("\\.rtf$"
      "text"    "richtext"      nil
      nil
      nil               nil)
@@ -367,15 +372,56 @@ To insert a signature file automatically, call the function
      "attachment"      (("filename" . file))
      )
     ("\\.signature"
-     "text"    "plain"         nil     nil)
+     "text"    "plain"         nil     nil     nil     nil)
     (".*"
      "application" "octet-stream" nil
      nil
-     "attachment"      (("filename" . file))
-     )
+     "attachment"      (("filename" . file)))
     )
   "*Alist of file name, types, parameters, and default encoding.
-If encoding is nil, it is determined from its contents.")
+If encoding is nil, it is determined from its contents."
+  :type `(repeat
+         (list regexp
+               ;; primary-type
+               (choice :tag "Primary-Type"
+                       ,@(nconc (mapcar (lambda (cell)
+                                          (list 'item (car cell))
+                                          )
+                                        mime-content-types)
+                                '(string)))
+               ;; subtype
+               (choice :tag "Sub-Type"
+                       ,@(nconc
+                          (apply #'nconc
+                                 (mapcar (lambda (cell)
+                                           (mapcar (lambda (cell)
+                                                     (list 'item (car cell))
+                                                     )
+                                                   (cdr cell)))
+                                         mime-content-types))
+                          '(string)))
+               ;; parameters
+               (repeat :tag "Parameters of Content-Type field"
+                       (cons string (choice string symbol)))
+               ;; content-transfer-encoding
+               (choice :tag "Encoding"
+                       ,@(cons
+                          '(const nil)
+                          (mapcar (lambda (cell)
+                                    (list 'item (car cell))
+                                    )
+                                  mime-file-encoding-method-alist)))
+               ;; disposition-type
+               (choice :tag "Disposition-Type"
+                       (item nil)
+                       (item "inline")
+                       (item "attachment")
+                       string)
+               ;; parameters
+               (repeat :tag "Parameters of Content-Disposition field"
+                       (cons string (choice string symbol)))
+               ))
+  :group 'mime-edit)
 
 
 ;;; @@ about charset, encoding and transfer-level
@@ -574,11 +620,11 @@ inserted into message header.")
 Tspecials means any character that matches with it in header must be quoted.")
 
 (defconst mime-edit-mime-version-value
-  (concat "1.0 (generated by " mime-edit-version-name ")")
+  (concat "1.0 (generated by " mime-edit-version-string ")")
   "MIME version number.")
 
 (defconst mime-edit-mime-version-field-for-message/partial
-  (concat "MIME-Version: 1.0 (split by " mime-edit-version-name ")\n")
+  (concat "MIME-Version: 1.0 (split by " mime-edit-version-string ")\n")
   "MIME version field for message/partial.")
 
 
@@ -965,26 +1011,27 @@ just return to previous mode."
     (princ (documentation 'mime-edit-mode))
     (print-help-return-message)))
 
-(defun mime-edit-insert-text ()
+(defun mime-edit-insert-text (&optional subtype)
   "Insert a text message.
-Charset is automatically obtained from the `charsets-mime-charset-alist'."
+Charset is automatically obtained from the `charsets-mime-charset-alist'.
+If optional argument SUBTYPE is not nil, text/SUBTYPE tag is inserted."
   (interactive)
-  (let ((ret (mime-edit-insert-tag "text" nil nil)))
-  (if ret
-      (progn
-       (if (looking-at mime-edit-single-part-tag-regexp)
-           (progn
-             ;; Make a space between the following message.
-             (insert "\n")
-             (forward-char -1)
-             ))
-       (if (and (member (cadr ret) '("enriched" "richtext"))
-                (fboundp 'enriched-mode)
-                )
-           (enriched-mode t)
-         (if (boundp 'enriched-mode)
-             (enriched-mode -1)
-           ))))))
+  (let ((ret (mime-edit-insert-tag "text" subtype nil)))
+    (when ret
+      (if (looking-at mime-edit-single-part-tag-regexp)
+         (progn
+           ;; Make a space between the following message.
+           (insert "\n")
+           (forward-char -1)
+           ))
+      (if (and (member (cadr ret) '("enriched" "richtext"))
+              (fboundp 'enriched-mode)
+              )
+         (enriched-mode t)
+       (if (boundp 'enriched-mode)
+           (enriched-mode -1)
+         ))
+      )))
 
 (defun mime-edit-insert-file (file &optional verbose)
   "Insert a message from a file."
@@ -1085,8 +1132,9 @@ Charset is automatically obtained from the `charsets-mime-charset-alist'."
   (let ((signature-insert-hook
          (function
           (lambda ()
-            (apply (function mime-edit-insert-tag)
-                   (mime-find-file-type signature-file-name))
+           (let ((items (mime-find-file-type signature-file-name)))
+             (apply (function mime-edit-insert-tag)
+                    (car items) (cadr items) (list (caddr items))))
             )))
         )
     (insert-signature arg)
@@ -2485,17 +2533,16 @@ Content-Type: message/partial; id=%s; number=%d; total=%d\n%s\n"
   "Quitting method for mime-view."
   (let ((temp mime-raw-buffer)
        buf)
-    (mime-view-kill-buffer)
+    (mime-preview-kill-buffer)
     (set-buffer temp)
     (setq buf mime-edit-buffer)
     (kill-buffer temp)
     (switch-to-buffer buf)
     ))
 
-(set-alist 'mime-view-quitting-method-alist
+(set-alist 'mime-preview-quitting-method-alist
           'mime-temp-message-mode
-          (function mime-edit-quitting-method)
-          )
+          #'mime-edit-quitting-method)
 
 
 ;;; @ edit again