clone-buffer not work on file buffers.
I can make it work by the following advice:
(advice-add 'clone-buffer :around (lambda (oldfun &rest args) "Allow cloning file buffers." (interactive "bName of new cloned buffer: ") (let (buffer-file-name) (apply oldfun args))))
The clone is a non-file buffer. One can modify it and save it into a new file with
Everything is working quite fine. So why does the original command
clone-buffer test whether the current buffer is a file buffer and disallow cloning in that case?
My current best guess for the motivation of the restriction: The change from a file buffer to a non-file buffer is quite hard.
- Version control like
vc-gitdoes not work anymore.
compile-commandcompiles the original buffer file and not the clone