From: yamaoka Date: Mon, 17 Jul 2000 22:01:33 +0000 (+0000) Subject: Synch. X-Git-Tag: t-gnus-6_14-quimby-before-installer-changed-~163 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7f7eae109eac58a5b789cf8c624ad2d553f608e1;p=elisp%2Fgnus.git- Synch. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index ef6e461..76f8628 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,11 @@ +2000-07-17 14:18:16 ShengHuo ZHU + + * mailcap.el (mailcap-mimetypes-parsed-p): New variable. + (mailcap-parse-mimetypes): Use it. + (mailcap-extension-to-mime): Parse mimetype. + (mailcap-mime-types): Ditto. + * mml.el (mml-minibuffer-read-type): Ditto. + 2000-07-16 18:25:07 ShengHuo ZHU * nndoc.el (nndoc-type-alist): Add outlook. diff --git a/lisp/gnus-mailcap.el b/lisp/gnus-mailcap.el index 41f898a..1cf91ce 100644 --- a/lisp/gnus-mailcap.el +++ b/lisp/gnus-mailcap.el @@ -829,39 +829,46 @@ this type is returned." (".jpeg" . "image/jpeg")) "An assoc list of file extensions and corresponding MIME content-types.") -(defun mailcap-parse-mimetypes (&optional path) +(defvar mailcap-mimetypes-parsed-p nil) + +(defun mailcap-parse-mimetypes (&optional path force) "Parse out all the mimetypes specified in a unix-style path string PATH. Components of PATH are separated by the `path-separator' character appropriate for this system. If PATH is omitted, use the value of -environment variable MIMETYPES if set; otherwise use a default path." - (cond - (path nil) - ((getenv "MIMETYPES") (setq path (getenv "MIMETYPES"))) - ((memq system-type '(ms-dos ms-windows windows-nt)) - (setq path '("~/mime.typ" "~/etc/mime.typ"))) - (t (setq path - ;; mime.types seems to be the normal name, definitely so - ;; on current GNUish systems. The search order follows - ;; that for mailcap. - '("~/.mime.types" - "/etc/mime.types" - "/usr/etc/mime.types" - "/usr/local/etc/mime.types" - "/usr/local/www/conf/mime.types" - "~/.mime-types" - "/etc/mime-types" - "/usr/etc/mime-types" - "/usr/local/etc/mime-types" - "/usr/local/www/conf/mime-types")))) - (let ((fnames (reverse (if (stringp path) - (parse-colon-path path) - path))) - fname) - (while fnames - (setq fname (car fnames)) - (if (and (file-readable-p fname)) - (mailcap-parse-mimetype-file fname)) - (setq fnames (cdr fnames))))) +environment variable MIMETYPES if set; otherwise use a default path. +If FORCE, re-parse even if already parsed." + (interactive (list nil t)) + (when (or (not mailcap-mimetypes-parsed-p) + force) + (cond + (path nil) + ((getenv "MIMETYPES") (setq path (getenv "MIMETYPES"))) + ((memq system-type '(ms-dos ms-windows windows-nt)) + (setq path '("~/mime.typ" "~/etc/mime.typ"))) + (t (setq path + ;; mime.types seems to be the normal name, definitely so + ;; on current GNUish systems. The search order follows + ;; that for mailcap. + '("~/.mime.types" + "/etc/mime.types" + "/usr/etc/mime.types" + "/usr/local/etc/mime.types" + "/usr/local/www/conf/mime.types" + "~/.mime-types" + "/etc/mime-types" + "/usr/etc/mime-types" + "/usr/local/etc/mime-types" + "/usr/local/www/conf/mime-types")))) + (let ((fnames (reverse (if (stringp path) + (parse-colon-path path) + path))) + fname) + (while fnames + (setq fname (car fnames)) + (if (and (file-readable-p fname)) + (mailcap-parse-mimetype-file fname)) + (setq fnames (cdr fnames)))) + (setq mailcap-mimetypes-parsed-p t))) (defun mailcap-parse-mimetype-file (fname) ;; Parse out a mime-types file @@ -900,6 +907,7 @@ environment variable MIMETYPES if set; otherwise use a default path." (defun mailcap-extension-to-mime (extn) "Return the MIME content type of the file extensions EXTN." + (mailcap-parse-mimetypes) (if (and (stringp extn) (not (eq (string-to-char extn) ?.))) (setq extn (concat "." extn))) @@ -928,6 +936,7 @@ The path of COMMAND will be returned iff COMMAND is a command." (defun mailcap-mime-types () "Return a list of MIME media types." + (mailcap-parse-mimetypes) (mm-delete-duplicates (mapcar 'cdr mailcap-mime-extensions))) (provide 'gnus-mailcap) diff --git a/lisp/mml.el b/lisp/mml.el index d4a04b6..4770d12 100644 --- a/lisp/mml.el +++ b/lisp/mml.el @@ -705,6 +705,7 @@ If MML is non-nil, return the buffer up till the correspondent mml tag." file)) (defun mml-minibuffer-read-type (name &optional default) + (mailcap-parse-mimetypes) (let* ((default (or default (mm-default-file-encoding name) ;; Perhaps here we should check what the file