clone buffer that is visiting a file
  Home FAQ Contact Sign in
gnu.emacs.help only
 
Advanced search
POPULAR GROUPS

more...

gnu.emacs.help Profile…
 Up
clone buffer that is visiting a file         


Author: xraysmalevich
Date: Sep 4, 2008 05:55

If you try to run clone-buffer on a file-visiting buffer, it won't
happen, and you get the error message "Cannot clone a file-visiting
buffer."

I think I understand why -- if you clone a file-visiting buffer, both
buffers are visiting the same file -- and this is more a situation for
an indirect buffer. Is this correct?

But what about situations where you want the entire text of the file-
visiting buffer, the same major mode, but not have it be visiting a
file? Is there any easier way to do this other than copying the entire
buffer and starting from scratch?

I poked around in the the internals of clone-buffer, and it seems to
be happy with copying file-visiting buffers if I turn off the file-
visiting checks AND disable copying local variables. Is this safe? Are
there any reason why I might NOT want to do this?

below is my modified clone-buffer code, with mooning internal
commentary on my suspicious changes:
Show full article (3.98Kb)
2 Comments
Re: clone buffer that is visiting a file         


Author: Kevin Rodgers
Date: Sep 4, 2008 18:45

xraysmalevich@gmail.com wrote:
> If you try to run clone-buffer on a file-visiting buffer, it won't
> happen, and you get the error message "Cannot clone a file-visiting
> buffer."
>
> I think I understand why -- if you clone a file-visiting buffer, both
> buffers are visiting the same file -- and this is more a situation for
> an indirect buffer. Is this correct?
>
> But what about situations where you want the entire text of the file-
> visiting buffer, the same major mode, but not have it be visiting a
> file? Is there any easier way to do this other than copying the entire
> buffer and starting from scratch?

Why don't you want the new buffer to be visiting a (different/temporary)
file? Depending on that, this might suit you:

http://lists.gnu.org/archive/html/help-gnu-emacs/2007-11/msg00678.html

--
Kevin Rodgers
Denver, Colorado, USA
no comments
Re: clone buffer that is visiting a file         


Author: xraysmalevich
Date: Sep 5, 2008 06:44

On Sep 4, 9:45 pm, Kevin Rodgers gmail.com> wrote:
> xraysmalev...@gmail.com wrote:
>> If you try to run clone-buffer on a file-visiting buffer, it won't
>> happen, and you get the error message "Cannot clone a file-visiting
>> buffer."
>
>> I think I understand why -- if you clone a file-visiting buffer, both
>> buffers are visiting the same file -- and this is more a situation for
>> an indirect buffer. Is this correct?
>
>> But what about situations where you want the entire text of the file-
>> visiting buffer, the same major mode, but not have it be visiting a
>> file? Is there any easier way to do this other than copying the entire
>> buffer and starting from scratch?
>
> Why don't you want the new buffer to be visiting a (different/temporary)
> file?  Depending on that, this might suit you:
>
> http://lists.gnu.org/archive/html/help-gnu-emacs/2007-11/msg00678.html
> ...
Show full article (1.34Kb)
no comments