Sams Teach Yourself Emacs in 24 Hours |
|||||||||||||||||
Hour 15: Getting an Overview of a File |
|||||||||||||||||
|
If you try to open the same buffer in two different windows, and afterward try to narrow it in two different ways, or try to create two different outlines, you will see that this is not possible. The reason for this is that both narrowing and the outline functions modify some characteristics of the buffer, which is independent of the fact that the buffer is shown in two different windows. Likewise you will see that it is not possible to mark in a buffer two different regions, which are shown in two different windows. The reason for this is that the mark (which is one end of the region) is shared between the windows.
A solution to these problems is to copy the buffer and use the copy for the outline and so on. Unfortunately this means that if you edit the one, you won't update the other. Emacs contains a nicer solution to this problem called indirect buffers . An indirect buffer is a copy of a buffer that has separate marks and other buffer characteristics but that ensures that an edit in one buffer is transferred to the other immediately.
In sams-lib.el the function sams-make-buffer-copy exists. When this function is invoked, a new frame is created with an indirect buffer which is a copy of the current buffer.
If you get a copy of a buffer this way, you can use either outline or narrowing in two different views of the same file. Furthermore you can get two buffers with separate marks, so it is possible to get two different regions of the same file. This makes it possible to invoke ediff-regions-linewise on two regions in the same buffer (or what at least appears to be the same buffer).
Sams Teach Yourself Emacs in 24 Hours |
|||||||||||||||||
Hour 15: Getting an Overview of a File |
|||||||||||||||||
|
© Copyright Macmillan USA. All rights reserved.