summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <n.goaziou@gmail.com>2010-07-20 11:47:54 +0200
committerNicolas Goaziou <n.goaziou@gmail.com>2010-09-01 19:05:49 +0200
commiteebd8eb022d1760a392e911fd4c50c366a8b783d (patch)
treefb2a400b1b1af7eab12213220cb159c0b3e06abf
parent42f82d1bad20dcf00304c146e2e15bebad5fe4f9 (diff)
downloadorg-mode-eebd8eb022d1760a392e911fd4c50c366a8b783d.tar.gz
Fixed bug in `org-in-item-p' with point at an heading just beyond list.
* org-list.el (org-in-item-p): Handle case when point is at an heading. * org-list.el (org-list-make-subtree): Add protection when used outside of list * org-list.el (org-insert-item): Removed useless hack now `org-in-item-p' is fixed. * org-timer.el (org-timer-item): Removed useless hack now `org-in-item-p' is fixed.
-rw-r--r--lisp/org-list.el28
-rw-r--r--lisp/org-timer.el3
2 files changed, 16 insertions, 15 deletions
diff --git a/lisp/org-list.el b/lisp/org-list.el
index 53bc86b..f533f58 100644
--- a/lisp/org-list.el
+++ b/lisp/org-list.el
@@ -420,7 +420,8 @@ function ends."
(defun org-in-item-p ()
"Is the cursor inside a plain list ?"
- (save-excursion
+ (unless (org-at-heading-p)
+ (save-excursion
;; Move to eol so that current line can be matched by
;; `org-item-re'.
(let* ((limit (save-excursion (outline-previous-heading)))
@@ -432,7 +433,7 @@ function ends."
;; an item before and there is no valid list ender between us
;; and the item found.
(and last-item-start
- (not list-ender)))))
+ (not list-ender))))))
(defun org-first-list-item-p ()
"Is this heading the first item in a plain list?"
@@ -697,8 +698,7 @@ new item will be created before the current one. Return t when
things worked, nil when we are not in an item, or item is
invisible."
(unless (or (not (org-in-item-p))
- (org-invisible-p)
- (< (org-list-bottom-point) (point)))
+ (org-invisible-p))
(if (save-excursion
(org-beginning-of-item)
(org-at-item-timer-p))
@@ -1383,15 +1383,17 @@ sublevels as a list of strings."
(defun org-list-make-subtree ()
"Convert the plain list at point into a subtree."
(interactive)
- (goto-char (org-list-top-point))
- (let ((list (org-list-parse-list t)) nstars)
- (save-excursion
- (if (ignore-errors
- (org-back-to-heading))
- (progn (org-search-forward-unenclosed org-complex-heading-regexp nil t)
- (setq nstars (length (match-string 1))))
- (setq nstars 0)))
- (org-list-make-subtrees list (1+ nstars))))
+ (if (not (org-in-item-p))
+ (error "Not in a list.")
+ (goto-char (org-list-top-point))
+ (let ((list (org-list-parse-list t)) nstars)
+ (save-excursion
+ (if (ignore-errors
+ (org-back-to-heading))
+ (progn (org-search-forward-unenclosed org-complex-heading-regexp nil t)
+ (setq nstars (length (match-string 1))))
+ (setq nstars 0)))
+ (org-list-make-subtrees list (1+ nstars)))))
(defun org-list-make-subtrees (list level)
"Convert LIST into subtrees starting at LEVEL."
diff --git a/lisp/org-timer.el b/lisp/org-timer.el
index e6b4402..33c4c0b 100644
--- a/lisp/org-timer.el
+++ b/lisp/org-timer.el
@@ -203,8 +203,7 @@ it in the buffer."
(cond
;; In a timer list, insert with `org-list-insert-item-generic'.
((and (org-in-item-p)
- (save-excursion (org-beginning-of-item) (org-at-item-timer-p))
- (>= (org-list-bottom-point) (point)))
+ (save-excursion (org-beginning-of-item) (org-at-item-timer-p)))
(org-list-insert-item-generic
(point) nil (concat (org-timer (when arg '(4)) t) ":: ")))
;; In a list of another type, don't break anything: throw an error.