;;; octet.el --- An octet stream viewer. ;; Copyright (C) 2000, 2002, 2003, 2004, 2005 ;; Yuuichi Teranishi ;; Author: Yuuichi Teranishi ;; Created: 2000/05/19 ;; Keywords: octet-stream, broken document ;; This program is free software; you can redistribute it and/or ;; modify it under the terms of the GNU General Public License as ;; published by the Free Software Foundation; either version 2, or (at ;; your option) any later version. ;; This program is distributed in the hope that it will be useful, but ;; WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to the ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, ;; Boston, MA 02110-1301, USA. ;;; Commentary: ;; ;; Display application/octet-stream inline on the emacs buffer. ;; ;; This program requires: ;; ;; emacs-w3m for HTML rendereing. ;; (http://emacs-w3m.namazu.org/) ;; Mule-UCS for UTF-8 decoding. ;; (ftp://ftp.m17n.org/pub/mule/Mule-UCS/) ;; wvHtml for MS Word document. ;; (http://www.wvware.com/) ;; xlHtml for MS Excel document. ;; (http://chicago.sourceforge.net/xlhtml/) ;; pptHtml for MS PowerPoint document. ;; (http://chicago.sourceforge.net/xlhtml/) ;; gunzip for decoding gzipped file. ;; bunzip2 for decoding bzip2ed file. ;; Put follwing line in your setting file: ;; ;; (require 'octet) ;; ;; To display octet data file, execute following command. ;; ;; M-x octet-find-file ;; ;; If you use SEMI, put following lines in your setting file: ;; ;; (require 'octet) ;; (octet-mime-setup) ;; ;; Then you can toggle displaying application/octet-stream messages. ;;; History: ;; ;; This file is created in 2000/05/19. ;; All part was rewrote in 2002/01/28. ;; Added to emacs-w3m repository in 2002/01/29. ;;; Code: (eval-when-compile (require 'cl)) (require 'poe) ; for compatibility (require 'pces) ; as-binary-process (require 'mime) ; SEMI (require 'static) (require 'w3m-util); w3m-insert-string (defvar octet-temp-directory temporary-file-directory "A directory to create temporal files.") (defvar octet-html-render-function 'octet-w3m-region "A function for HTML rendering.") (defvar octet-suffix-type-alist '(("xls" . msexcel) ("ppt" . msppt) ("doc" . msword) ("gz" . gzip) ("bz2" . bzip2) ("html" . html) ("jpg" . jpeg) ("jpeg" . jpeg) ("gif" . gif) ("png" . png) ("tif" . tiff) ("tiff" . tiff) ("txt" . text) ("lzh" . lzh) ("tar" . tar) ("pdf" . pdf)) "Alist of suffix-to-octet-type.") (defvar octet-content-type-alist '(("application/vnd\\.ms-excel" . msexcel) ("application/vnd\\.ms-powerpoint" . msppt) ("application/x-msexcel" . msexcel) ("application/msword" . msword) ("image/jpeg" . jpeg) ("image/gif" . gif) ("image/png" . png) ("image/tiff" . tiff) ("audio/midi" . ignore) ("video/mpeg" . ignore) ("text/html" . html-un) ("application/x-tar" . tar) ("application/pdf" . pdf)) "Alist of content-type-regexp-to-octet-type.") (defvar octet-magic-type-alist '(("^\377\330\377[\340\356]..JFIF" image jpeg) ("^\211PNG" image png) ("^GIF8[79]" image gif) ("^II\\*\000" image tiff) ("^MM\000\\*" image tiff) ("^MThd" audio midi) ("^\000\000\001\263" video mpeg) ("^