1 ;;; outline.el --- outline mode commands for Emacs
3 ;; Copyright (C) 1986, 93, 94, 95, 97, 2000, 2001
4 ;; Free Software Foundation, Inc.
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
28 ;; This package is a major mode for editing outline-format documents.
29 ;; An outline can be `abstracted' to show headers at any given level,
30 ;; with all stuff below hidden. See the Emacs manual for details.
34 ;; - subtree-terminators
38 (defgroup outlines nil
39 "Support for hierarchical outlining"
43 (defcustom outline-regexp
"[*\^L]+"
44 "*Regular expression to match the beginning of a heading.
45 Any line whose beginning matches this regexp is considered to start a heading.
46 Note that Outline mode only checks this regexp at the start of a line,
47 so the regexp need not (and usually does not) start with `^'.
48 The recommended way to set this is with a Local Variables: list
49 in the file it applies to. See also `outline-heading-end-regexp'."
50 :type
'(choice regexp
(const nil
))
53 (defcustom outline-heading-end-regexp
"\n"
54 "*Regular expression to match the end of a heading line.
55 You can assume that point is at the beginning of a heading when this
56 regexp is searched for. The heading ends at the end of the match.
57 The recommended way to set this is with a `Local Variables:' list
58 in the file it applies to."
62 (defvar outline-mode-prefix-map nil
)
64 (if outline-mode-prefix-map
66 (setq outline-mode-prefix-map
(make-sparse-keymap))
67 (define-key outline-mode-prefix-map
"@" 'outline-mark-subtree
)
68 (define-key outline-mode-prefix-map
"\C-n" 'outline-next-visible-heading
)
69 (define-key outline-mode-prefix-map
"\C-p" 'outline-previous-visible-heading
)
70 (define-key outline-mode-prefix-map
"\C-i" 'show-children
)
71 (define-key outline-mode-prefix-map
"\C-s" 'show-subtree
)
72 (define-key outline-mode-prefix-map
"\C-d" 'hide-subtree
)
73 (define-key outline-mode-prefix-map
"\C-u" 'outline-up-heading
)
74 (define-key outline-mode-prefix-map
"\C-f" 'outline-forward-same-level
)
75 (define-key outline-mode-prefix-map
"\C-b" 'outline-backward-same-level
)
76 (define-key outline-mode-prefix-map
"\C-t" 'hide-body
)
77 (define-key outline-mode-prefix-map
"\C-a" 'show-all
)
78 (define-key outline-mode-prefix-map
"\C-c" 'hide-entry
)
79 (define-key outline-mode-prefix-map
"\C-e" 'show-entry
)
80 (define-key outline-mode-prefix-map
"\C-l" 'hide-leaves
)
81 (define-key outline-mode-prefix-map
"\C-k" 'show-branches
)
82 (define-key outline-mode-prefix-map
"\C-q" 'hide-sublevels
)
83 (define-key outline-mode-prefix-map
"\C-o" 'hide-other
))
85 (defvar outline-mode-menu-bar-map nil
)
86 (if outline-mode-menu-bar-map
88 (setq outline-mode-menu-bar-map
(make-sparse-keymap))
90 (define-key outline-mode-menu-bar-map
[hide]
91 (cons "Hide" (make-sparse-keymap "Hide")))
93 (define-key outline-mode-menu-bar-map [hide hide-other]
94 '("Hide Other" . hide-other))
95 (define-key outline-mode-menu-bar-map [hide hide-sublevels]
96 '("Hide Sublevels" . hide-sublevels))
97 (define-key outline-mode-menu-bar-map [hide hide-subtree]
98 '("Hide Subtree" . hide-subtree))
99 (define-key outline-mode-menu-bar-map [hide hide-entry]
100 '("Hide Entry" . hide-entry))
101 (define-key outline-mode-menu-bar-map [hide hide-body]
102 '("Hide Body" . hide-body))
103 (define-key outline-mode-menu-bar-map [hide hide-leaves]
104 '("Hide Leaves" . hide-leaves))
106 (define-key outline-mode-menu-bar-map [show]
107 (cons "Show" (make-sparse-keymap "Show")))
109 (define-key outline-mode-menu-bar-map [show show-subtree]
110 '("Show Subtree" . show-subtree))
111 (define-key outline-mode-menu-bar-map [show show-children]
112 '("Show Children" . show-children))
113 (define-key outline-mode-menu-bar-map [show show-branches]
114 '("Show Branches" . show-branches))
115 (define-key outline-mode-menu-bar-map [show show-entry]
116 '("Show Entry" . show-entry))
117 (define-key outline-mode-menu-bar-map [show show-all]
118 '("Show All" . show-all))
120 (define-key outline-mode-menu-bar-map [headings]
121 (cons "Headings" (make-sparse-keymap "Headings")))
123 (define-key outline-mode-menu-bar-map [headings copy]
124 '(menu-item "Copy to kill ring" outline-headers-as-kill
125 :enable mark-active))
126 (define-key outline-mode-menu-bar-map [headings outline-backward-same-level]
127 '("Previous Same Level" . outline-backward-same-level))
128 (define-key outline-mode-menu-bar-map [headings outline-forward-same-level]
129 '("Next Same Level" . outline-forward-same-level))
130 (define-key outline-mode-menu-bar-map [headings outline-previous-visible-heading]
131 '("Previous" . outline-previous-visible-heading))
132 (define-key outline-mode-menu-bar-map [headings outline-next-visible-heading]
133 '("Next" . outline-next-visible-heading))
134 (define-key outline-mode-menu-bar-map [headings outline-up-heading]
135 '("Up" . outline-up-heading)))
137 (defvar outline-mode-map nil "")
141 (setq outline-mode-map (nconc (make-sparse-keymap) text-mode-map))
142 (define-key outline-mode-map "\C-c" outline-mode-prefix-map)
143 (define-key outline-mode-map [menu-bar] outline-mode-menu-bar-map))
145 (defvar outline-font-lock-keywords
147 ;; Highlight headings according to the level.
148 (eval . (list (concat "^" outline-regexp ".+")
149 0 '(or (cdr (assq (outline-font-lock-level)
150 '((1 . font-lock-function-name-face)
151 (2 . font-lock-variable-name-face)
152 (3 . font-lock-keyword-face)
153 (4 . font-lock-builtin-face)
154 (5 . font-lock-comment-face)
155 (6 . font-lock-constant-face)
156 (7 . font-lock-type-face)
157 (8 . font-lock-string-face))))
158 font-lock-warning-face)
160 "Additional expressions to highlight in Outline mode.")
162 (defun outline-font-lock-level ()
165 (outline-back-to-heading t)
166 (while (and (not (bobp))
167 (not (eq (funcall outline-level) 1)))
168 (outline-up-heading-all 1)
169 (setq count (1+ count)))
172 (defvar outline-view-change-hook nil
173 "Normal hook to be run after outline visibility changes.")
176 (define-derived-mode outline-mode text-mode "Outline"
177 "Set major mode for editing outlines with selective display.
178 Headings are lines which start with asterisks: one for major headings,
179 two for subheadings, etc. Lines not starting with asterisks are body lines.
181 Body text or subheadings under a heading can be made temporarily
182 invisible, or visible again. Invisible lines are attached to the end
183 of the heading, so they move with it, if the line is killed and yanked
184 back. A heading with text hidden under it is marked with an ellipsis (...).
186 Commands:\\<outline-mode-map>
187 \\[outline-next-visible-heading] outline-next-visible-heading move by visible headings
188 \\[outline-previous-visible-heading] outline-previous-visible-heading
189 \\[outline-forward-same-level] outline-forward-same-level similar but skip subheadings
190 \\[outline-backward-same-level] outline-backward-same-level
191 \\[outline-up-heading] outline-up-heading move from subheading to heading
193 \\[hide-body] make all text invisible (not headings).
194 \\[show-all] make everything in buffer visible.
196 The remaining commands are used when point is on a heading line.
197 They apply to some of the body or subheadings of that heading.
198 \\[hide-subtree] hide-subtree make body and subheadings invisible.
199 \\[show-subtree] show-subtree make body and subheadings visible.
200 \\[show-children] show-children make direct subheadings visible.
201 No effect on body, or subheadings 2 or more levels down.
202 With arg N, affects subheadings N levels down.
203 \\[hide-entry] make immediately following body invisible.
204 \\[show-entry] make it visible.
205 \\[hide-leaves] make body under heading and under its subheadings invisible.
206 The subheadings remain visible.
207 \\[show-branches] make all subheadings at all levels visible.
209 The variable `outline-regexp' can be changed to control what is a heading.
210 A line is a heading if `outline-regexp' matches something at the
211 beginning of the line. The longer the match, the deeper the level.
213 Turning on outline mode calls the value of `text-mode-hook' and then of
214 `outline-mode-hook', if they are non-nil."
215 (make-local-variable 'line-move-ignore-invisible)
216 (setq line-move-ignore-invisible t)
217 ;; Cause use of ellipses for invisible text.
218 (add-to-invisibility-spec '(outline . t))
219 (set (make-local-variable 'paragraph-start)
220 (concat paragraph-start "\\|\\(" outline-regexp "\\)"))
221 ;; Inhibit auto-filling of header lines.
222 (set (make-local-variable 'auto-fill-inhibit-regexp) outline-regexp)
223 (set (make-local-variable 'paragraph-separate)
224 (concat paragraph-separate "\\|\\(" outline-regexp "\\)"))
225 (set (make-local-variable 'font-lock-defaults)
226 '(outline-font-lock-keywords t nil nil backward-paragraph))
227 (setq imenu-generic-expression
228 (list (list nil (concat "^\\(?:" outline-regexp "\\).*$") 0)))
229 (add-hook 'change-major-mode-hook 'show-all nil t))
231 (defcustom outline-minor-mode-prefix "\C-c@"
232 "*Prefix key to use for Outline commands in Outline minor mode.
233 The value of this variable is checked as part of loading Outline mode.
234 After that, changing the prefix key requires manipulating keymaps."
239 (define-minor-mode outline-minor-mode
240 "Toggle Outline minor mode.
241 With arg, turn Outline minor mode on if arg is positive, off otherwise.
242 See the command `outline-mode' for more information on this mode."
243 nil " Outl" (list (cons [menu-bar] outline-mode-menu-bar-map)
244 (cons outline-minor-mode-prefix outline-mode-prefix-map))
245 (if outline-minor-mode
247 ;; Turn off this mode if we change major modes.
248 (add-hook 'change-major-mode-hook
249 (lambda () (outline-minor-mode -1))
251 (set (make-local-variable 'line-move-ignore-invisible) t)
252 ;; Cause use of ellipses for invisible text.
253 (add-to-invisibility-spec '(outline . t)))
254 (setq line-move-ignore-invisible nil)
255 ;; Cause use of ellipses for invisible text.
256 (remove-from-invisibility-spec '(outline . t)))
257 ;; When turning off outline mode, get rid of any outline hiding.
258 (or outline-minor-mode
261 (defcustom outline-level 'outline-level
262 "*Function of no args to compute a header's nesting level in an outline.
263 It can assume point is at the beginning of a header line."
267 ;; This used to count columns rather than characters, but that made ^L
268 ;; appear to be at level 2 instead of 1. Columns would be better for
269 ;; tab handling, but the default regexp doesn't use tabs, and anyone
270 ;; who changes the regexp can also redefine the outline-level variable
272 (defun outline-level ()
273 "Return the depth to which a statement is nested in the outline.
274 Point must be at the beginning of a header line. This is actually
275 the number of characters that `outline-regexp' matches."
277 (looking-at outline-regexp)
278 (- (match-end 0) (match-beginning 0))))
280 (defun outline-next-preface ()
281 "Skip forward to just before the next heading line.
282 If there's no following heading line, stop before the newline
283 at the end of the buffer."
284 (if (re-search-forward (concat "\n\\(" outline-regexp "\\)")
286 (goto-char (match-beginning 0)))
287 (if (and (bolp) (not (bobp)))
290 (defun outline-next-heading ()
291 "Move to the next (possibly invisible) heading line."
293 (if (re-search-forward (concat "\n\\(" outline-regexp "\\)")
295 (goto-char (1+ (match-beginning 0)))))
297 (defun outline-previous-heading ()
298 "Move to the previous (possibly invisible) heading line."
300 (re-search-backward (concat "^\\(" outline-regexp "\\)")
303 (defsubst outline-invisible-p ()
304 "Non-nil if the character after point is invisible."
305 (get-char-property (point) 'invisible))
306 (defun outline-visible ()
307 "Obsolete. Use `outline-invisible-p'."
308 (not (outline-invisible-p)))
310 (defun outline-back-to-heading (&optional invisible-ok)
311 "Move to previous heading line, or beg of this line if it's a heading.
312 Only visible heading lines are considered, unless INVISIBLE-OK is non-nil."
314 (or (outline-on-heading-p invisible-ok)
318 (or (re-search-backward (concat "^\\(" outline-regexp "\\)")
320 (error "before first heading"))
321 (setq found (and (or invisible-ok (outline-visible)) (point)))))
325 (defun outline-on-heading-p (&optional invisible-ok)
326 "Return t if point is on a (visible) heading line.
327 If INVISIBLE-OK is non-nil, an invisible heading line is ok too."
330 (and (bolp) (or invisible-ok (outline-visible))
331 (looking-at outline-regexp))))
333 (defun outline-end-of-heading ()
334 (if (re-search-forward outline-heading-end-regexp nil 'move)
337 (defun outline-next-visible-heading (arg)
338 "Move to the next visible heading line.
339 With argument, repeats or can move backward if negative.
340 A heading line is one that starts with a `*' (or that
341 `outline-regexp' matches)."
346 (while (and (not (bobp)) (< arg 0))
347 (while (and (not (bobp))
348 (re-search-backward (concat "^\\(" outline-regexp "\\)")
350 (not (outline-visible))))
352 (while (and (not (eobp)) (> arg 0))
353 (while (and (not (eobp))
354 (re-search-forward (concat "^\\(" outline-regexp "\\)")
356 (not (outline-visible))))
360 (defun outline-previous-visible-heading (arg)
361 "Move to the previous heading line.
362 With argument, repeats or can move forward if negative.
363 A heading line is one that starts with a `*' (or that
364 `outline-regexp' matches)."
366 (outline-next-visible-heading (- arg)))
368 (defun outline-mark-subtree ()
369 "Mark the current subtree in an outlined document.
370 This puts point at the start of the current subtree, and mark at the end."
373 (if (outline-on-heading-p)
374 ;; we are already looking at a heading
376 ;; else go back to previous heading
377 (outline-previous-visible-heading 1))
379 (outline-end-of-subtree)
383 (defun outline-flag-region (from to flag)
384 "Hides or shows lines from FROM to TO, according to FLAG.
385 If FLAG is nil then text is shown, while if FLAG is t the text is hidden."
389 (outline-discard-overlays (point) to 'outline)
391 (let ((o (make-overlay (point) to)))
392 (overlay-put o 'invisible 'outline)
393 (overlay-put o 'isearch-open-invisible
394 'outline-isearch-open-invisible))))
395 (run-hooks 'outline-view-change-hook))
398 ;; Function to be set as an outline-isearch-open-invisible' property
399 ;; to the overlay that makes the outline invisible (see
400 ;; `outline-flag-region').
401 (defun outline-isearch-open-invisible (overlay)
402 ;; We rely on the fact that isearch places point one the matched text.
406 ;; Exclude from the region BEG ... END all overlays
407 ;; which have PROP as the value of the `invisible' property.
408 ;; Exclude them by shrinking them to exclude BEG ... END,
409 ;; or even by splitting them if necessary.
410 ;; Overlays without such an `invisible' property are not touched.
411 (defun outline-discard-overlays (beg end prop)
413 (setq beg (prog1 end (setq end beg))))
415 (dolist (o (overlays-in beg end))
416 (if (eq (overlay-get o 'invisible) prop)
417 ;; Either push this overlay outside beg...end
418 ;; or split it to exclude beg...end
419 ;; or delete it entirely (if it is contained in beg...end).
420 (if (< (overlay-start o) beg)
421 (if (> (overlay-end o) end)
423 (move-overlay (outline-copy-overlay o)
424 (overlay-start o) beg)
425 (move-overlay o end (overlay-end o)))
426 (move-overlay o (overlay-start o) beg))
427 (if (> (overlay-end o) end)
428 (move-overlay o end (overlay-end o))
429 (delete-overlay o)))))))
431 ;; Make a copy of overlay O, with the same beginning, end and properties.
432 (defun outline-copy-overlay (o)
433 (let ((o1 (make-overlay (overlay-start o) (overlay-end o)
435 (props (overlay-properties o)))
437 (overlay-put o1 (car props) (nth 1 props))
438 (setq props (cdr (cdr props))))
442 "Hide the body directly following this heading."
444 (outline-back-to-heading)
445 (outline-end-of-heading)
447 (outline-flag-region (point) (progn (outline-next-preface) (point)) t)))
450 "Show the body directly following this heading.
451 Show the heading too, if it is currently invisible."
454 (outline-back-to-heading t)
455 (outline-flag-region (1- (point))
456 (progn (outline-next-preface) (point)) nil)))
459 "Hide all of buffer except headings."
461 (hide-region-body (point-min) (point-max)))
463 (defun hide-region-body (start end)
464 "Hide all body lines in the region, but not headings."
465 ;; Nullify the hook to avoid repeated calls to `outline-flag-region'
466 ;; wasting lots of time running `lazy-lock-fontify-after-outline'
467 ;; and run the hook finally.
468 (let (outline-view-change-hook)
471 (narrow-to-region start end)
472 (goto-char (point-min))
473 (if (outline-on-heading-p)
474 (outline-end-of-heading))
476 (outline-flag-region (point)
477 (progn (outline-next-preface) (point)) t)
479 (forward-char (if (looking-at "\n\n") 2 1))
480 (outline-end-of-heading))))))
481 (run-hooks 'outline-view-change-hook))
484 "Show all of the text in the buffer."
486 (outline-flag-region (point-min) (point-max) nil))
488 (defun hide-subtree ()
489 "Hide everything after this heading at deeper levels."
491 (outline-flag-subtree t))
493 (defun hide-leaves ()
494 "Hide all body after this heading at deeper levels."
496 (outline-back-to-heading)
498 (outline-end-of-heading)
499 (hide-region-body (point) (progn (outline-end-of-subtree) (point)))))
501 (defun show-subtree ()
502 "Show everything after this heading at deeper levels."
504 (outline-flag-subtree nil))
506 (defun hide-sublevels (levels)
507 "Hide everything but the top LEVELS levels of headers, in whole buffer."
510 (error "Must keep at least one level of headers"))
511 (setq levels (1- levels))
512 (let (outline-view-change-hook)
514 (goto-char (point-min))
515 ;; Keep advancing to the next top-level heading.
516 (while (or (and (bobp) (outline-on-heading-p))
517 (outline-next-heading))
518 (let ((end (save-excursion (outline-end-of-subtree) (point))))
519 ;; Hide everything under that.
520 (outline-flag-region (point) end t)
521 ;; Show the first LEVELS levels under that.
523 (show-children levels))
524 ;; Move to the next, since we already found it.
526 (run-hooks 'outline-view-change-hook))
529 "Hide everything except current body and parent and top-level headings."
532 (let (outline-view-change-hook)
534 (outline-back-to-heading t)
536 (while (condition-case nil (progn (outline-up-heading 1) (not (bobp)))
538 (outline-flag-region (1- (point))
539 (save-excursion (forward-line 1) (point))
541 (run-hooks 'outline-view-change-hook))
543 (defun outline-flag-subtree (flag)
545 (outline-back-to-heading)
546 (outline-end-of-heading)
547 (outline-flag-region (point)
548 (progn (outline-end-of-subtree) (point))
551 (defun outline-end-of-subtree ()
552 (outline-back-to-heading)
553 (let ((opoint (point))
555 (level (funcall outline-level)))
556 (while (and (not (eobp))
557 (or first (> (funcall outline-level) level)))
559 (outline-next-heading))
562 ;; Go to end of line before heading
565 ;; leave blank line before heading
566 (forward-char -1))))))
568 (defun show-branches ()
569 "Show all subheadings of this heading, but not their bodies."
571 (show-children 1000))
573 (defun show-children (&optional level)
574 "Show all direct subheadings of this heading.
575 Prefix arg LEVEL is how many levels below the current level should be shown.
576 Default is enough to cause the following heading to appear."
579 (if level (prefix-numeric-value level)
581 (outline-back-to-heading)
582 (let ((start-level (funcall outline-level)))
583 (outline-next-heading)
586 (max 1 (- (funcall outline-level) start-level)))))))
587 (let (outline-view-change-hook)
590 (outline-back-to-heading)
591 (setq level (+ level (funcall outline-level)))
592 (narrow-to-region (point)
593 (progn (outline-end-of-subtree)
594 (if (eobp) (point-max) (1+ (point)))))
595 (goto-char (point-min))
596 (while (and (not (eobp))
598 (outline-next-heading)
600 (if (<= (funcall outline-level) level)
602 (outline-flag-region (save-excursion
607 (progn (outline-end-of-heading) (point))
609 (run-hooks 'outline-view-change-hook))
611 (defun outline-up-heading-all (arg)
612 "Move to the heading line of which the present line is a subheading.
613 This function considers both visible and invisible heading lines.
614 With argument, move up ARG levels."
615 (outline-back-to-heading t)
616 (if (eq (funcall outline-level) 1)
617 (error "Already at top level of the outline"))
618 (while (and (> (funcall outline-level) 1)
621 (let ((present-level (funcall outline-level)))
622 (while (and (not (< (funcall outline-level) present-level))
624 (outline-previous-heading))
625 (setq arg (- arg 1)))))
627 (defun outline-up-heading (arg)
628 "Move to the visible heading line of which the present line is a subheading.
629 With argument, move up ARG levels."
631 (outline-back-to-heading)
632 (if (eq (funcall outline-level) 1)
633 (error "Already at top level of the outline"))
634 (while (and (> (funcall outline-level) 1)
637 (let ((present-level (funcall outline-level)))
638 (while (and (not (< (funcall outline-level) present-level))
640 (outline-previous-visible-heading 1))
641 (setq arg (- arg 1)))))
643 (defun outline-forward-same-level (arg)
644 "Move forward to the ARG'th subheading at same level as this one.
645 Stop at the first and last subheadings of a superior heading."
647 (outline-back-to-heading)
649 (let ((point-to-move-to (save-excursion
650 (outline-get-next-sibling))))
653 (goto-char point-to-move-to)
657 (error "No following same-level heading"))))))
659 (defun outline-get-next-sibling ()
660 "Move to next heading of the same level, and return point or nil if none."
661 (let ((level (funcall outline-level)))
662 (outline-next-visible-heading 1)
663 (while (and (> (funcall outline-level) level)
665 (outline-next-visible-heading 1))
666 (if (< (funcall outline-level) level)
670 (defun outline-backward-same-level (arg)
671 "Move backward to the ARG'th subheading at same level as this one.
672 Stop at the first and last subheadings of a superior heading."
674 (outline-back-to-heading)
676 (let ((point-to-move-to (save-excursion
677 (outline-get-last-sibling))))
680 (goto-char point-to-move-to)
684 (error "No previous same-level heading"))))))
686 (defun outline-get-last-sibling ()
687 "Move to previous heading of the same level, and return point or nil if none."
688 (let ((level (funcall outline-level)))
689 (outline-previous-visible-heading 1)
690 (while (and (> (funcall outline-level) level)
692 (outline-previous-visible-heading 1))
693 (if (< (funcall outline-level) level)
697 (defun outline-headers-as-kill (beg end)
698 "Save the visible outline headers in region at the start of the kill ring.
700 Text shown between the headers isn't copied. Two newlines are
701 inserted between saved headers. Yanking the result may be a
702 convenient way to make a table of contents of the buffer."
706 (narrow-to-region beg end)
707 (goto-char (point-min))
708 (let ((buffer (current-buffer))
711 (with-current-buffer buffer
712 ;; Boundary condition: starting on heading:
713 (when (outline-on-heading-p)
714 (outline-back-to-heading)
716 end (progn (outline-end-of-heading)
718 (insert-buffer-substring buffer start end)
720 (let ((temp-buffer (current-buffer)))
721 (with-current-buffer buffer
722 (while (outline-next-heading)
723 (when (outline-visible)
725 end (progn (outline-end-of-heading) (point)))
726 (with-current-buffer temp-buffer
727 (insert-buffer-substring buffer start end)
729 (kill-new (buffer-string)))))))
734 ;;; outline.el ends here