From: Christian Lemburg <lemburg@aixonix.de>
Subject: Re: MS Word mode?
Date: 08 Nov 2002 11:48:11 +0100 [thread overview]
Message-ID: <m3lm44uyl0.fsf@maki.aixonix.de> (raw)
In-Reply-To: 87fzudc5k0.fsf@emacswiki.org
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
next prev parent reply other threads:[~2002-11-08 10:48 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.1036696597.23451.help-gnu-emacs@gnu.org>
2002-11-07 23:40 ` MS Word mode? Alex Schroeder
2002-11-08 10:48 ` Christian Lemburg [this message]
2002-11-08 11:24 ` Tiarnan
2002-11-08 13:52 ` Arnaldo Mandel
[not found] ` <mailman.1036765729.27121.help-gnu-emacs@gnu.org>
2002-11-08 17:24 ` Alex Schroeder
[not found] <mailman.1036693626.13090.help-gnu-emacs@gnu.org>
2002-11-07 18:59 ` Bruce Mobarry
2002-11-08 6:18 ` Julien Avarre
2002-11-08 9:15 ` Thomas Link
2002-11-09 18:40 ` Kin Cho
2002-11-07 18:01 Tiarnan
2002-11-07 18:48 ` Roger Mason
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m3lm44uyl0.fsf@maki.aixonix.de \
--to=lemburg@aixonix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).