Книга: Learning GNU Emacs, 3rd Edition
7.4.3 Editing While Text Is Hidden
7.4.3 Editing While Text Is Hidden
Now that you know how to hide and show text, let's discuss some of the properties of hidden text. Editing a document while some of it is hidden is often useful—it's a great way to make major changes in document structure—but there are some dangers that you should be aware of. Let's say you've hidden all text with outline mode and only the headings are showing, giving you a true "outline" of your document. If you move a heading that has hidden text and headings associated with it, everything that is hidden moves when you move the visible text. Later, when you "show" all of the document, the hidden text appears in its new location—underneath the heading that you moved. Similarly, if you delete a heading, you delete all hidden text as well.
This feature makes moving blocks of text easy. However, there are some things to watch out for. If you delete the ellipsis following an entry, Emacs deletes the hidden information as well. To its credit, Emacs tries to keep you from doing this; it does not allow you to delete the ellipsis using the Del key or using normal cursor commands like C-b to move the cursor onto it. However, if you're persistent you can delete the ellipses (and the text it represents) using, for example, C-k. If you do so, Emacs deletes the hidden text. Typing C-y yanks the hidden text that you killed when you deleted the ellipsis; the undo command, C-_, restores the ellipsis. Our advice is to display text before deleting it so you can see what you're doing. On the other hand, when you are moving sections of an outline around, it is helpful to do so while text is hidden so you can keep the structure in mind.
Be careful when moving hidden text to a buffer that's not in outline mode. Let's say that your outline ends with a heading followed by an ellipsis. When marking that section to move to another buffer, make sure the region includes the newline following the ellipsis (for example, move to the beginning of the next line). If you simply place the cursor following the ellipsis, Emacs copies only the header, not the hidden text. We're not sure why. Moving past the newline copies the body as well as the heading correctly, and pasting it into a buffer in text mode shows all the hidden text.