Bläddra i källkod

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.
Nicolas Goaziou 14 år sedan
förälder
incheckning
11f19abcf2
1 ändrade filer med 4 tillägg och 5 borttagningar
  1. 4 5
      lisp/org-timer.el

+ 4 - 5
lisp/org-timer.el

@@ -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)