From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Scott Frazer Newsgroups: gmane.emacs.help Subject: Re: writing a file to disc Date: Wed, 28 Nov 2007 13:02:32 -0800 (PST) Organization: http://groups.google.com Message-ID: <21c50cdb-4ee0-4796-9cfb-cca2adc89b9d@e23g2000prf.googlegroups.com> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1196286046 2086 80.91.229.12 (28 Nov 2007 21:40:46 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 28 Nov 2007 21:40:46 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Nov 28 22:40:53 2007 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IxUeK-0003Jb-GU for geh-help-gnu-emacs@m.gmane.org; Wed, 28 Nov 2007 22:40:52 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IxUe1-0004o2-LM for geh-help-gnu-emacs@m.gmane.org; Wed, 28 Nov 2007 16:40:33 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews.google.com!e23g2000prf.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 26 Original-NNTP-Posting-Host: 64.102.76.105 Original-X-Trace: posting.google.com 1196283753 15452 127.0.0.1 (28 Nov 2007 21:02:33 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Wed, 28 Nov 2007 21:02:33 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: e23g2000prf.googlegroups.com; posting-host=64.102.76.105; posting-account=mTP6TAoAAADeO2EO3QMjJrmUPGLwlQy3 User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.10) Gecko/20071115 Firefox/2.0.0.10,gzip(gfe),gzip(gfe) Content-Disposition: inline Original-Xref: shelby.stanford.edu gnu.emacs.help:154231 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:49659 Archived-At: On Nov 28, 1:32 pm, rahed wrote: > Kevin Rodgers writes: > > (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) > > It makes two buffers, a new one and the original. I don't know > lisp, could you possibly trim it so that only the original occupy the > buffer? > > Many thanks. My newsreader was acting funny, so sorry if this is a duplicate. (defun clone-file (filename) "Clone the current buffer and write it into FILENAME." (interactive "FClone to file: ") (let ((buffer-file-name nil)) (kill-buffer (with-current-buffer (clone-buffer) (write-file filename (interactive-p)) (current-buffer)))))