;;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
;;; Maintainer: MORIOKA Tomohiko <morioka@jaist.ac.jp>
;;; Created: 1994/08/21 renamed from mime.el
-;;; Version: $Revision: 7.49 $
+;;; Version: $Revision: 7.52 $
;;; Keywords: mail, news, MIME, multimedia, multilingual
;;;
;;; This file is part of tm (Tools for MIME).
;;;
(defconst mime-editor/RCS-ID
- "$Id: tm-edit.el,v 7.49 1996/04/11 00:39:12 morioka Exp $")
+ "$Id: tm-edit.el,v 7.52 1996/04/19 13:40:55 shuhei-k Exp $")
(defconst mime-editor/version (get-version-string mime-editor/RCS-ID))
;;; modified by Steven L. Baur <steve@miranova.com>
;;; 1995/12/6 (c.f. [tm-en:209])
-(if (and (string-match "XEmacs\\|Lucid" emacs-version)
- (not (boundp 'mime-editor/popup-menu-for-xemacs)))
+(if (and running-xemacs (not (boundp 'mime-editor/popup-menu-for-xemacs)))
(setq mime-editor/popup-menu-for-xemacs
(append '("MIME Commands" "---")
(mapcar (function (lambda (item)
(error "You are already editing a MIME message.")
(setq mime/editor-mode-flag t)
;; Remember old key bindings.
- (if (string-match "XEmacs\\|Lucid" emacs-version)
+ (if running-xemacs
nil
- (make-local-variable 'mime/editor-mode-old-local-map)
- (setq mime/editor-mode-old-local-map (current-local-map))
- ;; Add MIME commands to current local map.
- (use-local-map (copy-keymap (current-local-map))))
+ (make-local-variable 'mime/editor-mode-old-local-map)
+ (setq mime/editor-mode-old-local-map (current-local-map))
+ ;; Add MIME commands to current local map.
+ (use-local-map (copy-keymap (current-local-map)))
+ )
(if (not (lookup-key (current-local-map) mime-prefix))
(define-key (current-local-map) mime-prefix mime-editor/mime-map))
;; welcome.
;; modified by Pekka Marjola <pema@niksula.hut.fi>
;; 1995/9/5 (c.f. [tm-eng:69])
- (cond ((string-match "XEmacs\\|Lucid" emacs-version)
+ (cond (running-xemacs
(mime-editor/define-menu-for-xemacs))
((string-match "^19\\." emacs-version)
(mime-editor/define-menu-for-emacs19)
(mime-editor/translate-buffer)))
;; Restore previous state.
(setq mime/editor-mode-flag nil)
- (cond ((string-match "XEmacs\\|Lucid" emacs-version)
+ (cond (running-xemacs
;; mime-prefix only defined if binding was nil
(if (eq (lookup-key (current-local-map) mime-prefix)
mime-editor/mime-map)
(defun mime-editor/insert-signature (&optional arg)
"Insert a signature file specified by mime-signature-file."
(interactive "P")
- (let ((signature
- (expand-file-name
- (if arg
- (read-file-name "Insert your signature: "
- (concat signature-file-name "-")
- signature-file-name
- nil)
- (signature/get-signature-file-name))))
- )
- (if signature-insert-at-eof
- (goto-char (point-max))
- )
- (apply (function mime-editor/insert-tag)
- (mime-find-file-type signature))
- (if (file-readable-p signature)
- (progn
- (goto-char (point-max))
- (if (not (bolp))
- (insert "\n"))
- (delete-blank-lines)
- (insert-file-contents signature)
- (set-buffer-modified-p (buffer-modified-p))
- ; force mode line update
- ))))
+ (let ((signature-insert-hook
+ (function
+ (lambda ()
+ (apply (function mime-editor/insert-tag)
+ (mime-find-file-type signature))
+ )))
+ )
+ (insert-signature arg)
+ ))
\f
;; Insert a new tag around a point.
(mime-prompt-for-parameters-1 (cdr (assoc answer (cdr parameter)))))
))
-(defun mime-encode-string (encoding string)
- "Using ENCODING encode a STRING.
-If the STRING is too long, the encoded string may be broken into
-several lines."
- (save-excursion
- (set-buffer (get-buffer-create " *MIME encoding*"))
- (erase-buffer)
- (insert string)
- (mime-encode-region encoding (point-min) (point-max))
- (prog1
- (buffer-substring (point-min) (point-max))
- (kill-buffer (current-buffer)))))
-
-(defun mime-editor/encode-string (method string)
- "For given METHOD that is a cons of charset and encoding,
-encode a STRING. [tm-edit.el]"
- (let* ((charset (car method))
- (encoding (cdr method)))
- (setq string (mime/convert-string-from-emacs string charset))
- (cond ((stringp encoding)
- (mime-encode-string encoding string)
- )
- (t string)
- )))
-
(defun mime-flag-region (from to flag)
"Hides or shows lines from FROM to TO, according to FLAG.
If FLAG is `\\n' (newline character) then text is shown,
mime-editor/charset-default-encoding-alist)
))
(beg (mime-editor/content-beginning))
- (end (mime-editor/content-end))
- (body (buffer-substring beg end))
- (encoded (mime-editor/encode-string
- (cons charset encoding) body))
)
- (if (not (string-equal body encoded))
- (progn
- (goto-char beg)
- (delete-region beg end)
- (insert encoded)
- (goto-char beg)))
- (mime-editor/define-encoding encoding)))
+ (mime/code-convert-region-from-emacs
+ beg (mime-editor/content-end) charset)
+ (mime-encode-region encoding
+ beg (mime-editor/content-end))
+ (mime-editor/define-encoding encoding)))
(forward-line 1))
((null encoding) ;Encoding is not specified.
;; Application, image, audio, video, and any other
(beg (mime-editor/content-beginning))
(end (mime-editor/content-end))
(body (buffer-substring beg end))
- (encoded (mime-editor/encode-string
- (cons nil encoding) body))
- )
- (if (not (string-equal body encoded))
- (progn
- (goto-char beg)
- (delete-region beg end)
- (insert encoded)
- (goto-char beg)))
- (mime-editor/define-encoding encoding))
+ )
+ (mime-encode-region encoding beg end)
+ (mime-editor/define-encoding encoding))
(forward-line 1))
)
)))