From e79eb9f77304888f141f743f2057692304f44176 Mon Sep 17 00:00:00 2001 From: morioka Date: Thu, 21 May 1998 06:31:29 +0000 Subject: [PATCH] Sync up with remi-1_4_0_90. --- ChangeLog | 82 +++++++++++++++++++++++++++++ Makefile | 2 +- TODO | 43 +++++++++++++-- mime-parse.el | 64 +++++++++++++++-------- mime-play.el | 35 ++++++------- mime-view.el | 162 +++++++++++++++------------------------------------------ semi-def.el | 37 ++----------- 7 files changed, 227 insertions(+), 198 deletions(-) diff --git a/ChangeLog b/ChangeLog index f8fee8a..f94eb36 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,85 @@ +1998-05-19 MORIOKA Tomohiko + + * mime-play.el (mime-raw-dired-function): Don't refer + 'mime/use-multi-frame. + + * semi-def.el: Abolish variable 'mime/use-multi-frame. + + * semi-def.el (mime-insert-button): Merge arguments of two + 'insert. + + * semi-def.el: Abolish function 'get-version-string because it is + not used. + + * TODO (Don't use filter-model): New item. + + * TODO (Fix problem of dynamic configuration for + 'mime-acting-condition): Done. + + * TODO (Mother entity should modify preview-situation of + children): Done. + +1998-05-17 MORIOKA Tomohiko + + * mime-view.el (mime-view-setup-buffers): Use + 'mime-view-display-entity; abolish 'mime-view-display-message. + (mime-view-display-entity): fixed. + +1998-05-17 MORIOKA Tomohiko + + * mime-view.el (mime-view-display-message): fixed. + +1998-05-16 MORIOKA Tomohiko + + * mime-view.el (mime-raw-get-subject): Use + 'mime-content-disposition-filename. + + * mime-parse.el (mime-content-type-parameter): New function. + + * mime-parse.el (mime-content-disposition-parameter): New + function. + (mime-content-disposition-filename): New function. + +1998-05-16 MORIOKA Tomohiko + + * mime-play.el (mime-raw-get-original-filename): Abolish optional + argument 'encoding; modify for 'mime-raw-get-uu-filename. + + * mime-view.el (mime-raw-get-uu-filename): Change interface; don't + check encoding. + (mime-raw-get-subject): Change interface; new implementation. + +1998-05-15 MORIOKA Tomohiko + + * mime-view.el (mime-view-display-entity): fixed. + + * mime-parse.el (mime-parse-multipart): Change interface. + +1998-05-15 MORIOKA Tomohiko + + * mime-parse.el (make-mime-entity): Add 'content-disposition. + (mime-entity-content-disposition): New function. + (mime-parse-multipart): Modify for 'make-mime-entity. + (mime-parse-message): Modify for 'make-mime-entity. + +1998-05-15 MORIOKA Tomohiko + + * mime-play.el (mime-raw-play-entity): Don't use + 'mime-entity-media-type, 'mime-entity-media-subtype and + 'mime-entity-parameters. + +1998-05-15 MORIOKA Tomohiko + + * mime-view.el (mime-view-display-entity): Don't use + 'mime-entity-media-type, 'mime-entity-media-subtype and + 'mime-entity-parameters. + +1998-05-15 MORIOKA Tomohiko + + * mime-view.el (mime-view-display-message): Don't use + 'mime-entity-media-type, 'mime-entity-media-subtype and + 'mime-entity-parameters. + 1998-05-17 MORIOKA Tomohiko * mime-setup.el: Avoid warning message of byte-compiler. diff --git a/Makefile b/Makefile index 6b64388..c141eec 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ # Makefile for SEMI kernel. # -VERSION = 1.4.4 +VERSION = 1.4.5 PACKAGE = semi SHELL = /bin/sh diff --git a/TODO b/TODO index c7de264..c3cd0b1 100644 --- a/TODO +++ b/TODO @@ -3,13 +3,50 @@ * MIME-View -** Mother entity should modify preview-situation of children - ** Better implementation for multipart/alternative ** dynamic configuration for 'mime-preview-condition -** Fix problem of dynamic configuration for 'mime-acting-condition +** Don't use filter-model + + tomo (major developer of SEMI) and akr (major developer of +FLIM-FLAM) discussed about Emacs 20.3 problem related with SEMI and +FLIM. They found essential problem with Emacs 20.3 are: + + - Emacs 20.3 separates string-type to unibyte-string and + multibyte-string. Emacs 20.3 has enough APIs to treat them. + + - Buffer has mode about interpretation of contents. Each mode is + designed to save semantics as characters. Namely buffer contains + unibyte-characters or multibyte-characters. One buffer can not + contain both representations. + + - {decode|encode}-coding-{region|string} run in byte world. So it + is not harmonized with other API. + + - It seems easy to write code in one mode or one world + (unibyte-string or multibyte-string). However it seems not easy + to write inter-mode program, such as SEMI. + + - Byte <-> byte conversion, such as base64, quoted-printable, must + be run only with unibyte-mode. + + - Byte <-> character conversion, such as + {decode|encode}-coding-region, should not be defined in single + buffer. Instead of them, decoder should read from unibyte buffer + and output to multibyte buffer. Similarly, encoder should read + from multibyte buffer and output to unibyte buffer. + `insert-buffer-substring' like API may be suitable. Anyway Emacs + introduces multiple representations, so it should be redesigned + based on multiple representation world model. + + Anyway FLIM should introduce new APIs based on inter-representation +world model. Conventional APIs should be implemented based on new +APIs. + + SEMI should abolish filter model and introduce new methods to +display inline data. These methods should use new FLIM APIs based on +inter-representation world model. * MIME-Edit diff --git a/mime-parse.el b/mime-parse.el index f3e696c..2741a04 100644 --- a/mime-parse.el +++ b/mime-parse.el @@ -122,6 +122,10 @@ and return parsed it. Format of return value is as same as "Return primary-type of CONTENT-TYPE." (cddr content-type)) +(defsubst mime-content-type-parameter (content-type parameter) + "Return PARAMETER value of CONTENT-TYPE." + (cdr (assoc parameter (mime-content-type-parameters content-type)))) + ;;; @ Content-Disposition ;;; @@ -160,6 +164,14 @@ and return parsed it." "Return disposition-parameters of CONTENT-DISPOSITION." (cdr content-disposition)) +(defsubst mime-content-disposition-parameter (content-disposition parameter) + "Return PARAMETER value of CONTENT-DISPOSITION." + (cdr (assoc parameter (cdr content-disposition)))) + +(defsubst mime-content-disposition-filename (content-disposition) + "Return filename of CONTENT-DISPOSITION." + (mime-content-disposition-parameter content-disposition "filename")) + ;;; @ Content-Transfer-Encoding ;;; @@ -184,16 +196,18 @@ If is is not found, return DEFAULT-ENCODING." (defsubst make-mime-entity (node-id point-min point-max - content-type encoding children) + content-type content-disposition encoding + children) (vector node-id point-min point-max - content-type encoding children)) + content-type content-disposition encoding children)) -(defsubst mime-entity-node-id (entity-info) (aref entity-info 0)) -(defsubst mime-entity-point-min (entity-info) (aref entity-info 1)) -(defsubst mime-entity-point-max (entity-info) (aref entity-info 2)) -(defsubst mime-entity-content-type (entity-info) (aref entity-info 3)) -(defsubst mime-entity-encoding (entity-info) (aref entity-info 4)) -(defsubst mime-entity-children (entity-info) (aref entity-info 5)) +(defsubst mime-entity-node-id (entity) (aref entity 0)) +(defsubst mime-entity-point-min (entity) (aref entity 1)) +(defsubst mime-entity-point-max (entity) (aref entity 2)) +(defsubst mime-entity-content-type (entity) (aref entity 3)) +(defsubst mime-entity-content-disposition (entity) (aref entity 4)) +(defsubst mime-entity-encoding (entity) (aref entity 5)) +(defsubst mime-entity-children (entity) (aref entity 6)) (defsubst mime-entity-media-type (entity) (mime-content-type-primary-type (mime-entity-content-type entity))) @@ -205,9 +219,13 @@ If is is not found, return DEFAULT-ENCODING." (mime-type/subtype-string (mime-entity-media-type entity-info) (mime-entity-media-subtype entity-info))) -(defun mime-parse-multipart (boundary content-type encoding node-id) +(defun mime-parse-multipart (content-type content-disposition encoding node-id) (goto-char (point-min)) - (let* ((dash-boundary (concat "--" boundary)) + (let* ((dash-boundary + (concat "--" + (std11-strip-quoted-string + (cdr (assoc "boundary" + (mime-content-type-parameters content-type)))))) (delimiter (concat "\n" (regexp-quote dash-boundary))) (close-delimiter (concat delimiter "--[ \t]*$")) (beg (point-min)) @@ -249,7 +267,8 @@ If is is not found, return DEFAULT-ENCODING." (setq children (cons ret children)) ) (make-mime-entity node-id beg (point-max) - content-type encoding (nreverse children)) + content-type content-disposition encoding + (nreverse children)) )) (defun mime-parse-message (&optional default-ctl default-encoding node-id) @@ -258,21 +277,20 @@ DEFAULT-CTL is used when an entity does not have valid Content-Type field. Its format must be as same as return value of mime-{parse|read}-Content-Type." (let* ((content-type (or (mime-read-Content-Type) default-ctl)) - (encoding (mime-read-Content-Transfer-Encoding default-encoding)) - (boundary (assoc "boundary" - (mime-content-type-parameters content-type)))) - (cond (boundary - (setq boundary (std11-strip-quoted-string (cdr boundary))) - (mime-parse-multipart boundary content-type encoding node-id) + (content-disposition (mime-read-Content-Disposition)) + (primary-type (mime-content-type-primary-type content-type)) + (encoding (mime-read-Content-Transfer-Encoding default-encoding))) + (cond ((eq primary-type 'multipart) + (mime-parse-multipart content-type content-disposition encoding + node-id) ) - ((and (eq (mime-content-type-primary-type content-type) - 'message) + ((and (eq primary-type 'message) (memq (mime-content-type-subtype content-type) - '(rfc822 news)) - ) + '(rfc822 news) + )) (goto-char (point-min)) (make-mime-entity node-id (point-min) (point-max) - content-type encoding + content-type content-disposition encoding (save-restriction (narrow-to-region (if (re-search-forward "^$" nil t) @@ -286,7 +304,7 @@ mime-{parse|read}-Content-Type." ) (t (make-mime-entity node-id (point-min) (point-max) - content-type encoding nil) + content-type content-disposition encoding nil) )) )) diff --git a/mime-play.el b/mime-play.el index ef682d6..943519c 100644 --- a/mime-play.el +++ b/mime-play.el @@ -123,14 +123,10 @@ is selected from variable `mime-acting-condition'. If MODE is specified, play as it. Default MODE is \"play\"." (let ((beg (mime-entity-point-min entity-info)) (end (mime-entity-point-max entity-info)) - (c-type (mime-entity-media-type entity-info)) - (c-subtype (mime-entity-media-subtype entity-info)) - (params (mime-entity-parameters entity-info)) - (encoding (mime-entity-encoding entity-info)) - ) - (or c-type - (setq c-type 'text - c-subtype 'plain)) + (content-type (mime-entity-content-type entity-info)) + (encoding (mime-entity-encoding entity-info))) + (or content-type + (setq content-type (make-mime-content-type 'text 'plain))) ;; Check for VM (if (< beg (point-min)) (setq beg (point-min)) @@ -139,11 +135,9 @@ specified, play as it. Default MODE is \"play\"." (setq end (point-max)) ) (let (method cal ret) - (setq cal (list* (cons 'type c-type) - (cons 'subtype c-subtype) + (setq cal (list* (cons 'major-mode major-mode) (cons 'encoding encoding) - (cons 'major-mode major-mode) - params)) + content-type)) (if mode (setq cal (cons (cons 'mode mode) cal)) ) @@ -188,10 +182,11 @@ specified, play as it. Default MODE is \"play\"." (t (mime-show-echo-buffer "No method are specified for %s\n" - (mime-type/subtype-string c-type c-subtype)) - )) - ) - )) + (mime-type/subtype-string + (mime-content-type-primary-type content-type) + (mime-content-type-subtype content-type)) + ))) + ))) ;;; @ external decoder @@ -347,8 +342,10 @@ window.") (concat (regexp-* mime-view-file-name-char-regexp) "\\(\\." mime-view-file-name-char-regexp "+\\)*")) -(defun mime-raw-get-original-filename (param &optional encoding) - (or (mime-raw-get-uu-filename param encoding) +(defun mime-raw-get-original-filename (param) + (or (if (member (cdr (assq 'encoding param)) + mime-view-uuencode-encoding-name-list) + (mime-raw-get-uu-filename)) (let (ret) (or (if (or (and (setq ret (mime-read-Content-Disposition)) (setq ret @@ -585,7 +582,7 @@ to write." ;;; (defvar mime-raw-dired-function - (if mime/use-multi-frame + (if (and (>= emacs-major-version 19) window-system) (function dired-other-frame) (function mime-raw-dired-function-for-one-frame) )) diff --git a/mime-view.el b/mime-view.el index 8ae704c..fcfc391 100644 --- a/mime-view.el +++ b/mime-view.el @@ -726,7 +726,11 @@ The compressed face will be piped to this command.") (setq mime-preview-original-major-mode mode) (setq major-mode 'mime-view-mode) (setq mode-name "MIME-View") - (mime-view-display-message message-info the-buf obuf) + (mime-view-display-entity message-info message-info + the-buf obuf + '((entity-button . invisible) + (header . visible) + )) (set-buffer-modified-p nil) ) (setq buffer-read-only t) @@ -735,94 +739,12 @@ The compressed face will be piped to this command.") (setq mime-preview-buffer obuf) ) -(defun mime-view-display-message (message-info ibuf obuf) - (let* ((start (mime-entity-point-min message-info)) - (end (mime-entity-point-max message-info)) - (media-type (mime-entity-media-type message-info)) - (media-subtype (mime-entity-media-subtype message-info)) - (params (mime-entity-parameters message-info)) - (encoding (mime-entity-encoding message-info)) - end-of-header e nb ne subj) - (set-buffer ibuf) - (goto-char start) - (setq end-of-header (if (re-search-forward "^$" nil t) - (1+ (match-end 0)) - end)) - (if (> end-of-header end) - (setq end-of-header end) - ) - (save-restriction - (narrow-to-region start end) - (setq subj - (eword-decode-string - (mime-raw-get-subject params encoding))) - ) - (set-buffer obuf) - (setq nb (point)) - (narrow-to-region nb nb) - ;; Insert message-header - (save-restriction - (narrow-to-region (point)(point)) - (insert-buffer-substring mime-raw-buffer start end-of-header) - (let ((f (cdr (assq mime-preview-original-major-mode - mime-view-content-header-filter-alist)))) - (if (functionp f) - (funcall f) - (mime-view-default-content-header-filter) - )) - (run-hooks 'mime-view-content-header-filter-hook) - ) - (let* ((situation - (ctree-match-calist mime-preview-condition - (list* (cons 'type media-type) - (cons 'subtype media-subtype) - (cons 'encoding encoding) - (cons 'major-mode major-mode) - params))) - (message-button - (cdr (assq 'message-button situation))) - (body-presentation-method - (cdr (assq 'body-presentation-method situation)))) - (when (eq message-button 'visible) - (goto-char (point-max)) - (mime-view-insert-entity-button message-info message-info subj) - ) - (cond ((eq body-presentation-method 'with-filter) - (let ((body-filter (cdr (assq 'body-filter situation)))) - (save-restriction - (narrow-to-region (point-max)(point-max)) - (insert-buffer-substring mime-raw-buffer end-of-header end) - (funcall body-filter situation) - ))) - ((functionp body-presentation-method) - (funcall body-presentation-method situation) - ) - ((null (mime-entity-children message-info)) - (goto-char (point-max)) - (mime-view-insert-entity-button message-info message-info subj) - )) - (setq ne (point-max)) - (widen) - (put-text-property nb ne 'mime-view-raw-buffer ibuf) - (put-text-property nb ne 'mime-view-entity message-info) - (goto-char ne) - (let ((children (mime-entity-children message-info)) - (default-situation - (cdr (assq 'childrens-situation situation)))) - (while children - (mime-view-display-entity (car children) message-info ibuf obuf - default-situation) - (setq children (cdr children)) - ))))) - (defun mime-view-display-entity (entity message-info ibuf obuf default-situation) (let* ((start (mime-entity-point-min entity)) (end (mime-entity-point-max entity)) - (media-type (mime-entity-media-type entity)) - (media-subtype (mime-entity-media-subtype entity)) - (params (mime-entity-parameters entity)) - (encoding (mime-entity-encoding entity)) + (content-type (mime-entity-content-type entity)) + (encoding (mime-entity-encoding entity)) end-of-header e nb ne subj) (set-buffer ibuf) (goto-char start) @@ -834,18 +756,18 @@ The compressed face will be piped to this command.") ) (save-restriction (narrow-to-region start end) - (setq subj - (eword-decode-string - (mime-raw-get-subject params encoding))) + (setq subj (eword-decode-string (mime-raw-get-subject entity))) ) (let* ((situation - (ctree-match-calist mime-preview-condition - (list* (cons 'type media-type) - (cons 'subtype media-subtype) - (cons 'encoding encoding) - (cons 'major-mode major-mode) - (append params - default-situation)))) + (or + (ctree-match-calist mime-preview-condition + (append + (or content-type + (make-mime-content-type 'text 'plain)) + (list* (cons 'encoding encoding) + (cons 'major-mode major-mode) + default-situation))) + default-situation)) (button-is-invisible (eq (cdr (assq 'entity-button situation)) 'invisible)) (header-is-visible @@ -901,33 +823,33 @@ The compressed face will be piped to this command.") (setq children (cdr children)) ))))) -(defun mime-raw-get-uu-filename (param &optional encoding) - (if (member (or encoding - (cdr (assq 'encoding param)) - ) - mime-view-uuencode-encoding-name-list) - (save-excursion - (or (if (re-search-forward "^begin [0-9]+ " nil t) - (if (looking-at ".+$") - (buffer-substring (match-beginning 0)(match-end 0)) - )) - "")) - )) +(defun mime-raw-get-uu-filename () + (save-excursion + (if (re-search-forward "^begin [0-9]+ " nil t) + (if (looking-at ".+$") + (buffer-substring (match-beginning 0)(match-end 0)) + )))) -(defun mime-raw-get-subject (param &optional encoding) +(defun mime-raw-get-subject (entity) (or (std11-find-field-body '("Content-Description" "Subject")) - (let (ret) - (if (or (and (setq ret (mime-read-Content-Disposition)) - (setq ret - (assoc "filename" - (mime-content-disposition-parameters ret))) - ) - (setq ret (assoc "name" param)) - (setq ret (assoc "x-name" param)) - ) - (std11-strip-quoted-string (cdr ret)) - )) - (mime-raw-get-uu-filename param encoding) + (let ((ret (mime-entity-content-disposition entity))) + (and ret + (setq ret (mime-content-disposition-filename ret)) + (std11-strip-quoted-string ret) + )) + (let ((ret (mime-entity-content-type entity))) + (and ret + (setq ret + (cdr + (let ((param (mime-content-type-parameters ret))) + (or (assoc "name" param) + (assoc "x-name" param)) + ))) + (std11-strip-quoted-string ret) + )) + (if (member (mime-entity-encoding entity) + mime-view-uuencode-encoding-name-list) + (mime-raw-get-uu-filename)) "")) diff --git a/semi-def.el b/semi-def.el index 2bab24b..0425e27 100644 --- a/semi-def.el +++ b/semi-def.el @@ -1,11 +1,11 @@ -;;; semi-def.el --- definition module for SEMI +;;; semi-def.el --- definition module for REMI ;; Copyright (C) 1995,1996,1997,1998 Free Software Foundation, Inc. ;; Author: MORIOKA Tomohiko ;; Keywords: definition, MIME, multimedia, mail, news -;; This file is part of SEMI (Spadework for Emacs MIME Interfaces). +;; This file is part of REMI (Radical 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 @@ -36,13 +36,6 @@ "Caesar rotation of current region." t) -;;; @ variables -;;; - -(defvar mime/use-multi-frame - (and (>= emacs-major-version 19) window-system)) - - ;;; @ constants ;;; @@ -75,21 +68,13 @@ (add-text-properties from to (list 'mime-button-callback function)) (and data (add-text-properties from to (list 'mime-button-data data))) - ;;(add-text-properties from to (list 'keymap widget-keymap)) )) (defsubst mime-insert-button (string function &optional data) "Insert STRING as button with callback FUNCTION and DATA." (save-restriction (narrow-to-region (point)(point)) - (insert (concat "[" string "]")) - ;; (widget-push-button-value-create - ;; (widget-convert 'push-button - ;; :notify (lambda (&rest ignore) - ;; (mime-preview-play-current-entity) - ;; ) - ;; string)) - (insert "\n") + (insert (concat "[" string "]\n")) (mime-add-button (point-min)(point-max) function data) )) @@ -105,8 +90,7 @@ point (point) func (get-text-property (point) 'mime-button-callback) data (get-text-property (point) 'mime-button-data) - ) - ) + )) (save-excursion (set-buffer buf) (goto-char point) @@ -185,8 +169,7 @@ FUNCTION.") (defmacro pgp-function (method) "Return function to do service METHOD." - `(cadr (assq ,method (symbol-value 'pgp-function-alist))) - ) + `(cadr (assq ,method (symbol-value 'pgp-function-alist)))) (mapcar (function (lambda (method) @@ -262,16 +245,6 @@ FUNCTION.") )) -;;; @ RCS version -;;; - -(defsubst get-version-string (id) - "Return a version-string from RCS ID." - (and (string-match ",v \\([0-9][0-9.][0-9.]+\\)" id) - (substring id (match-beginning 1)(match-end 1)) - )) - - ;;; @ Other Utility ;;; -- 1.7.10.4