(defvar catdoc-prog "catdoc"
"The name of the program that will perform the conversion. This
will probably be catdoc.exe, but on Unix, or similar the process may have
another name.")
(defvar catdoc-add-menu-item t
"Controls whether or not to add a new entry on the file menu, that will allow
word files to be opened from the GUI.")
(defvar catdoc-process nil
"The catdoc process that we are going to spawn.")
(defvar catdoc-filename nil
"The input filename to the catdoc process, this is used later to allow rename
the output buffer appropriately.")
(defun catdoc-process-filter (proc string)
"Process the results from the catdoc process."
(set-buffer (get-buffer-create "*catdoc*"))
(insert string))
(defun catdoc-sentinel (proc msg)
"When the catdoc process has finished, switch to its output buffer,
and rename it appropriately."
(cond ((eq (process-status proc) 'exit)
(switch-to-buffer "*catdoc*")
(rename-buffer (concat catdoc-filename ".txt"))
)))
(defun open-word-document (file-name )
"Find, decode and display a specific Microsoft Word document."
(interactive "fOpen Word Document: \n")
(setq file-name (expand-file-name file-name))
(setq catdoc-filename file-name)
(setq catdoc-process
(start-process "catdoc" nil catdoc-prog file-name))
(set-process-filter catdoc-process 'catdoc-process-filter)
(set-process-sentinel catdoc-process 'catdoc-sentinel)
(process-kill-without-query catdoc-process)
)
(if catdoc-add-menu-item
(if (if (boundp 'running-xemacs)
running-xemacs
(string-match "XEmacs\\|Lucid" emacs-version))
(add-menu-button '("File") ["Open Word Document" open-word-document] "Open in Other %_Window...")
(define-key menu-bar-file-menu [catdoc-open]
'("Open Word Document" . open-word-document))))
(provide 'catdoc)