org-list: fix bug with org-toggle-checkbox

* lisp/org-list.el (org-list-checkbox): when called from an headline,
  function would normally skip drawers, but not if a SCHEDULED or
  DEADLINE keyword is standing before the drawer. Also avoid problems
  if function is called in buffers not is Org mode.
This commit is contained in:
Nicolas Goaziou 2011-03-23 14:47:33 +01:00
parent 8d0c034047
commit 06ca884162
1 changed files with 10 additions and 3 deletions

View File

@ -2073,6 +2073,10 @@ in subtree, ignoring drawers."
block-item
lim-up
lim-down
(drawer-re (concat "^[ \t]*:\\("
(mapconcat 'regexp-quote org-drawers "\\|")
"\\):[ \t]*$"))
(keyword-re (concat "^[ \t]*" org-keyword-time-regexp))
(orderedp (org-entry-get nil "ORDERED"))
(bounds
;; In a region, start at first item in region
@ -2085,11 +2089,14 @@ in subtree, ignoring drawers."
(error "No item in region"))
(setq lim-down (copy-marker limit))))
((org-on-heading-p)
;; On an heading, start at first item after drawers
;; On an heading, start at first item after drawers and
;; time-stamps (scheduled, etc.)
(let ((limit (save-excursion (outline-next-heading) (point))))
(forward-line 1)
(when (looking-at org-drawer-regexp)
(re-search-forward "^[ \t]*:END:" limit nil))
(while (or (looking-at drawer-re) (looking-at keyword-re))
(if (looking-at keyword-re)
(forward-line 1)
(re-search-forward "^[ \t]*:END:" limit nil)))
(if (org-list-search-forward (org-item-beginning-re) limit t)
(setq lim-up (point-at-bol))
(error "No item in subtree"))