summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <n.goaziou@gmail.com>2010-07-17 15:17:38 +0200
committerNicolas Goaziou <n.goaziou@gmail.com>2010-09-01 19:05:47 +0200
commit3dfc889cce8b07f7f745b72ea135654995057506 (patch)
tree76b16506569ba89ef748b4dc45241be0318e1a50
parent0229bcc05429d1a36ead914a1f6c5ab33b1c54d9 (diff)
downloadorg-mode-3dfc889cce8b07f7f745b72ea135654995057506.tar.gz
Refactoring.
-rw-r--r--lisp/org-list.el19
-rw-r--r--lisp/org-timer.el7
2 files changed, 16 insertions, 10 deletions
diff --git a/lisp/org-list.el b/lisp/org-list.el
index e5701a8..8b7ab68 100644
--- a/lisp/org-list.el
+++ b/lisp/org-list.el
@@ -438,6 +438,16 @@ function end."
(not (member (char-after) '(?\ ?\t)))
(< (point) (match-end 0))))
+(defun org-at-item-timer-p ()
+ "Is point at a line starting a plain list item with a timer?
+This skips checkboxes, if any."
+ (and (or (org-at-item-checkbox-p)
+ (org-at-item-p))
+ (save-excursion
+ (goto-char (match-end 0))
+ (skip-chars-forward " \t")
+ (looking-at "\\([0-9]+:[0-9]+:[0-9]+\\)[ \t]+::[ \t]+"))))
+
(defun org-at-item-checkbox-p ()
"Is point at a line starting a plain-list item with a checklet?"
(and (org-at-item-p)
@@ -686,10 +696,8 @@ things worked, nil when we are not in an item, or item is
invisible."
(unless (or (not (org-in-item-p))
(org-invisible-p))
- ;; Timer list: delegate to `org-timer-item'.
- (if (save-excursion
- (org-beginning-of-item)
- (looking-at "[ \t]*[-+*][ \t]+[0-9]+:[0-9]+:[0-9]+ ::"))
+ (if (org-at-item-timer-p)
+ ;; Timer list: delegate to `org-timer-item'.
(progn (org-timer-item) t)
;; if we're in a description list, ask for the new term.
(let ((desc-text (when (save-excursion
@@ -1302,8 +1310,7 @@ optional argument WITH-CASE, the sorting considers case as well."
((= dcst ?t)
(cond
;; If it is a timer list, convert timer to seconds
- ((and (goto-char (match-end 0))
- (looking-at "\\([0-9]+:[0-9]+:[0-9]+\\)[ \t]+::"))
+ ((org-at-item-timer-p)
(org-timer-hms-to-secs (match-string 1)))
((or (org-search-forward-unenclosed org-ts-regexp
(point-at-eol) t)
diff --git a/lisp/org-timer.el b/lisp/org-timer.el
index 0e29682..d859f7a 100644
--- a/lisp/org-timer.el
+++ b/lisp/org-timer.el
@@ -203,10 +203,9 @@ it in the buffer."
(cond
;; In a timer list, insert with `org-insert-item-internal'.
((and (org-in-item-p)
- (save-excursion
- (org-beginning-of-item)
- (looking-at "[ \t]*[-+*][ \t]+[0-9]+:[0-9]+:[0-9]+ ::")))
- (org-insert-item-internal (point) nil (concat (org-timer (when arg '(4)) t) ":: ")))
+ (org-at-item-timer-p))
+ (org-insert-item-internal
+ (point) nil (concat (org-timer (when arg '(4)) t) ":: ")))
;; In a list of another type, don't break anything: throw an error.
((org-in-item-p)
(error "This is not a timer list"))