Browse Source

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.
Bastien Guerry 12 years ago
parent
commit
71c3c12b39
3 changed files with 12 additions and 12 deletions
  1. 3 3
      lisp/org-list.el
  2. 4 4
      lisp/org-table.el
  3. 5 5
      lisp/org.el

+ 3 - 3
lisp/org-list.el

@@ -2133,7 +2133,7 @@ the item, so this really moves item trees."
 	 (prevs (org-list-prevs-alist struct))
 	 (next-item (org-list-get-next-item (point-at-bol) struct prevs)))
     (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)
 	(setq struct (org-list-send-item item 'begin 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))
 	 (prev-item (org-list-get-prev-item (point-at-bol) struct prevs)))
     (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)
 	(setq struct (org-list-send-item item 'end struct))
       (setq struct (org-list-swap-items prev-item item struct)))
@@ -2756,7 +2756,7 @@ Return t at each successful move."
 	  (cond
 	   ((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))))
 
 (defun org-sort-list (&optional with-case sorting-type getkey-func compare-func)

+ 4 - 4
lisp/org-table.el

@@ -1039,7 +1039,7 @@ Before doing so, re-align the table if necessary."
       (progn
 	(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]*$\\)")
     (re-search-backward "|" (org-table-begin)))
   (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))
 	 (colpos (if left (1- col) (1+ col))))
     (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]*$"))
-	(error "Cannot move column further right"))
+	(user-error "Cannot move column further right"))
     (goto-char beg)
     (while (< (point) end)
       (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)
     (unless (org-at-table-p)
       (goto-char pos)
-      (error "Cannot move row further"))
+      (user-error "Cannot move row further"))
     (setq hline2p (looking-at org-table-hline-regexp))
     (goto-char pos)
     (beginning-of-line 1)

+ 5 - 5
lisp/org.el

@@ -7929,7 +7929,7 @@ case."
     (while (> cnt 0)
       (or (and (funcall movfunc) (looking-at org-outline-regexp))
 	  (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)))
     (if (> arg 0)
 	;; 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 to the next element at the same level, when possible."
   (interactive)
-  (cond ((eobp) (error "Cannot move further down"))
+  (cond ((eobp) (user-error "Cannot move further down"))
 	((org-with-limited-levels (org-at-heading-p))
 	 (let ((origin (point)))
 	   (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"))))
+	     (user-error "Cannot move further down"))))
 	(t
 	 (let* ((elem (org-element-at-point))
 		(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 to the previous element at the same level, when possible."
   (interactive)
-  (cond ((bobp) (error "Cannot move further up"))
+  (cond ((bobp) (user-error "Cannot move further up"))
 	((org-with-limited-levels (org-at-heading-p))
 	 ;; At an headline, move to the previous one, if any, or stay
 	 ;; here.
@@ -22732,7 +22732,7 @@ Move to the previous element at the same level, when possible."
 	   (when (= (point) origin)
 	     (or (org-with-limited-levels (org-up-heading-safe))
 		 (progn (goto-char origin)
-			(error "Cannot move further up"))))))
+			(user-error "Cannot move further up"))))))
 	(t
 	 (let* ((trail (org-element-at-point 'keep-trail))
 		(elem (car trail))