From cc683398d818bf017b41908fac2e652785324773 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Mon, 11 Feb 2013 16:07:23 +0100 Subject: [PATCH] Fix failing test on `org-backward-element' * lisp/org.el (org-forward-element, org-backward-element): When no headline is found at the same level, still move forward or backward. --- lisp/org.el | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 22579a0d6..461cdf094 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -22705,7 +22705,7 @@ Move to the next element at the same level, when possible." (cond ((eobp) (error "Cannot move further down")) ((org-with-limited-levels (org-at-heading-p)) (let ((origin (point))) - (org-forward-heading-same-level 1) + (goto-char (org-end-of-subtree nil t)) (unless (org-with-limited-levels (org-at-heading-p)) (goto-char origin) (error "Cannot move further down")))) @@ -22726,10 +22726,13 @@ Move to the previous element at the same level, when possible." ;; At an headline, move to the previous one, if any, or stay ;; here. (let ((origin (point))) - (org-backward-heading-same-level 1) - (unless (org-with-limited-levels (org-at-heading-p)) - (goto-char origin) - (error "Cannot move further up")))) + (org-with-limited-levels (org-backward-heading-same-level 1)) + ;; When current headline has no sibling above, move to its + ;; parent. + (when (= (point) origin) + (or (org-with-limited-levels (org-up-heading-safe)) + (progn (goto-char origin) + (error "Cannot move further up")))))) (t (let* ((trail (org-element-at-point 'keep-trail)) (elem (car trail)) -- 2.11.4.GIT