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

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

Re: writing a file to disc


From: Scott Frazer
Subject: Re: writing a file to disc
Date: Wed, 28 Nov 2007 13:02:32 -0800 (PST)
User-agent: G2/1.0

On Nov 28, 1:32 pm, rahed <rah...@gmail.com> wrote:
> Kevin Rodgers <kevin.d.rodg...@gmail.com> 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)))))


reply via email to

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