Use `user-error' when moving or modifying the element at point is not possible

* org.el (org-move-subtree-down, org-forward-element)
(org-backward-element):
* org-table.el (org-table-previous-field)
(org-table-move-column, org-table-move-row):
* org-list.el (org-move-item-down, org-move-item-up)
(org-cycle-item-indentation): Use `user-error' when moving or
modifying the element at point is not possible.
This commit is contained in:
Bastien Guerry 2013-02-22 10:31:35 +01:00
parent db0143f70e
commit 71c3c12b39
3 changed files with 12 additions and 12 deletions

View file

@ -2133,7 +2133,7 @@ the item, so this really moves item trees."
(prevs (org-list-prevs-alist struct)) (prevs (org-list-prevs-alist struct))
(next-item (org-list-get-next-item (point-at-bol) struct prevs))) (next-item (org-list-get-next-item (point-at-bol) struct prevs)))
(unless (or next-item org-list-use-circular-motion) (unless (or next-item org-list-use-circular-motion)
(error "Cannot move this item further down")) (user-error "Cannot move this item further down"))
(if (not next-item) (if (not next-item)
(setq struct (org-list-send-item item 'begin struct)) (setq struct (org-list-send-item item 'begin struct))
(setq struct (org-list-swap-items item next-item struct)) (setq struct (org-list-swap-items item next-item struct))
@ -2154,7 +2154,7 @@ the item, so this really moves item trees."
(prevs (org-list-prevs-alist struct)) (prevs (org-list-prevs-alist struct))
(prev-item (org-list-get-prev-item (point-at-bol) struct prevs))) (prev-item (org-list-get-prev-item (point-at-bol) struct prevs)))
(unless (or prev-item org-list-use-circular-motion) (unless (or prev-item org-list-use-circular-motion)
(error "Cannot move this item further up")) (user-error "Cannot move this item further up"))
(if (not prev-item) (if (not prev-item)
(setq struct (org-list-send-item item 'end struct)) (setq struct (org-list-send-item item 'end struct))
(setq struct (org-list-swap-items prev-item item struct))) (setq struct (org-list-swap-items prev-item item struct)))
@ -2756,7 +2756,7 @@ Return t at each successful move."
(cond (cond
((ignore-errors (org-list-indent-item-generic 1 t struct))) ((ignore-errors (org-list-indent-item-generic 1 t struct)))
((ignore-errors (org-list-indent-item-generic -1 t struct))) ((ignore-errors (org-list-indent-item-generic -1 t struct)))
(t (error "Cannot move item")))) (t (user-error "Cannot move item"))))
t)))) t))))
(defun org-sort-list (&optional with-case sorting-type getkey-func compare-func) (defun org-sort-list (&optional with-case sorting-type getkey-func compare-func)

View file

@ -1039,7 +1039,7 @@ Before doing so, re-align the table if necessary."
(progn (progn
(re-search-backward "|" (org-table-begin)) (re-search-backward "|" (org-table-begin))
(re-search-backward "|" (org-table-begin))) (re-search-backward "|" (org-table-begin)))
(error (error "Cannot move to previous table field"))) (error (user-error "Cannot move to previous table field")))
(while (looking-at "|\\(-\\|[ \t]*$\\)") (while (looking-at "|\\(-\\|[ \t]*$\\)")
(re-search-backward "|" (org-table-begin))) (re-search-backward "|" (org-table-begin)))
(if (looking-at "| ?") (if (looking-at "| ?")
@ -1472,9 +1472,9 @@ first dline below it is used. When ABOVE is non-nil, the one above is used."
(linepos (org-current-line)) (linepos (org-current-line))
(colpos (if left (1- col) (1+ col)))) (colpos (if left (1- col) (1+ col))))
(if (and left (= col 1)) (if (and left (= col 1))
(error "Cannot move column further left")) (user-error "Cannot move column further left"))
(if (and (not left) (looking-at "[^|\n]*|[^|\n]*$")) (if (and (not left) (looking-at "[^|\n]*|[^|\n]*$"))
(error "Cannot move column further right")) (user-error "Cannot move column further right"))
(goto-char beg) (goto-char beg)
(while (< (point) end) (while (< (point) end)
(if (org-at-table-hline-p) (if (org-at-table-hline-p)
@ -1522,7 +1522,7 @@ first dline below it is used. When ABOVE is non-nil, the one above is used."
(beginning-of-line tonew) (beginning-of-line tonew)
(unless (org-at-table-p) (unless (org-at-table-p)
(goto-char pos) (goto-char pos)
(error "Cannot move row further")) (user-error "Cannot move row further"))
(setq hline2p (looking-at org-table-hline-regexp)) (setq hline2p (looking-at org-table-hline-regexp))
(goto-char pos) (goto-char pos)
(beginning-of-line 1) (beginning-of-line 1)

View file

@ -7929,7 +7929,7 @@ case."
(while (> cnt 0) (while (> cnt 0)
(or (and (funcall movfunc) (looking-at org-outline-regexp)) (or (and (funcall movfunc) (looking-at org-outline-regexp))
(progn (goto-char beg0) (progn (goto-char beg0)
(error "Cannot move past superior level or buffer limit"))) (user-error "Cannot move past superior level or buffer limit")))
(setq cnt (1- cnt))) (setq cnt (1- cnt)))
(if (> arg 0) (if (> arg 0)
;; Moving forward - still need to move over subtree ;; Moving forward - still need to move over subtree
@ -22702,13 +22702,13 @@ When BLOCK-REGEXP is non-nil, use this regexp to find blocks."
"Move forward by one element. "Move forward by one element.
Move to the next element at the same level, when possible." Move to the next element at the same level, when possible."
(interactive) (interactive)
(cond ((eobp) (error "Cannot move further down")) (cond ((eobp) (user-error "Cannot move further down"))
((org-with-limited-levels (org-at-heading-p)) ((org-with-limited-levels (org-at-heading-p))
(let ((origin (point))) (let ((origin (point)))
(goto-char (org-end-of-subtree nil t)) (goto-char (org-end-of-subtree nil t))
(unless (org-with-limited-levels (org-at-heading-p)) (unless (org-with-limited-levels (org-at-heading-p))
(goto-char origin) (goto-char origin)
(error "Cannot move further down")))) (user-error "Cannot move further down"))))
(t (t
(let* ((elem (org-element-at-point)) (let* ((elem (org-element-at-point))
(end (org-element-property :end elem)) (end (org-element-property :end elem))
@ -22721,7 +22721,7 @@ Move to the next element at the same level, when possible."
"Move backward by one element. "Move backward by one element.
Move to the previous element at the same level, when possible." Move to the previous element at the same level, when possible."
(interactive) (interactive)
(cond ((bobp) (error "Cannot move further up")) (cond ((bobp) (user-error "Cannot move further up"))
((org-with-limited-levels (org-at-heading-p)) ((org-with-limited-levels (org-at-heading-p))
;; At an headline, move to the previous one, if any, or stay ;; At an headline, move to the previous one, if any, or stay
;; here. ;; here.
@ -22732,7 +22732,7 @@ Move to the previous element at the same level, when possible."
(when (= (point) origin) (when (= (point) origin)
(or (org-with-limited-levels (org-up-heading-safe)) (or (org-with-limited-levels (org-up-heading-safe))
(progn (goto-char origin) (progn (goto-char origin)
(error "Cannot move further up")))))) (user-error "Cannot move further up"))))))
(t (t
(let* ((trail (org-element-at-point 'keep-trail)) (let* ((trail (org-element-at-point 'keep-trail))
(elem (car trail)) (elem (car trail))