* mm-decode.el (mm-application-msword-renderer): New variable.
authorShengHuo ZHU <zsh@cs.rochester.edu>
Mon, 18 Feb 2002 15:04:08 +0000 (15:04 +0000)
committerShengHuo ZHU <zsh@cs.rochester.edu>
Mon, 18 Feb 2002 15:04:08 +0000 (15:04 +0000)
(mm-inline-media-tests): Use it.
(mm-inlined-types): Add application/msword.

* mm-view.el (mm-inline-render-with-file): With unibyte buffer.
(mm-inline-render-with-stdin): Ditto.
(mm-inline-render-with-function): Ditto.
(mm-application-msword-renderer-alist): New variable.
(mm-inline-application-msword): New function.
(mm-inline-wash-with-file): Bind coding-system-for-write.
(mm-inline-wash-with-stdin): Ditto.

lisp/ChangeLog
lisp/mm-decode.el
lisp/mm-view.el

index 86aeb55..2c522fe 100644 (file)
@@ -1,4 +1,19 @@
 2002-02-18  ShengHuo ZHU  <zsh@cs.rochester.edu>
+
+       * mm-decode.el (mm-application-msword-renderer): New variable.
+       (mm-inline-media-tests): Use it.
+       (mm-inlined-types): Add application/msword.
+
+       * mm-view.el (mm-inline-render-with-file): With unibyte buffer.
+       (mm-inline-render-with-stdin): Ditto.
+       (mm-inline-render-with-function): Ditto.
+       (mm-application-msword-renderer-alist): New variable.
+       (mm-inline-application-msword): New function.
+       (mm-inline-wash-with-file): Bind coding-system-for-write.
+       (mm-inline-wash-with-stdin): Ditto.
+
+2002-02-18  ShengHuo ZHU  <zsh@cs.rochester.edu>
+       
        Suggested by Felix Natter <fnatter@gmx.net>
 
        * gnus-art.el (gnus-mime-view-part-externally): Rename from
index 57c6268..4be1050 100644 (file)
@@ -116,6 +116,17 @@ The defined renderer types are:
   :version "21.3"
   :group 'mime-display)
 
+(defcustom mm-application-msword-renderer
+  (cond ((executable-find "catdoc") 'catdoc))
+  "Render of application/msword contents.
+It is one of defined renderer types, or a rendering function.
+The defined renderer types are:
+`catdoc' : using catdoc."
+  :type '(choice (symbol catdoc)
+                (function))
+  :version "21.3"
+  :group 'mime-display)
+
 (defvar mm-inline-text-html-renderer nil
   "Function used for rendering inline HTML contents.
 It is suggested to customize `mm-text-html-renderer' instead.")
@@ -194,6 +205,10 @@ images, however this behavior may be changed in the future."
      (lambda (handle)
        (or (featurep 'vcard)
           (locate-library "vcard"))))
+    ("application/msword"
+     mm-inline-application-msword
+     (lambda (handle)
+       mm-application-msword-renderer))
     ("message/delivery-status" mm-inline-text identity)
     ("message/rfc822" mm-inline-message identity)
     ("message/partial" mm-inline-partial identity)
@@ -232,7 +247,7 @@ images, however this behavior may be changed in the future."
     "message/partial" "message/external-body" "application/emacs-lisp"
     "application/pgp-signature" "application/x-pkcs7-signature"
     "application/pkcs7-signature" "application/x-pkcs7-mime"
-    "application/pkcs7-mime")
+    "application/pkcs7-mime" "application/msword")
   "List of media types that are to be displayed inline.
 See also `mm-inline-media-tests', which says how to display a media
 type inline."
index 90a564b..ad7dfeb 100644 (file)
@@ -45,7 +45,7 @@
           "links" "-dump" file)
     (lynx  mm-inline-render-with-stdin nil
           "lynx" "-dump" "-force_html" "-stdin"))
-  "The attributes of renderer types.")
+  "The attributes of renderer types for text/html.")
 
 (defvar mm-text-html-washer-alist
   '((w3  . gnus-article-wash-html-with-w3)
           "links" "-dump" file)
     (lynx  mm-inline-wash-with-stdin nil
           "lynx" "-dump" "-force_html" "-stdin"))
-  "The attributes of washer types.")
+  "The attributes of washer types for text/html.")
+
+(defvar mm-application-msword-renderer-alist
+  '((catdoc  mm-inline-render-with-stdin nil "catdoc"))
+  "The attributes of renderer types.")
 
 ;;; Internal variables.
 
@@ -311,7 +315,8 @@ will not be substituted.")
 (defun mm-inline-wash-with-file (post-func cmd &rest args)
   (let ((file (make-temp-name 
               (expand-file-name "mm" mm-tmp-directory))))
-    (write-region (point-min) (point-max) file nil 'silent)
+    (let ((coding-system-for-write 'binary))
+      (write-region (point-min) (point-max) file nil 'silent))
     (delete-region (point-min) (point-max))
     (unwind-protect
        (apply 'call-process cmd nil t nil (mapcar 'eval args))
@@ -319,15 +324,16 @@ will not be substituted.")
     (and post-func (funcall post-func))))
 
 (defun mm-inline-wash-with-stdin (post-func cmd &rest args)
-  (apply 'call-process-region (point-min) (point-max)
-        cmd t t nil args)
+  (let ((coding-system-for-write 'binary))
+    (apply 'call-process-region (point-min) (point-max)
+          cmd t t nil args))
   (and post-func (funcall post-func)))
 
 (defun mm-inline-render-with-file (handle post-func cmd &rest args)
   (let ((source (mm-get-part handle)))
     (mm-insert-inline
      handle
-     (with-temp-buffer
+     (mm-with-unibyte-buffer
        (insert source)
        (apply 'mm-inline-wash-with-file post-func cmd args)
        (buffer-string)))))
@@ -336,7 +342,7 @@ will not be substituted.")
   (let ((source (mm-get-part handle)))
     (mm-insert-inline 
      handle 
-     (with-temp-buffer
+     (mm-with-unibyte-buffer
        (insert source)
        (apply 'mm-inline-wash-with-stdin post-func cmd args)
        (buffer-string)))))
@@ -345,7 +351,7 @@ will not be substituted.")
   (let ((source (mm-get-part handle)))
     (mm-insert-inline 
      handle 
-     (with-temp-buffer
+     (mm-with-unibyte-buffer
        (insert source)
        (apply func args)
        (buffer-string)))))
@@ -586,6 +592,18 @@ will not be substituted.")
                       (and (listp (car-safe smime-keys))
                            (caar smime-keys)))))))
 
+(defun mm-inline-application-msword (handle)
+  (let* ((func mm-application-msword-renderer)
+        (entry (assq func mm-application-msword-renderer-alist))
+        buffer-read-only)
+    (if entry
+       (setq func (cdr entry)))
+    (cond
+     ((gnus-functionp func)
+      (funcall func handle))
+     (t
+      (apply (car func) handle (cdr func))))))
+
 (provide 'mm-view)
 
 ;;; mm-view.el ends here