Function: org-backward-element
org-backward-element is an interactive and byte-compiled function
defined in org.el.gz.
Signature
(org-backward-element)
Documentation
Move backward by one element.
Move to the previous element at the same level, when possible.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/org/org.el.gz
(defun org-backward-element ()
"Move backward by one element.
Move to the previous element at the same level, when possible."
(interactive)
(cond ((bobp) (user-error "Cannot move further up"))
((org-with-limited-levels (org-at-heading-p))
;; At a headline, move to the previous one, if any, or stay
;; here.
(let ((origin (point)))
(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)
(user-error "Cannot move further up"))))))
(t
(let* ((elem (org-element-at-point))
(beg (org-element-begin elem)))
(cond
;; Move to beginning of current element if point isn't
;; there already.
((null beg) (message "No element at point"))
((/= (point) beg) (goto-char beg))
(t (goto-char beg)
(skip-chars-backward " \r\t\n")
(unless (bobp)
(let ((prev (org-element-at-point)))
(goto-char (org-element-begin prev))
(while (and (setq prev (org-element-parent prev))
(<= (org-element-end prev) beg))
(goto-char (org-element-begin prev)))))))))))