# HG changeset patch # User Eli Zaretskii # Date 1166828235 0 # Node ID dfa668ddf262cf06307c25bde88d449e7192ffec # Parent 1f7a9ccf81422b1f694c97f287bd2c38698c868c (outline-next-visible-heading): Fix the case with a header at end-of-file with no final newline. diff -r 1f7a9ccf8142 -r dfa668ddf262 lisp/outline.el --- a/lisp/outline.el Fri Dec 22 22:46:22 2006 +0000 +++ b/lisp/outline.el Fri Dec 22 22:57:15 2006 +0000 @@ -652,19 +652,24 @@ (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) - (outline-invisible-p))) - (setq arg (1+ arg))) - (while (and (not (eobp)) (> arg 0)) - (while (and (not (eobp)) - (re-search-forward (concat "^\\(?:" outline-regexp "\\)") - nil 'move) - (outline-invisible-p (match-beginning 0)))) - (setq arg (1- arg))) - (beginning-of-line)) + (let (found-heading-p) + (while (and (not (bobp)) (< arg 0)) + (while (and (not (bobp)) + (setq found-heading-p + (re-search-backward + (concat "^\\(?:" outline-regexp "\\)") + nil 'move)) + (outline-invisible-p))) + (setq arg (1+ arg))) + (while (and (not (eobp)) (> arg 0)) + (while (and (not (eobp)) + (setq found-heading-p + (re-search-forward + (concat "^\\(?:" outline-regexp "\\)") + nil 'move)) + (outline-invisible-p (match-beginning 0)))) + (setq arg (1- arg))) + (if found-heading-p (beginning-of-line)))) (defun outline-previous-visible-heading (arg) "Move to the previous heading line.