From: Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Subject: Re: emacs rmail. How to convert .doc to plain text
Date: 24 Nov 2002 18:08:22 +0100 [thread overview]
Message-ID: <m3bs4ej3p5.fsf@cicero.benny.turtle-trading.net> (raw)
In-Reply-To: arq84t$apl$1$830fa795@news.demon.co.uk
Hi,
Puff Addison <puff@theaddisons.demon.co.uk> writes:
> Yes, please post your Emacs integration code.
Ok, see below. I should note that it is probably also possible to
(ab-)use jka-compr for this, which would make my two functions
obsolete.
so long, benny
>>>>>>>
(defun benny-antiword-file-handler (operation &rest args)
;; First check for the specific operations
;; that we have special handling for.
(cond ((eq operation 'insert-file-contents)
(apply 'benny-antiword-insert-file args))
((eq operation 'file-writable-p)
nil)
((eq operation 'write-region)
(error "Word documents can't be written"))
;; Handle any operation we don't know about.
(t (let ((inhibit-file-name-handlers
(cons 'benny-antiword-file-handler
(and (eq inhibit-file-name-operation operation)
inhibit-file-name-handlers)))
(inhibit-file-name-operation operation))
(apply operation args)))))
(defun benny-antiword-insert-file (filename &optional visit beg end replace)
(set-buffer-modified-p nil)
(setq buffer-file-name (file-truename filename))
(setq buffer-read-only t)
(let ((start (point))
(inhibit-read-only t))
(if replace (delete-region (point-min) (point-max)))
(save-excursion
(let ((coding-system-for-read 'utf-8)
(filename (encode-coding-string
buffer-file-name
(or file-name-coding-system
default-file-name-coding-system))))
(call-process "antiword" nil t nil "-m" "UTF-8.txt"
filename))
(list buffer-file-name (- (point) start)))))
(setq file-name-handler-alist
(cons '("\\.doc\\'" . benny-antiword-file-handler)
file-name-handler-alist))
<<<<<<<
next prev parent reply other threads:[~2002-11-24 17:08 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-11-22 4:32 emacs rmail. How to convert .doc to plain text Don Saklad
2002-11-22 22:06 ` Zap Branigan
2002-11-23 6:57 ` Don Saklad
2002-11-23 18:25 ` Benjamin Riefenstahl
2002-11-24 10:01 ` Puff Addison
2002-11-24 17:08 ` Benjamin Riefenstahl [this message]
2002-11-24 11:41 ` Don Saklad
2002-11-24 17:01 ` Benjamin Riefenstahl
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m3bs4ej3p5.fsf@cicero.benny.turtle-trading.net \
--to=benjamin.riefenstahl@epost.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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.