all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Kevin Rodgers <kevin.d.rodgers@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: how to handle buffer modifications that are not to be saved
Date: Mon, 02 Apr 2012 23:13:44 -0600	[thread overview]
Message-ID: <jle0t7$16a$1@dough.gmane.org> (raw)
In-Reply-To: <9tp2tuFo64U1@mid.individual.net>

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




      parent reply	other threads:[~2012-04-03  5:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-31 19:06 how to handle buffer modifications that are not to be saved Will Parsons
2012-03-31 20:14 ` PJ Weisberg
     [not found] ` <mailman.231.1333224894.20052.help-gnu-emacs@gnu.org>
2012-04-01 18:27   ` Will Parsons
2012-04-03  5:13 ` Kevin Rodgers [this message]

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='jle0t7$16a$1@dough.gmane.org' \
    --to=kevin.d.rodgers@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /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.