[Timeline] Make clock line parser barf when not in Org mode
This commit is contained in:
parent
82e0967b9f
commit
07aad33448
|
@ -101,6 +101,19 @@ CLOCK: [2018-01-08 Mon 16:00]--[2018-01-08 Mon 16:15] => 0:15
|
|||
((1515334380.0 . 1515338220.0)
|
||||
(1515423600.0 . 1515424500.0)))))))
|
||||
|
||||
(ert-deftest timeline-tools-test-parse-clocklines-5 ()
|
||||
"Test `timeline-tools-clocklines-in-range’ without org-mode."
|
||||
(let ((result (should-error (with-temp-buffer
|
||||
(insert "* Task 1\n")
|
||||
(insert ":LOGBOOK:\n")
|
||||
(insert "CLOCK: [2018-01-07 Sun 13:15]--[2018-01-07 Sun 14:00] => 0:45\n")
|
||||
(insert ":END:\n")
|
||||
(timeline-tools-clocklines-in-range 1515279600.0 1515366000.0))
|
||||
:type 'user-error)))
|
||||
(should (equal (cadr result)
|
||||
"Not in Org mode buffer, cannot parse clocklines"))
|
||||
(should (equal (car result)
|
||||
'user-error))))
|
||||
|
||||
|
||||
;; Conflict resolution tests
|
||||
|
|
|
@ -151,7 +151,9 @@ For each headline, call HEADLINE-FN with no arguments and point
|
|||
on the start of the headline. Traversal will be done from the
|
||||
end of the file upwards. If the buffer is narrowed, only this
|
||||
region will be traversed."
|
||||
(when (eq major-mode 'org-mode)
|
||||
(unless (eq major-mode 'org-mode)
|
||||
(user-error "Not in Org mode buffer, cannot parse clocklines"))
|
||||
|
||||
;; Make sure everything is visible, as otherwise editing may produce odd
|
||||
;; results
|
||||
(org-cycle '(64))
|
||||
|
@ -170,7 +172,7 @@ region will be traversed."
|
|||
(t
|
||||
;; A headline
|
||||
(save-mark-and-excursion
|
||||
(funcall headline-fn)))))))))
|
||||
(funcall headline-fn))))))))
|
||||
|
||||
(defvar timeline-tools-org-inactive-timestamp-format
|
||||
(concat "[" (substring (cdr org-time-stamp-formats) 1 -1) "]")
|
||||
|
@ -245,7 +247,6 @@ given as seconds since the epoch, as a floating point number.
|
|||
Truncation with respect to TSTART and TEND is done, i.e., START
|
||||
or END will always be in the interval [TSTART,TEND]."
|
||||
;; adapted from `org-clock-sum’
|
||||
(when (eq major-mode 'org-mode)
|
||||
(let* ((tstart (cond ((stringp tstart) (org-time-string-to-seconds tstart))
|
||||
((consp tstart) (float-time tstart))
|
||||
(t tstart)))
|
||||
|
@ -284,7 +285,7 @@ or END will always be in the interval [TSTART,TEND]."
|
|||
(when (not (null times))
|
||||
(push (cons (point-marker) times) task-clock-times)
|
||||
(setq times nil))))
|
||||
task-clock-times)))
|
||||
task-clock-times))
|
||||
|
||||
(defun timeline-tools-timeline (tstart tend &optional files)
|
||||
"Return timeline between TSTART and TEND from FILES.
|
||||
|
|
Loading…
Reference in New Issue