1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-12-23 10:34:17 +00:00

org-timer: fix bug with `org-timer-item'

* lisp/org-timer.el (org-timer-item): save-excursion prevents
  `org-list-struct' to get the list structure when point isn't on the
  first line of the item.
This commit is contained in:
Nicolas Goaziou 2011-03-08 10:40:46 +01:00
parent 4fc3e71f10
commit 11f19abcf2

View File

@ -207,21 +207,20 @@ it in the buffer."
(defun org-timer-item (&optional arg)
"Insert a description-type item with the current timer value."
(interactive "P")
(let ((itemp (org-in-item-p)))
(let ((itemp (org-in-item-p)) (pos (point)))
(cond
;; In a timer list, insert with `org-list-insert-item',
;; then fix the list.
((and itemp
(save-excursion (goto-char itemp) (org-at-item-timer-p)))
((and itemp (goto-char itemp) (org-at-item-timer-p))
(let* ((struct (org-list-struct))
(prevs (org-list-prevs-alist struct))
(s (concat (org-timer (when arg '(4)) t) ":: ")))
(setq struct (org-list-insert-item (point) struct prevs nil s))
(setq struct (org-list-insert-item pos struct prevs nil s))
(org-list-write-struct struct (org-list-parents-alist struct))
(looking-at org-list-full-item-re)
(goto-char (match-end 0))))
;; In a list of another type, don't break anything: throw an error.
(itemp (error "This is not a timer list"))
(itemp (goto-char pos) (error "This is not a timer list"))
;; Else, start a new list.
(t
(beginning-of-line)