help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: How to convert .doc to plain text ascii in emacs.


From: Thomas Persson
Subject: Re: How to convert .doc to plain text ascii in emacs.
Date: Sat, 01 May 2004 21:02:44 +0200
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux)

Yoni Rabkin Katzenell <yoni-r@actcom.com> writes:

> Don Saklad <dsaklad@nestle.csail.mit.edu> writes:
>
>> What related emacs commands are there that might convert an rmail
>> attachment from .doc to plain text ascii ?...
>>
>> It is an rmail message distributed from local government about an
>> upcoming public hearing.
>
> I heard that Antiword [http://www.winfield.demon.nl/] can convert doc
> files into plain text and postscript. Note though, that I have never
> used the software myself.

I use antiword and the following code to integrate it with emacs:

(defun antiword-buffer ()
  "Takes the current buffer as input to the external program antiword.

If the current buffer is a ms-word document it's contents are replaced
with the output from antiword and the extension `.doc' is replaced
with `.txt' in the buffer-file-name."
  (let ((txt-buffer-file-name (concat (substring (buffer-file-name) 0 -4)
                                      ".txt")))
    (shell-command-on-region (point-min) (point-max)
                             "cat | antiword -" nil t nil)
    (undo-start)
    (if (equal (buffer-string) "- is not a Word Document.\n")
        (or (undo-more 1)
            (message "%s - is not a Word Document."(current-buffer)))
      (set-visited-file-name txt-buffer-file-name)
      (not-modified))))

;; The following expression makes sure that antiword-buffer is run when a
;; file with the .doc extension is opened.
(setq auto-mode-alist
      (append '(("\\.doc\\'" . antiword-buffer))
              auto-mode-alist))


reply via email to

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