unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Thomas Persson <thomas@spacecentre.se>
Subject: Re: How to convert .doc to plain text ascii in emacs.
Date: Sat, 01 May 2004 21:02:44 +0200	[thread overview]
Message-ID: <87u0z0vuln.fsf@spacecentre.se> (raw)
In-Reply-To: m38ygg2cnl.fsf@jrwork.burla

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	other threads:[~2004-05-01 19:02 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-04-28 17:32 How to convert .doc to plain text ascii in emacs Don Saklad
2004-04-28 18:13 ` Yoni Rabkin Katzenell
2004-05-01 19:02   ` Thomas Persson [this message]
2004-05-02 14:44     ` gebser
2004-05-02 19:04       ` Roodwriter
2004-05-02 19:26       ` Thomas Persson
2004-05-02  8:57 ` Tim X
  -- strict thread matches above, loose matches on Subject: below --
2004-04-28 18:02 Don Saklad
2004-04-28 18:10 ` Kin Cho
2004-04-28 18:17   ` Jay Belanger
2004-04-29 13:47     ` John Russell

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=87u0z0vuln.fsf@spacecentre.se \
    --to=thomas@spacecentre.se \
    /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).