Mickey Petersen tweets about cloning buffers and makes explicit a distinction that I must admit I wasn’t clear on.
You can clone indirect buffers in #emacs with C-x 4 c — very useful if you want to browse two or more parts of a large file. Changes in either is reflected in all the others.
(But if you want them totally separated, use M-x clone-buffer or C-x x n)
— Mickey Petersen (@mickeynp) December 7, 2021
I’m pretty familiar with indirect buffers, which are a clever way of looking at a buffer with two different views: you can have different narrowings, point positions, modes, and other properties while still maintaining identical text. Text changes made to the indirect buffer or the base buffer are instantly reflected in the other. It’s almost always what you want but sometimes it’s convenient to simply make an independent copy of a buffer.
Mickey’s tweet shows you how to do either. Oddly, I couldn’t find clone-buffer
in the manual but its documentation available with describe-function
(Ctrl+h f) and has been around for a long time.
As I said, you almost always want clone-indirect-buffer
or its siblings. I’ve used it a few times but I’ve never used clone-buffer
. Still, it’s nice to know they’re both available. As usual, Emacs has us covered.