From: Kevin Rodgers <kevin.d.rodgers@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: writing a file to disc
Date: Wed, 28 Nov 2007 08:56:36 -0700 [thread overview]
Message-ID: <fik33j$l3g$1@ger.gmane.org> (raw)
In-Reply-To: <u63zmtsox.fsf@gmail.com>
rahed wrote:
> Hi,
>
> I have a file in a buffer and want to write it (C-x C-w) to disc under a
> different name. At the same time I want to leave in the
> buffer only the original one.
>
> Is there a some simple key binding to do it?
How about:
(defun clone-file (filename)
"Clone the current buffer and write the new buffer into file FILENAME."
(interactive "FWrite file: ")
(let* ((buffer-file-name nil))
(with-current-buffer (clone-buffer nil (interactive-p))
(write-file filename (interactive-p)))))
(global-set-key "\C-xW" 'clone-file)
--
Kevin Rodgers
Denver, Colorado, USA
next prev parent reply other threads:[~2007-11-28 15:56 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-28 13:17 writing a file to disc rahed
2007-11-28 14:30 ` Peter Dyballa
2007-11-28 15:56 ` Kevin Rodgers [this message]
2007-11-28 18:32 ` rahed
[not found] ` <mailman.4266.1196275142.18990.help-gnu-emacs@gnu.org>
2007-11-28 21:02 ` Scott Frazer
2007-11-29 7:59 ` rahed
[not found] ` <mailman.4255.1196265534.18990.help-gnu-emacs@gnu.org>
2007-11-29 1:01 ` Johan Bockgård
[not found] <mailman.4235.1196255887.18990.help-gnu-emacs@gnu.org>
2007-11-30 17:02 ` Stefan Monnier
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='fik33j$l3g$1@ger.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.
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).