aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1994-05-02 07:45:48 +0000
committerRichard M. Stallman1994-05-02 07:45:48 +0000
commita2b3bd0f1109f99beb870a4a80656af7e3976228 (patch)
treedea4bbfa2b407ec39e1ca0045b0fc0f041c21474
parentec334d84c036de531886bf1559ae591c3f77239a (diff)
downloademacs-a2b3bd0f1109f99beb870a4a80656af7e3976228.tar.gz
emacs-a2b3bd0f1109f99beb870a4a80656af7e3976228.zip
Doc fixes.
(hide-sublevels): Rewritten faster and simpler.
-rw-r--r--lisp/textmodes/ooutline.el39
1 files changed, 21 insertions, 18 deletions
diff --git a/lisp/textmodes/ooutline.el b/lisp/textmodes/ooutline.el
index 399c5017ab1..236ed3afc80 100644
--- a/lisp/textmodes/ooutline.el
+++ b/lisp/textmodes/ooutline.el
@@ -265,7 +265,7 @@ Only visible heading lines are considered."
265 (error "before first heading"))) 265 (error "before first heading")))
266 266
267(defun outline-on-heading-p () 267(defun outline-on-heading-p ()
268 "Return T if point is on a (visible) heading line." 268 "Return t if point is on a (visible) heading line."
269 (save-excursion 269 (save-excursion
270 (beginning-of-line) 270 (beginning-of-line)
271 (and (bolp) 271 (and (bolp)
@@ -365,21 +365,26 @@ while if FLAG is `\\^M' (control-M) the text is hidden."
365 (outline-flag-subtree ?\n)) 365 (outline-flag-subtree ?\n))
366 366
367(defun hide-sublevels (levels) 367(defun hide-sublevels (levels)
368 "Hide everything except the top LEVELS levels of headers." 368 "Hide everything but the top LEVELS levels of headers, in whole buffer."
369 (interactive "p") 369 (interactive "p")
370 (if (< levels 1) 370 (if (< levels 1)
371 (error "Must keep at least one level of headers")) 371 (error "Must keep at least one level of headers"))
372 (setq levels (1- levels)) 372 (setq levels (1- levels))
373 (save-excursion 373 (save-excursion
374 (goto-char (point-min)) 374 (goto-char (point-min))
375 (or (outline-on-heading-p) 375 (condition-case nil
376 (outline-next-heading)) 376 ;; Keep advancing to the next top-level heading.
377 (hide-subtree) 377 (while (progn (or (and (bobp) (outline-on-heading-p))
378 (show-children levels) 378 (outline-next-heading))
379 (condition-case err 379 (not (eobp)))
380 (while (outline-get-next-sibling) 380 (setq first nil)
381 (hide-subtree) 381 (let ((end (save-excursion (outline-end-of-subtree) (point))))
382 (show-children levels)) 382 ;; Hide everything under that.
383 (outline-flag-region (point) end ?\^M)
384 ;; Show the first LEVELS levels under that.
385 (show-children levels)
386 ;; Move to the next, since we already found it.
387 (goto-char end)))
383 (error nil)))) 388 (error nil))))
384 389
385(defun hide-other () 390(defun hide-other ()
@@ -482,8 +487,8 @@ With argument, move up ARG levels."
482 (setq arg (- arg 1))))) 487 (setq arg (- arg 1)))))
483 488
484(defun outline-forward-same-level (arg) 489(defun outline-forward-same-level (arg)
485 "Move forward to the ARG'th subheading from here of the same level as the 490 "Move forward to the ARG'th subheading at same level as this one.
486present one. It stops at the first and last subheadings of a superior heading." 491Stop at the first and last subheadings of a superior heading."
487 (interactive "p") 492 (interactive "p")
488 (outline-back-to-heading) 493 (outline-back-to-heading)
489 (while (> arg 0) 494 (while (> arg 0)
@@ -498,8 +503,7 @@ present one. It stops at the first and last subheadings of a superior heading."
498 (error "")))))) 503 (error ""))))))
499 504
500(defun outline-get-next-sibling () 505(defun outline-get-next-sibling ()
501 "Position the point at the next heading of the same level, 506 "Move to next heading of the same level, and return point or nil if none."
502and return that position or nil if it cannot be found."
503 (let ((level (funcall outline-level))) 507 (let ((level (funcall outline-level)))
504 (outline-next-visible-heading 1) 508 (outline-next-visible-heading 1)
505 (while (and (> (funcall outline-level) level) 509 (while (and (> (funcall outline-level) level)
@@ -510,8 +514,8 @@ and return that position or nil if it cannot be found."
510 (point)))) 514 (point))))
511 515
512(defun outline-backward-same-level (arg) 516(defun outline-backward-same-level (arg)
513 "Move backward to the ARG'th subheading from here of the same level as the 517 "Move backward to the ARG'th subheading at same level as this one.
514present one. It stops at the first and last subheadings of a superior heading." 518Stop at the first and last subheadings of a superior heading."
515 (interactive "p") 519 (interactive "p")
516 (outline-back-to-heading) 520 (outline-back-to-heading)
517 (while (> arg 0) 521 (while (> arg 0)
@@ -526,8 +530,7 @@ present one. It stops at the first and last subheadings of a superior heading."
526 (error "")))))) 530 (error ""))))))
527 531
528(defun outline-get-last-sibling () 532(defun outline-get-last-sibling ()
529 "Position the point at the previous heading of the same level, 533 "Move to next heading of the same level, and return point or nil if none."
530and return that position or nil if it cannot be found."
531 (let ((level (funcall outline-level))) 534 (let ((level (funcall outline-level)))
532 (outline-previous-visible-heading 1) 535 (outline-previous-visible-heading 1)
533 (while (and (> (funcall outline-level) level) 536 (while (and (> (funcall outline-level) level)