org.el (org-forward-element, org-backward-element): Throw a message instead of an error
* org.el (org-forward-element, org-backward-element): Throw a message instead of an error when trying to move from a position where there is no element.
This commit is contained in:
parent
17b6b708ba
commit
9bec9f1cd0
|
@ -23155,9 +23155,10 @@ Move to the next element at the same level, when possible."
|
||||||
(let* ((elem (org-element-at-point))
|
(let* ((elem (org-element-at-point))
|
||||||
(end (org-element-property :end elem))
|
(end (org-element-property :end elem))
|
||||||
(parent (org-element-property :parent elem)))
|
(parent (org-element-property :parent elem)))
|
||||||
(if (and parent (= (org-element-property :contents-end parent) end))
|
(cond ((and parent (= (org-element-property :contents-end parent) end))
|
||||||
(goto-char (org-element-property :end parent))
|
(goto-char (org-element-property :end parent)))
|
||||||
(goto-char end))))))
|
((integer-or-marker-p end) (goto-char end))
|
||||||
|
(t (message "No element at point")))))))
|
||||||
|
|
||||||
(defun org-backward-element ()
|
(defun org-backward-element ()
|
||||||
"Move backward by one element.
|
"Move backward by one element.
|
||||||
|
@ -23183,6 +23184,7 @@ Move to the previous element at the same level, when possible."
|
||||||
(cond
|
(cond
|
||||||
;; Move to beginning of current element if point isn't
|
;; Move to beginning of current element if point isn't
|
||||||
;; there already.
|
;; there already.
|
||||||
|
((null beg) (message "No element at point"))
|
||||||
((/= (point) beg) (goto-char beg))
|
((/= (point) beg) (goto-char beg))
|
||||||
(prev-elem (goto-char (org-element-property :begin prev-elem)))
|
(prev-elem (goto-char (org-element-property :begin prev-elem)))
|
||||||
((org-before-first-heading-p) (goto-char (point-min)))
|
((org-before-first-heading-p) (goto-char (point-min)))
|
||||||
|
|
Loading…
Reference in New Issue