diff options
| author | Dave Love | 1998-10-02 14:38:12 +0000 |
|---|---|---|
| committer | Dave Love | 1998-10-02 14:38:12 +0000 |
| commit | 4679533511e6651f584d3042ca313ef4c20b5d2a (patch) | |
| tree | 0bf58e5f363e00d1d224500ba6501eb5e71f71e2 | |
| parent | 6480a693a2d702d821c40709965ea975d1ffef7d (diff) | |
| download | emacs-4679533511e6651f584d3042ca313ef4c20b5d2a.tar.gz emacs-4679533511e6651f584d3042ca313ef4c20b5d2a.zip | |
(hide-region-body): Bind
outline-view-change-hook to nil while making repeated calls to
outline-flag-region. Run it once at the end.
(hide-other, hide-sublevels, show-children): Likewise.
| -rw-r--r-- | lisp/textmodes/outline.el | 124 |
1 files changed, 68 insertions, 56 deletions
diff --git a/lisp/textmodes/outline.el b/lisp/textmodes/outline.el index aba8644676f..6a667e749d1 100644 --- a/lisp/textmodes/outline.el +++ b/lisp/textmodes/outline.el | |||
| @@ -496,21 +496,26 @@ Show the heading too, if it is currently invisible." | |||
| 496 | 496 | ||
| 497 | (defun hide-region-body (start end) | 497 | (defun hide-region-body (start end) |
| 498 | "Hide all body lines in the region, but not headings." | 498 | "Hide all body lines in the region, but not headings." |
| 499 | (save-excursion | 499 | ;; Nullify the hook to avoid repeated calls to `outline-flag-region' |
| 500 | (save-restriction | 500 | ;; wasting lots of time running `lazy-lock-fontify-after-outline' |
| 501 | (narrow-to-region start end) | 501 | ;; and run the hook finally. |
| 502 | (goto-char (point-min)) | 502 | (let (outline-view-change-hook) |
| 503 | (if (outline-on-heading-p) | 503 | (save-excursion |
| 504 | (outline-end-of-heading)) | 504 | (save-restriction |
| 505 | (while (not (eobp)) | 505 | (narrow-to-region start end) |
| 506 | (outline-flag-region (point) | 506 | (goto-char (point-min)) |
| 507 | (progn (outline-next-preface) (point)) t) | 507 | (if (outline-on-heading-p) |
| 508 | (if (not (eobp)) | 508 | (outline-end-of-heading)) |
| 509 | (progn | 509 | (while (not (eobp)) |
| 510 | (forward-char | 510 | (outline-flag-region (point) |
| 511 | (if (looking-at "\n\n") | 511 | (progn (outline-next-preface) (point)) t) |
| 512 | 2 1)) | 512 | (if (not (eobp)) |
| 513 | (outline-end-of-heading))))))) | 513 | (progn |
| 514 | (forward-char | ||
| 515 | (if (looking-at "\n\n") | ||
| 516 | 2 1)) | ||
| 517 | (outline-end-of-heading))))))) | ||
| 518 | (run-hooks 'outline-view-change-hook)) | ||
| 514 | 519 | ||
| 515 | (defun show-all () | 520 | (defun show-all () |
| 516 | "Show all of the text in the buffer." | 521 | "Show all of the text in the buffer." |
| @@ -540,31 +545,36 @@ Show the heading too, if it is currently invisible." | |||
| 540 | (if (< levels 1) | 545 | (if (< levels 1) |
| 541 | (error "Must keep at least one level of headers")) | 546 | (error "Must keep at least one level of headers")) |
| 542 | (setq levels (1- levels)) | 547 | (setq levels (1- levels)) |
| 543 | (save-excursion | 548 | (let (outline-view-change-hook) |
| 544 | (goto-char (point-min)) | 549 | (save-excursion |
| 545 | ;; Keep advancing to the next top-level heading. | 550 | (goto-char (point-min)) |
| 546 | (while (or (and (bobp) (outline-on-heading-p)) | 551 | ;; Keep advancing to the next top-level heading. |
| 547 | (outline-next-heading)) | 552 | (while (or (and (bobp) (outline-on-heading-p)) |
| 548 | (let ((end (save-excursion (outline-end-of-subtree) (point)))) | 553 | (outline-next-heading)) |
| 549 | ;; Hide everything under that. | 554 | (let ((end (save-excursion (outline-end-of-subtree) (point)))) |
| 550 | (outline-flag-region (point) end t) | 555 | ;; Hide everything under that. |
| 551 | ;; Show the first LEVELS levels under that. | 556 | (outline-flag-region (point) end t) |
| 552 | (if (> levels 0) | 557 | ;; Show the first LEVELS levels under that. |
| 553 | (show-children levels)) | 558 | (if (> levels 0) |
| 554 | ;; Move to the next, since we already found it. | 559 | (show-children levels)) |
| 555 | (goto-char end))))) | 560 | ;; Move to the next, since we already found it. |
| 561 | (goto-char end))))) | ||
| 562 | (run-hooks 'outline-view-change-hook)) | ||
| 556 | 563 | ||
| 557 | (defun hide-other () | 564 | (defun hide-other () |
| 558 | "Hide everything except current body and parent and top-level headings." | 565 | "Hide everything except current body and parent and top-level headings." |
| 559 | (interactive) | 566 | (interactive) |
| 560 | (hide-sublevels 1) | 567 | (hide-sublevels 1) |
| 561 | (save-excursion | 568 | (let (outline-view-change-hook) |
| 562 | (outline-back-to-heading t) | 569 | (save-excursion |
| 563 | (show-entry) | 570 | (outline-back-to-heading t) |
| 564 | (while (condition-case nil (progn (outline-up-heading 1) t) (error nil)) | 571 | (show-entry) |
| 565 | (outline-flag-region (1- (point)) | 572 | (while (condition-case nil (progn (outline-up-heading 1) t) |
| 566 | (save-excursion (forward-line 1) (point)) | 573 | (error nil)) |
| 567 | nil)))) | 574 | (outline-flag-region (1- (point)) |
| 575 | (save-excursion (forward-line 1) (point)) | ||
| 576 | nil)))) | ||
| 577 | (run-hooks 'outline-view-change-hook)) | ||
| 568 | 578 | ||
| 569 | (defun outline-flag-subtree (flag) | 579 | (defun outline-flag-subtree (flag) |
| 570 | (save-excursion | 580 | (save-excursion |
| @@ -610,27 +620,29 @@ Default is enough to cause the following heading to appear." | |||
| 610 | (if (eobp) | 620 | (if (eobp) |
| 611 | 1 | 621 | 1 |
| 612 | (max 1 (- (funcall outline-level) start-level))))))) | 622 | (max 1 (- (funcall outline-level) start-level))))))) |
| 613 | (save-excursion | 623 | (let (outline-view-change-hook) |
| 614 | (save-restriction | 624 | (save-excursion |
| 615 | (outline-back-to-heading) | 625 | (save-restriction |
| 616 | (setq level (+ level (funcall outline-level))) | 626 | (outline-back-to-heading) |
| 617 | (narrow-to-region (point) | 627 | (setq level (+ level (funcall outline-level))) |
| 618 | (progn (outline-end-of-subtree) | 628 | (narrow-to-region (point) |
| 619 | (if (eobp) (point-max) (1+ (point))))) | 629 | (progn (outline-end-of-subtree) |
| 620 | (goto-char (point-min)) | 630 | (if (eobp) (point-max) (1+ (point))))) |
| 621 | (while (and (not (eobp)) | 631 | (goto-char (point-min)) |
| 622 | (progn | 632 | (while (and (not (eobp)) |
| 623 | (outline-next-heading) | 633 | (progn |
| 624 | (not (eobp)))) | 634 | (outline-next-heading) |
| 625 | (if (<= (funcall outline-level) level) | 635 | (not (eobp)))) |
| 626 | (save-excursion | 636 | (if (<= (funcall outline-level) level) |
| 627 | (outline-flag-region (save-excursion | 637 | (save-excursion |
| 628 | (forward-char -1) | 638 | (outline-flag-region (save-excursion |
| 629 | (if (bolp) | 639 | (forward-char -1) |
| 630 | (forward-char -1)) | 640 | (if (bolp) |
| 631 | (point)) | 641 | (forward-char -1)) |
| 632 | (progn (outline-end-of-heading) (point)) | 642 | (point)) |
| 633 | nil))))))) | 643 | (progn (outline-end-of-heading) (point)) |
| 644 | nil))))))) | ||
| 645 | (run-hooks 'outline-view-change-hook)) | ||
| 634 | 646 | ||
| 635 | (defun outline-up-heading (arg) | 647 | (defun outline-up-heading (arg) |
| 636 | "Move to the heading line of which the present line is a subheading. | 648 | "Move to the heading line of which the present line is a subheading. |