Browse Source

org-list.el: Return an error when there is no list at point.

* org-list.el (org-mark-list): Return an error when there is
no list at point.
Bastien Guerry 9 years ago
parent
commit
c465c7bdf0
1 changed files with 9 additions and 7 deletions
  1. 9 7
      lisp/org-list.el

+ 9 - 7
lisp/org-list.el

@@ -2182,13 +2182,15 @@ item is invisible."
   "Mark the current list.
 If this is a sublist, only mark the sublist."
   (interactive)
-  (let* ((item (org-list-get-item-begin))
-	 (struct (org-list-struct))
-	 (prevs (org-list-prevs-alist struct))
-	 (lbeg (org-list-get-list-begin item struct prevs))
-	 (lend (org-list-get-list-end item struct prevs)))
-    (push-mark lend nil t)
-    (goto-char lbeg)))
+  (if (not (org-at-item-p))
+      (error "Not on a list")
+    (let* ((item (org-list-get-item-begin))
+	   (struct (org-list-struct))
+	   (prevs (org-list-prevs-alist struct))
+	   (lbeg (org-list-get-list-begin item struct prevs))
+	   (lend (org-list-get-list-end item struct prevs)))
+      (push-mark lend nil t)
+      (goto-char lbeg))))
 
 (defun org-list-repair ()
   "Fix indentation, bullets and checkboxes is the list at point."