changeset 6175:340f5eb2e8b6

(outline-on-heading-p): Use bolp. (show-children): Use outline-back-to-heading. (outline-next-preface): Don't retreat over \n or ^M if no more headers.
author Richard M. Stallman <rms@gnu.org>
date Thu, 03 Mar 1994 19:17:47 +0000
parents 3902f1241d1c
children 1dbec303c87b
files lisp/textmodes/ooutline.el
diffstat 1 files changed, 29 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/textmodes/ooutline.el	Thu Mar 03 18:27:51 1994 +0000
+++ b/lisp/textmodes/ooutline.el	Thu Mar 03 19:17:47 1994 +0000
@@ -234,9 +234,10 @@
   "Skip forward to just before the next heading line."
   (if (re-search-forward (concat "[\n\^M]\\(" outline-regexp "\\)")
 			 nil 'move)
-      (goto-char (match-beginning 0)))
-  (if (memq (preceding-char) '(?\n ?\^M))
-      (forward-char -1)))
+      (progn
+	(goto-char (match-beginning 0))
+	(if (memq (preceding-char) '(?\n ?\^M))
+	    (forward-char -1)))))
 
 (defun outline-next-heading ()
   "Move to the next (possibly invisible) heading line."
@@ -246,17 +247,17 @@
       (goto-char (1+ (match-beginning 0)))))
 
 (defun outline-back-to-heading ()
-  "Move to previous (possibly invisible) heading line,
-or to the beginning of this line if it is a heading line."
+  "Move to previous heading line, or beg of this line if it's a heading.
+Only visible heading lines are considered."
   (beginning-of-line)
   (or (outline-on-heading-p)
       (re-search-backward (concat "^\\(" outline-regexp "\\)") nil 'move)))
 
 (defun outline-on-heading-p ()
-  "Return T if point is on a header line."
+  "Return T if point is on a (visible) heading line."
   (save-excursion
     (beginning-of-line)
-    (and (eq (preceding-char) ?\n)
+    (and (bobp)
 	 (looking-at outline-regexp))))
 
 (defun outline-end-of-heading ()
@@ -423,33 +424,33 @@
   (setq level
 	(if level (prefix-numeric-value level)
 	  (save-excursion
-	    (beginning-of-line)
+	    (outline-back-to-heading)
 	    (let ((start-level (funcall outline-level)))
 	      (outline-next-heading)
 	      (if (eobp)
 		  1
 		(max 1 (- (funcall outline-level) start-level)))))))
   (save-excursion
-   (save-restriction
-    (beginning-of-line)
-    (setq level (+ level (funcall outline-level)))
-    (narrow-to-region (point)
-		      (progn (outline-end-of-subtree)
-			     (if (eobp) (point-max) (1+ (point)))))
-    (goto-char (point-min))
-    (while (and (not (eobp))
-		(progn
-		 (outline-next-heading)
-		 (not (eobp))))
-      (if (<= (funcall outline-level) level)
-	  (save-excursion
-	    (outline-flag-region (save-excursion
-				   (forward-char -1)
-				   (if (memq (preceding-char) '(?\n ?\^M))
-				       (forward-char -1))
-				   (point))
-				 (progn (outline-end-of-heading) (point))
-				 ?\n)))))))
+    (save-restriction
+      (outline-back-to-heading)
+      (setq level (+ level (funcall outline-level)))
+      (narrow-to-region (point)
+			(progn (outline-end-of-subtree)
+			       (if (eobp) (point-max) (1+ (point)))))
+      (goto-char (point-min))
+      (while (and (not (eobp))
+		  (progn
+		    (outline-next-heading)
+		    (not (eobp))))
+	(if (<= (funcall outline-level) level)
+	    (save-excursion
+	      (outline-flag-region (save-excursion
+				     (forward-char -1)
+				     (if (memq (preceding-char) '(?\n ?\^M))
+					 (forward-char -1))
+				     (point))
+				   (progn (outline-end-of-heading) (point))
+				   ?\n)))))))
 
 (defun outline-up-heading (arg)
   "Move to the heading line of which the present line is a subheading.