Выбрать главу

7.4.5 Promoting and Demoting Sections

Often as you're writing, you find that a certain heading should really be promoted or demoted a level. To promote a heading, type C-c C-^. To demote it a level, C-c C-v. (Note the clever attempt to make the key bindings indicate that you're moving headings up or down a level using ^ and v.) This automatically changes the markings for the heading in question. In other words, promoting a second-level heading removes an asterisk, making it a first-level heading. You'll find the commands to move to the next and previous headings, C-c C-n and C-c C-p, helpful when you are promoting and demoting sections.

But what if you want to demote not just a heading but a subtree? Or even the entire outline? At the moment, you'd have to write a Lisp function to do that (or use someone else's). Several functions like this have been written by gurus and posted online, but none are part of Emacs at this writing. We hope this function is incorporated soon.

7.4.6 Using Outline Minor Mode

Outline mode is also available as a minor mode so that you can use it subordinately to your favorite major mode. To start outline mode as a minor mode, type M-x outline-minor-mode; Outl appears on the mode line. In some ways, this mode is less convenient; rather than the simple C-c prefix you use for most outline mode commands, in outline minor mode, you must preface all commands with C-c @ instead, to avoid interfering with the usual C-c commands of the major mode. So, if you want to move down to the next heading (the C-c C-n command in outline mode), you would type C-c @ C-n instead.

Please note that mixing outline major mode and outline minor mode is not only redundant but can be dangerous. Turning on the minor mode while the major mode is on can confuse Emacs. Exit outline mode, then enter outline minor mode if you wish.

Table 7-4 summarizes outline mode commands. In the next section, we discuss another specialized editing method: editing with rectangles.

Table 7-4. Outline mode commands

Keystrokes Command name Action
(none)
outline-mode
Toggle outline mode.
C-c C-n HeadingsNext outline-next-visible-heading Move to the next heading.
C-c C-p HeadingsPrevious outline-previous-visible-heading Move to the previous heading.
C-c C-f HeadingsNext Same Level outline-forward-same-level Move to the next heading of the same level.
C-c C-b HeadingsPrevious Same Level outline-backward-same-level Move to the previous heading of same level.
C-c C-u HeadingsUp outline-up-heading Move up one heading level.
C-c C-t HideHide Body hide-body Hide all body lines.
C-c C-a ShowShow All show-all Show everything that's hidden.
C-c C-q HideHide Sublevels hide-sublevels Display first level headers only.
C-c C-o HideHide Other hide-other Hide all text and headings outside the current subtree. First level headers show.
C-c @ outline-mark-subtree Mark the current header and all sublevels.
C-c C-^ outline-promote Promote the current heading one level.
C-c C-v outline-demote Demote the current heading one level.
C-c C-d HideHide Subtree hide-subtree Hide subheads and body associated with a given heading.
C-c C-c HideHide Entry hide-entry Hide the body associated with a particular heading (not subheads and their bodies).
C-c C-l HideHide Leaves hide-leaves Hide the body of a particular heading and the bodies of all its subheads.
C-c C-s ShowShow Subtree show-subtree Show the subheads and text associated with a given heading.
C-c C-e ShowShow Entry show-entry Show the body associated with a particular heading (not subheads and their bodies).
C-c C-k ShowShow Branches show-branches Show the body of a heading and bodies of all its subheads.
C-c Tab ShowShow Children show-children Show the next level of subheads associated with a particular heading (none of body text).