[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: MS Word mode?

From: Christian Lemburg
Subject: Re: MS Word mode?
Date: 08 Nov 2002 11:48:11 +0100
User-agent: Gnus/5.0807 (Gnus v5.8.7) XEmacs/21.1 (Channel Islands)

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
- 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 ...


perl -MPOSIX -e 'print tmpnam()'


# Allow wvText to read from the standard input. 
# thanks to brandon from
t=$(basename $(tempfile))
cat "$@" > /tmp/$f.doc
cd /tmp
wvText $f.doc $f.txt
cat $f.txt
rm -f $f.doc $f.txt


;; thanks to brandon from

(defun mm-inline-msword (handle)
  "Return foo bar"
  (let (text)
      (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

(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)))


;;; automodes

(setq auto-mode-alist
         ("\\.\\([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)

;; 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, <>,
 43rd Law of Computing:
        Anything that can go wr
 fortune: Segmentation violation -- Core dumped

reply via email to

[Prev in Thread] Current Thread [Next in Thread]