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

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

Re: how to handle buffer modifications that are not to be saved


From: Kevin Rodgers
Subject: Re: how to handle buffer modifications that are not to be saved
Date: Mon, 02 Apr 2012 23:13:44 -0600
User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; en-US; rv:1.9.2.28) Gecko/20120306 Thunderbird/3.1.20

On 3/31/12 1:06 PM, Will Parsons wrote:
I recently discovered a utility (Perl script) to convert a Word .docx
file to plain text (http://docx2txt.sourceforge.net/).  The author
thoughtfully provides the following addition to .emacs for viewing a
.docx file within Emacs using the utility:
----------------
(add-to-list 'auto-mode-alist '("\\.docx\\'" . docx2txt))

(defun docx2txt ()
   "Run docx2txt on the entire buffer."
   (shell-command-on-region (point-min) (point-max) "docx2txt.pl" t t))
----------------
He also warns:

   Be warned that with above ~/.emacs code addition, if you happen to
   save the buffer/file, it will overwrite the .docx file with the text
   content.

I would like to avoid the danger of unintentionally overwriting the
original file.

Then don't specify t for the optional OUTPUT-BUFFER and REPLACE arguments.

I know I could do that my renaming the buffer to end
in .txt rather than .docx, but really I probably don't want a separate
text file, or have to answer a question about saving a modified
buffer.  What would be the recommended way of simply making the
converted .docx buffer temporary, so I don't have to worry about
saving it accidentally, or answering any questions about saving it
when exiting?

Create a buffer that is not visiting a file:

(shell-command-on-region (point-min) (point-max) "docx2txt.pl"
                         (generate-new-buffer "*docx2txt*")
                         t)

--
Kevin Rodgers
Denver, Colorado, USA




reply via email to

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