From: hayashi Date: Mon, 31 Jan 2000 06:51:11 +0000 (+0000) Subject: * mime-view.el (mime-display-entity): Clean up code. X-Git-Tag: emy-1_13_1 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2d0d383d18e7984ea063c06797f2c8833ca489cf;p=elisp%2Fsemi.git * mime-view.el (mime-display-entity): Clean up code. * mime-play.el (mime-save-content-for-broken-message): New function. --- diff --git a/ChangeLog b/ChangeLog index 830d996..a8753e4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,23 @@ +2000-01-31 Yoshiki Hayashi + + * EMY 1.13.1 is released. + +2000-01-31 Yoshiki Hayashi + + * emy.texi: Describe how to deal with broken message. + +2000-01-31 Yoshiki Hayashi + + * mime-play.el (mime-save-content-for-broken-message): New function. + +2000-01-28 Yoshiki Hayashi + + * mime-view.el (mime-display-entity): Clean up code. + 2000-01-28 Yoshiki Hayashi * mime-view.el (mime-display-entity): Fix handling of - inline Content-Disposition. + inline parameter of Content-Disposition. 2000-01-20 Yoshiki Hayashi diff --git a/Makefile b/Makefile index 7f24328..108695c 100644 --- a/Makefile +++ b/Makefile @@ -21,11 +21,12 @@ LISPDIR = NONE PACKAGEDIR = NONE VERSION_SPECIFIC_LISPDIR = NONE -GOMI = *.elc +GOMI = *.elc *.info VERSION = $(API).$(RELEASE) ARC_DIR = /pub/mule/semi/semi-$(API)-for-flim-$(FLIM_API) +all: elc elc: $(EMACS) $(FLAGS) -f compile-semi \ @@ -45,6 +46,9 @@ install-package: package $(XEMACS) $(FLAGS) -f install-semi-package $(PACKAGEDIR) +info: + makeinfo -o emy.info emy.texi + clean: -$(RM) $(GOMI) diff --git a/emy.texi b/emy.texi index ef2e65c..8dc36fe 100644 --- a/emy.texi +++ b/emy.texi @@ -1,6 +1,6 @@ \input texinfo.tex @c -*- texinfo -*- -@setfilename emy +@setfilename emy.info @set VERSION 1.13 @@ -142,9 +142,10 @@ try persuading me. Warning: `It's de facto standard' is not enough. Right now only differences between SEMI and EMY are documented. @menu -* Manipulating an Entity:: Changing representation of the part +* Manipulating an Entity:: Changing representation of the part * Changing Entity Button:: Where to add button indicating that entity. * Adding Buttons:: Where you want to see buttons. +* How to deal with broken MUA:: Some MUA sends totally broken messages. @end menu @node Manipulating an Entity @@ -256,8 +257,99 @@ Default value is: This means you will have buttons around message/* and multipart/alternative, and before application/*. +@node How to deal with broken MUA +@section Illegal MIME messages + +Some MUAs send totally broken MIME messages. According to the standard, +it's perfectly fine for EMY not to grok those message. However, EMY +tries to extract as much information as possible. Here's some functions +that might help you. + +Some MUAs localized to Japanese sends these strings as a filename +parameter of Content-Disposition. + +@example +=?ISO-2022-JP?B?GyRCRnxLXDhsGyhC?= +@end example + +It looks like encoded-words. This usage is strictly prohibited by RFC +2047. Instead, you should use mechanism described in RFC 2231. +If you really want to ``decode'' it when saving it to file, you can use +something like this. + +@lisp +(mime-add-condition + 'action + '((mode . "extract") + (method . mime-save-content-for-broken-message))) +@end lisp + +Unfortunately, there's no easy way to customize looking of buttons. +It's on EMY's TODO list. + +If you are desperate, you can redefine +@code{mime-view-insert-entity-button}. + +@lisp +(defun mime-view-insert-entity-button (entity &optional body-is-invisible) + "Insert entity-button of ENTITY." + (let ((entity-node-id (mime-entity-node-id entity)) + (params (mime-entity-parameters entity)) + (subject (eword-decode-string (mime-view-entity-title entity)))) + (mime-insert-button + (concat + (let ((access-type (assoc "access-type" params)) + (num (or (cdr (assoc "x-part-number" params)) + (if (consp entity-node-id) + (mapconcat (function + (lambda (num) + (format "%s" (1+ num)))) + (reverse entity-node-id) ".") + "0")))) + (cond (access-type + (let ((server (assoc "server" params))) + (setq access-type (cdr access-type)) + (if server + (format "%s %s ([%s] %s)" + num subject access-type (cdr server)) + (let ((site (cdr (assoc "site" params))) + (dir (cdr (assoc "directory" params))) + (url (cdr (assoc "url" params)))) + (if url + (format "%s %s ([%s] %s)" + num subject access-type url) + (format "%s %s ([%s] %s:%s)" + num subject access-type site dir)))))) + (t + (let ((media-type (mime-entity-media-type entity)) + (media-subtype (mime-entity-media-subtype entity)) + (charset (cdr (assoc "charset" params))) + (encoding (mime-entity-encoding entity))) + (concat + num " " subject + (let ((rest + (format " <%s/%s%s%s>" + media-type media-subtype + (if charset + (concat "; " charset) + "") + (if encoding + (concat " (" encoding ")") + "")))) + (if (>= (+ (current-column)(length rest))(window-width)) + "\n\t") + rest)))))) + (if body-is-invisible + " ..." + "")) + (function mime-preview-play-current-entity)))) +@end lisp + +@strong{Note:} These settings are unsupported until better way is +implemented. + @node MIME-Edit -@chapter Composing MIME messages. +@chapter Composing MIME messages @vindex mime-edit-attach-at-end-type (MIME-Edit) When you are editing MIME message, you might want to insert some part at diff --git a/mime-play.el b/mime-play.el index b98ccea..1e7e35b 100644 --- a/mime-play.el +++ b/mime-play.el @@ -29,6 +29,7 @@ (require 'mime-view) (require 'alist) (require 'filename) +(require 'eword-decode) (eval-when-compile (condition-case nil @@ -484,9 +485,30 @@ window.") (if (file-exists-p filename) (or (yes-or-no-p (format "File %s exists. Save anyway? " filename)) (error ""))) - (mime-write-entity-content entity (expand-file-name filename)) - )) + (mime-write-entity-content entity (expand-file-name filename)))) +(defun mime-save-content-for-broken-message (entity situation) + (let ((name (or (and (mime-entity-filename entity) + (eword-decode-string + (mime-entity-filename entity))) + (format "%s" (mime-entity-media-type entity)))) + (dir (if (eq t mime-save-directory) + default-directory + mime-save-directory)) + filename) + (setq filename (read-file-name + (concat "File name: (default " + (file-name-nondirectory name) ") ") + dir + (concat (file-name-as-directory dir) + (file-name-nondirectory name)))) + (if (file-directory-p filename) + (setq filename (concat (file-name-as-directory filename) + (file-name-nondirectory name)))) + (if (file-exists-p filename) + (or (yes-or-no-p (format "File %s exists. Save anyway? " filename)) + (error ""))) + (mime-write-entity-content entity (expand-file-name filename)))) ;;; @ file detection ;;; diff --git a/mime-view.el b/mime-view.el index 8f1d67c..6539c65 100644 --- a/mime-view.el +++ b/mime-view.el @@ -315,7 +315,7 @@ mother-buffer." ;;; @@@ predicate function ;;; -;; fix flim +;; #### fix flim (defun mime-view-entity-type/subtype (entity) (if (not (mime-entity-media-type entity)) 'text/plain @@ -344,7 +344,7 @@ You can customize the visibility by changing `mime-view-button-place-alist'." ;; When previous entity exists (and prev-entity (or - ;; Check previous eneity + ;; Check previous entity ;; type/subtype (memq (cdr (assq @@ -373,11 +373,9 @@ You can customize the visibility by changing `mime-view-button-place-alist'." (if (consp entity-node-id) (mapconcat (function (lambda (num) - (format "%s" (1+ num)) - )) + (format "%s" (1+ num)))) (reverse entity-node-id) ".") - "0")) - )) + "0")))) (cond (access-type (let ((server (assoc "server" params))) (setq access-type (cdr access-type)) @@ -386,15 +384,12 @@ You can customize the visibility by changing `mime-view-button-place-alist'." num subject access-type (cdr server)) (let ((site (cdr (assoc "site" params))) (dir (cdr (assoc "directory" params))) - (url (cdr (assoc "url" params))) - ) + (url (cdr (assoc "url" params)))) (if url (format "%s %s ([%s] %s)" num subject access-type url) (format "%s %s ([%s] %s:%s)" - num subject access-type site dir)) - ))) - ) + num subject access-type site dir)))))) (t (let ((media-type (mime-entity-media-type entity)) (media-subtype (mime-entity-media-subtype entity)) @@ -413,13 +408,11 @@ You can customize the visibility by changing `mime-view-button-place-alist'." "")))) (if (>= (+ (current-column)(length rest))(window-width)) "\n\t") - rest))) - ))) + rest)))))) (if body-is-invisible " ..." "")) - (function mime-preview-play-current-entity)) - )) + (function mime-preview-play-current-entity)))) ;;; @@ entity-header @@ -1110,21 +1103,19 @@ With prefix, it prompts for coding-system." (children (mime-entity-children entity))) ;; Check if attachment is specified. ;; if inline is forced or not. - (if (not (or (eq t mime-view-force-inline-types) - (memq (mime-entity-media-type entity) - mime-view-force-inline-types) - (memq (mime-view-entity-type/subtype entity) + (unless (or (eq t mime-view-force-inline-types) + (memq (mime-entity-media-type entity) + mime-view-force-inline-types) + (memq (mime-view-entity-type/subtype entity) mime-view-force-inline-types) ;; whether Content-Disposition header exists. - ;; #### FIXME. This is way too ugly. - (not (and - (mime-entity-content-disposition entity) - (not (eq 'inline - (mime-content-disposition-type - (mime-entity-content-disposition entity)))))))) - ;; This is attachment - (setq header-is-visible nil - body-is-visible nil)) + (not (mime-entity-content-disposition entity)) + (eq 'inline + (mime-content-disposition-type + (mime-entity-content-disposition entity)))) + ;; This is attachment + (setq header-is-visible nil + body-is-visible nil)) (set-buffer preview-buffer) (setq nb (point)) (save-restriction diff --git a/semi-def.el b/semi-def.el index f17ae71..2f35c2d 100644 --- a/semi-def.el +++ b/semi-def.el @@ -30,7 +30,7 @@ (require 'custom) -(defconst mime-user-interface-product ["EMY" (1 13 0) "No pain no gain"] +(defconst mime-user-interface-product ["EMY" (1 13 1) "Haste makes waste"] "Product name, version number and code name of MIME-kernel package.") (autoload 'mule-caesar-region "mule-caesar"