summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Guerry <bzg@altern.org>2013-07-04 15:26:25 +0200
committerBastien Guerry <bzg@altern.org>2013-07-04 15:26:25 +0200
commit9bec9f1cd07340ea50325fbda849e30997c42558 (patch)
tree8bf896b1382a0a321c161a34a94e996afac25500
parent17b6b708baf23b4e8d1d8f853d062fdbdefb20d3 (diff)
downloadorg-mode-9bec9f1cd07340ea50325fbda849e30997c42558.tar.gz
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.
-rw-r--r--lisp/org.el8
1 files changed, 5 insertions, 3 deletions
diff --git a/lisp/org.el b/lisp/org.el
index e1b428d..952ff5f 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -23155,9 +23155,10 @@ Move to the next element at the same level, when possible."
(let* ((elem (org-element-at-point))
(end (org-element-property :end elem))
(parent (org-element-property :parent elem)))
- (if (and parent (= (org-element-property :contents-end parent) end))
- (goto-char (org-element-property :end parent))
- (goto-char end))))))
+ (cond ((and parent (= (org-element-property :contents-end parent) end))
+ (goto-char (org-element-property :end parent)))
+ ((integer-or-marker-p end) (goto-char end))
+ (t (message "No element at point")))))))
(defun org-backward-element ()
"Move backward by one element.
@@ -23183,6 +23184,7 @@ Move to the previous element at the same level, when possible."
(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))
(prev-elem (goto-char (org-element-property :begin prev-elem)))
((org-before-first-heading-p) (goto-char (point-min)))