# HG changeset patch # User Richard M. Stallman # Date 933524819 0 # Node ID 01b59199fcbcda8932c26950f7bfc2a9ddcef4d1 # Parent 820b95325cb52c34eb392289c9baf77f67da4365 (outline-next-heading): New function. (outline-up-heading-all): New function. (outline-font-lock-level): Using outline-up-heading-all. Tell outline-back-to-heading to accept invisible headings. diff -r 820b95325cb5 -r 01b59199fcbc lisp/textmodes/outline.el --- a/lisp/textmodes/outline.el Sun Aug 01 16:12:32 1999 +0000 +++ b/lisp/textmodes/outline.el Sun Aug 01 16:26:59 1999 +0000 @@ -166,10 +166,10 @@ (defun outline-font-lock-level () (let ((count 1)) (save-excursion - (outline-back-to-heading) + (outline-back-to-heading t) (condition-case nil (while (not (bobp)) - (outline-up-heading 1) + (outline-up-heading-all 1) (setq count (1+ count))) (error))) count)) @@ -644,8 +644,44 @@ nil))))))) (run-hooks 'outline-view-change-hook)) +(defun outline-up-heading-all (arg) + "Move to the heading line of which the present line is a subheading. +This function considers both visible and invisible heading lines. +With argument, move up ARG levels." + (outline-back-to-heading t) + (if (eq (funcall outline-level) 1) + (error "Already at top level of the outline")) + (while (and (> (funcall outline-level) 1) + (> arg 0) + (not (bobp))) + (let ((present-level (funcall outline-level))) + (while (and (not (< (funcall outline-level) present-level)) + (not (bobp))) + (outline-next-heading -1)) + (setq arg (- arg 1))))) + +(defun outline-next-heading (arg) + "Move to the next heading line (visible or invisible). +With argument, repeats or can move backward if negative. +A heading line is one that starts with a `*' (or that +`outline-regexp' matches)." + (if (< arg 0) + (beginning-of-line) + (end-of-line)) + (while (and (not (bobp)) (< arg 0)) + (while (and (not (bobp)) + (re-search-backward (concat "^\\(" outline-regexp "\\)") + nil 'move))) + (setq arg (1+ arg))) + (while (and (not (eobp)) (> arg 0)) + (while (and (not (eobp)) + (re-search-forward (concat "^\\(" outline-regexp "\\)") + nil 'move))) + (setq arg (1- arg))) + (beginning-of-line)) + (defun outline-up-heading (arg) - "Move to the heading line of which the present line is a subheading. + "Move to the visible heading line of which the present line is a subheading. With argument, move up ARG levels." (interactive "p") (outline-back-to-heading)