[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 <alex@emacswiki.org> writes:
> Roger Mason <rmason@sparky2.esd.mun.ca> 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, <lemburg@aixonix.de>, http://www.clemburg.com/
43rd Law of Computing:
Anything that can go wr
fortune: Segmentation violation -- Core dumped
- MS Word mode?, Tiarnan, 2002/11/07
- Re: MS Word mode?, Julien Avarre, 2002/11/08
- Re: MS Word mode?, Julien Avarre, 2002/11/08
- Re: MS Word mode?, Thomas Link, 2002/11/08
- Re: MS Word mode?, Kin Cho, 2002/11/09