>From ff792a00e28b7b0ca4fde98f72611ef8079daf04 Mon Sep 17 00:00:00 2001 From: Rafael Laboissiere Date: Wed, 12 Apr 2017 22:18:54 +0200 Subject: [PATCH] Do not fail when heading is at the beginning of the buffer * org.el (org-forward-heading-same-level): Do not move backward when at the beginning of the buffer --- lisp/org.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lisp/org.el b/lisp/org.el index 17caa3fa6..b46369ad5 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -24071,7 +24071,8 @@ non-nil it will also look at invisible ones." (count (if arg (abs arg) 1)) (result (point))) (while (and (prog1 (> count 0) - (forward-char (if (and arg (< arg 0)) -1 1))) + (forward-char (if (and arg (< arg 0)) + (if (= (point) 1) 0 -1) 1))) (funcall f org-outline-regexp-bol nil 'move)) (let ((l (- (match-end 0) (match-beginning 0) 1))) (cond ((< l level) (setq count 0)) -- 2.11.0