From: hayashi Date: Fri, 13 Oct 2000 05:39:22 +0000 (+0000) Subject: * mime-edit.el (mime-edit-force-text-tag): New macro. X-Git-Tag: emy-1_13_9~1 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=957328ebbc667deae8c53feb0baa9e0162938e2a;p=elisp%2Fsemi.git * mime-edit.el (mime-edit-force-text-tag): New macro. * mime-edit.el (mime-edit-insert-text-file): * mime-edit.el (mime-edit-insert-external): * mime-edit.el (mime-edit-insert-binary-string): * mime-edit.el (mime-edit-insert-binary-file): * mime-edit.el (mime-edit-process-multipart-1): * mime-edit.el (mime-edit-normalize-body): * mime-edit.el (mime-edit-enclose-region-internal): * mime-edit.el (mime-edit-insert-key): Use mime-edit-force-text-tag. --- diff --git a/ChangeLog b/ChangeLog index b741067..5f821fc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +2000-10-13 Yoshiki Hayashi + + * mime-edit.el (mime-edit-force-text-tag): New macro. + * mime-edit.el (mime-edit-insert-text-file): + * mime-edit.el (mime-edit-insert-external): + * mime-edit.el (mime-edit-insert-binary-string): + * mime-edit.el (mime-edit-insert-binary-file): + * mime-edit.el (mime-edit-process-multipart-1): + * mime-edit.el (mime-edit-normalize-body): + * mime-edit.el (mime-edit-enclose-region-internal): + * mime-edit.el (mime-edit-insert-key): Use mime-edit-force-text-tag. + +2000-10-12 Yoshiki Hayashi + + * mime-edit.el (mime-edit-insert-insert-binary-string): Don't + make a blank only part. + (mime-edit-insert-binary-file): Ditto. + (mime-edit-insert-text-file): Ditto. + 2000-10-10 Yoshiki Hayashi * mime-edit.el (mime-edit-insert-place): Barf if on invisible region. diff --git a/mime-edit.el b/mime-edit.el index 8e60b9b..0534b88 100644 --- a/mime-edit.el +++ b/mime-edit.el @@ -825,6 +825,12 @@ Tspecials means any character that matches with it in header must be quoted.") (goto-char (point-max))) ,@ body)) +(defmacro mime-edit-force-text-tag (regexp) + `(cond ((looking-at (concat "\n*\\(" ,regexp "\\)")) + (replace-match "\\1")) + ((not (eobp)) + (insert (mime-make-text-tag) "\n")))) + ;;; @ functions ;;; @@ -1130,9 +1136,7 @@ If optional argument SUBTYPE is not nil, text/SUBTYPE tag is inserted." (save-excursion (let ((ret (insert-file-contents file))) (forward-char (cadr ret)) - (if (and (not (eobp)) - (not (looking-at mime-edit-single-part-tag-regexp))) - (insert (mime-make-text-tag) "\n"))))))) + (mime-edit-force-text-tag mime-edit-single-part-regexp)))))) (defun mime-edit-insert-file (file &optional verbose) "Insert a message from a FILE. @@ -1238,9 +1242,7 @@ Content-Transfer-Encoding and Content-Disposition headers." subtype (insert "Content-Type: " pritype "/" subtype (or parameters "") "\n")) - (if (and (not (eobp)) - (not (looking-at mime-edit-single-part-tag-regexp))) - (insert (mime-make-text-tag) "\n"))))) + (mime-edit-force-text-tag mime-edit-single-part-tag-regexp)))) (defun mime-edit-insert-voice () "Insert a voice message." @@ -1359,10 +1361,7 @@ Optional argument ENCODING specifies an encoding method such as base64." (invisible-region (point-min) (point-max)) (goto-char (point-max))) (goto-char (point-max)))) - (unless (or (looking-at mime-edit-tag-regexp) - (= (point)(point-max))) - (insert "\n") - (mime-edit-insert-tag "text" "plain")) + (mime-edit-force-text-tag mime-edit-tag-regexp) ;; Define encoding even if it is 7bit. (if (stringp encoding) (save-excursion @@ -1388,10 +1387,7 @@ Optional argument ENCODING specifies an encoding method such as base64." (invisible-region (point-min) (point-max)) (goto-char (point-max))) (goto-char (point-max)))) - (unless (or (looking-at mime-edit-tag-regexp) - (= (point)(point-max))) - (insert "\n") - (mime-edit-insert-tag "text" "plain")) + (mime-edit-force-text-tag mime-edit-tag-regexp) ;; Define encoding even if it is 7bit. (if (stringp encoding) (save-excursion @@ -1761,9 +1757,7 @@ Parameter must be '(PROMPT CHOICE1 (CHOISE2 ...))." (let ((beg (match-beginning 0)) (end (match-end 0))) (delete-region beg end) - (or (looking-at mime-edit-beginning-tag-regexp) - (eobp) - (insert (concat (mime-make-text-tag) "\n"))))) + (mime-edit-force-text-tag mime-edit-beginning-tag-regxp))) (cond ((string-equal type "quote") (mime-edit-enquote-region bb eb)) ((string-equal type "pgp-signed") @@ -2211,9 +2205,7 @@ Content-Description: S/MIME Encrypted Message][base64]]\n") (if (= end (point-max)) nil (goto-char end) - (or (looking-at mime-edit-beginning-tag-regexp) - (eobp) - (insert (mime-make-text-tag) "\n"))) + (mime-edit-force-text-tag mime-edit-beginning-tag-regexp)) (visible-region beg end) (goto-char beg)) (cond @@ -2386,9 +2378,7 @@ and insert data encoded as ENCODING." (goto-char (point-max)) (insert (format "--}-<<%s>>\n" type)) (goto-char (point-max))) - (or (looking-at mime-edit-beginning-tag-regexp) - (eobp) - (insert (mime-make-text-tag) "\n")))) + (mime-edit-force-text-tag mime-edit-beginning-tag-regexp))) (defun mime-edit-enclose-quote-region (beg end) (interactive "*r") @@ -2440,9 +2430,7 @@ and insert data encoded as ENCODING." (mime-edit-insert-tag "application" "pgp-keys") (mime-edit-define-encoding "7bit") (pgg-insert-key) - (if (and (not (eobp)) - (not (looking-at mime-edit-single-part-tag-regexp))) - (insert (mime-make-text-tag) "\n"))) + (mime-edit-force-text-tag mime-edit-single-part-tag-regexp)) ;;; @ flag setting