* how to handle buffer modifications that are not to be saved
@ 2012-03-31 19:06 Will Parsons
2012-03-31 20:14 ` PJ Weisberg
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Will Parsons @ 2012-03-31 19:06 UTC (permalink / raw)
To: help-gnu-emacs
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. 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?
--
Will
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: how to handle buffer modifications that are not to be saved
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-03 5:13 ` Kevin Rodgers
2 siblings, 0 replies; 4+ messages in thread
From: PJ Weisberg @ 2012-03-31 20:14 UTC (permalink / raw)
To: wbparsons@cshore.com; +Cc: help-gnu-emacs@gnu.org
[-- Attachment #1: Type: text/plain, Size: 469 bytes --]
On Saturday, March 31, 2012, Will Parsons <oudeis@nodomain.invalid> wrote:
> 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?
Off the top of my head, try setting buffer-file-name to nil.
--
-PJ
Gehm's Corollary to Clark's Law: Any technology distinguishable from
magic is insufficiently advanced.
[-- Attachment #2: Type: text/html, Size: 547 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: how to handle buffer modifications that are not to be saved
[not found] ` <mailman.231.1333224894.20052.help-gnu-emacs@gnu.org>
@ 2012-04-01 18:27 ` Will Parsons
0 siblings, 0 replies; 4+ messages in thread
From: Will Parsons @ 2012-04-01 18:27 UTC (permalink / raw)
To: help-gnu-emacs
PJ Weisberg wrote:
> --f46d04182582cbffdd04bc8f9b66
> Content-Type: text/plain; charset=ISO-8859-1
>
> On Saturday, March 31, 2012, Will Parsons <oudeis@nodomain.invalid> wrote:
>
>> 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?
>
> Off the top of my head, try setting buffer-file-name to nil.
Close - an auto-save file is still created, but this can be eliminated
with:
(auto-save-mode 0)
Thanks!
--
Will
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: how to handle buffer modifications that are not to be saved
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-03 5:13 ` Kevin Rodgers
2 siblings, 0 replies; 4+ messages in thread
From: Kevin Rodgers @ 2012-04-03 5:13 UTC (permalink / raw)
To: help-gnu-emacs
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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-04-03 5:13 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 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).