From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Christian Lemburg Newsgroups: gmane.emacs.help Subject: Re: MS Word mode? Date: 08 Nov 2002 11:48:11 +0100 Organization: KPNQwest Germany GmbH, customer reader site Sender: help-gnu-emacs-admin@gnu.org Message-ID: References: <87fzudc5k0.fsf@emacswiki.org> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1036756734 30618 80.91.224.249 (8 Nov 2002 11:58:54 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Fri, 8 Nov 2002 11:58:54 +0000 (UTC) Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18A7ml-0007xf-00 for ; Fri, 08 Nov 2002 12:58:51 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 18A7O5-0005v4-00; Fri, 08 Nov 2002 06:33:21 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!news-fra1.dfn.de!news0.de.colt.net!blackbush.xlink.net!blackbush.de.kpnqwest.net!scapa.de.kpnqwest.net!194.121.123.2!194.121.123.146 Original-Newsgroups: gnu.emacs.help Original-Lines: 127 Original-NNTP-Posting-Host: 194.121.123.2 Original-X-Trace: newsreader2.lb-lan.ka.de.kpnqwest.net 1036754161 3429 194.121.123.2 (8 Nov 2002 11:16:01 GMT) Original-X-Complaints-To: "abuse@de.kpnqwest.net" Original-NNTP-Posting-Date: Fri, 8 Nov 2002 11:16:01 +0000 (UTC) X-Face: "PlaRZ)@9[if~e#S1]D7|l`|7"C.kV+P^$.r!pL"NE^5Gh[Fwr?wR-@{Me)_Dfyec#Mi4M7 KWUn#dE$B3L3?WX:lR.vf-LI+w3OJL46>O2+HP#h$;.*K^Om]xOh8a>F1"6{%;k>=/;{Pn%sX2~'E? User-Agent: Gnus/5.0807 (Gnus v5.8.7) XEmacs/21.1 (Channel Islands) X-Original-NNTP-Posting-Host: 194.121.123.146 Original-Xref: shelby.stanford.edu gnu.emacs.help:106837 Original-To: help-gnu-emacs@gnu.org Errors-To: help-gnu-emacs-admin@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.help:3392 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:3392 Alex Schroeder writes: > Roger Mason writes: > > > There was a question about this recently on this forum. Look for > > undoc.el, I got it from the wiki (I think). It has worked very well for > > me to date, although I have not attempted ro read complex documents. > > Well, it makes things readable, but it is far from perfect -- it seems > to just delete any non-ascii characters, such that sometimes you will > see words such as "Alex8" where "8" is some garbage that just looked > like being part of a real word... In other words, interfacing to > something like catdoc, antiword, or wvText (included with AbiWord) > might be cool. Actually all you need is this: > > (add-to-list 'auto-mode-alist '("\\.doc\\'" . no-word)) > > (defun no-word () > "Run antiword on the entire buffer." > (shell-command-on-region (point-min) (point-max) "antiword - " t t)) > > Alex. Yup, works for me: - installed wvWare - found some emacs code for using wvText within Gnus at http://216.239.37.100/search?q=cache:RW5fo8yVQSgC:www.rhodesmill.org/brandon/notes/emacs.txt+using+wvText+emacs&hl=en&ie=UTF-8 - used code above to modify auto-mode-alist Working smooth in dired-mode and gnus ... For your convenience, here are the assorted code snippets (Disclaimer: all just stolen together, none of this is mine ...): Of course, one could play the same trick with wvHtml and use an emacs browser to view the resulting HTML ... hm ... I think I have to get this wmf2png business working ... ---------------- bin/tempfile ---------------- perl -MPOSIX -e 'print tmpnam()' ---------------- bin/wvTextStdin: ---------------- #!/bin/bash # Allow wvText to read from the standard input. # thanks to brandon from rhodesmill.org t=$(basename $(tempfile)) cat "$@" > /tmp/$f.doc cd /tmp wvText $f.doc $f.txt cat $f.txt rm -f $f.doc $f.txt ---------------- emacs/my-mime-types.el ---------------- ;; thanks to brandon from rhodesmill.org (defun mm-inline-msword (handle) "Return foo bar" (let (text) (with-temp-buffer (mm-insert-part handle) (call-process-region (point-min) (point-max) "wvTextStdin" t t nil) (setq text (buffer-string))) (mm-insert-inline handle text))) (setq mm-automatic-display (append mm-automatic-display '("application/msword"))) (setq mm-inlined-types (append mm-inlined-types '("application/msword" "application/octet-stream"))) (setq mm-inline-media-tests (append mm-inline-media-tests '(("application/msword" mm-inline-msword identity)) '(("application/octet-stream" mm-inline-msword (lambda (handle) (let* ((type (mm-handle-type handle)) (name-pair (assq 'name type)) (name (cdr name-pair))) (if name (equal ".doc" (substring name -4 nil))) )))))) ---------------- emacs/my-automodes.el ---------------- ;;; automodes (setq auto-mode-alist (append '( ("\\.\\([pP][Llm]\\|al\\)$" . cperl-mode) ("\\.\\([xX][sS][dD]\\)$" . xml-mode) ("\\.\\([xX][mM][lL]\\)$" . xml-mode) ("\\.[jJ][sS]$" . javascript-mode) ("\\.[pP][hH][pP]$" . php-mode) ("\\.doc\\'" . my-word-converter) ) auto-mode-alist)) ;; thanks to Alex Schroeder (defun my-word-converter () "Run wvTextStdin on the entire buffer." (shell-command-on-region (point-min) (point-max) "wvTextStdin" t t)) -- Christian Lemburg, , http://www.clemburg.com/ 43rd Law of Computing: Anything that can go wr fortune: Segmentation violation -- Core dumped