REF put org-x-clock-range in terms of org-ml

This commit is contained in:
Nathan Dwarshuis 2021-04-18 21:57:43 -04:00
parent 2226c6371b
commit 0c716275f6
1 changed files with 19 additions and 22 deletions

View File

@ -976,28 +976,25 @@ don't log changes in the logbook."
Does not touch the running clock. When called with one prefix Does not touch the running clock. When called with one prefix
ARG, ask for a range in minutes in place of the second date." ARG, ask for a range in minutes in place of the second date."
(interactive "P") (interactive "P")
(let* ((t1 (-> (org-read-date t t) (float-time))) (cl-flet
(t2 (if (equal arg '(4)) ((read-date
(-some-> (read-string "Length in minutes: ") (default-time)
(cl-parse-integer :junk-allowed t) (round (float-time (org-read-date t t nil nil default-time))))
(* 60) (read-duration
(+ t1)) (start-epoch)
(-> (org-read-date t t nil nil t1) (let ((out (read-string "Length in minutes: ")))
(float-time) (if (not (s-match "[0-9]+" out))
(round))))) (error "Invalid duration: %s" out)
(cond (+ start-epoch (* 60 (string-to-number)))))))
((not t2) (message "Invalid range given!")) (let* ((t1 (read-date nil))
((< t2 t1) (message "Second timestamp earlier than first!")) (t2 (if (equal arg '(4)) (read-duration t1) (read-date t1))))
(t (if (< t2 t1) (message "Second timestamp earlier than first!")
(let ((s (org-ml-unixtime-to-time-long t1)) (let ((s (org-ml-unixtime-to-time-long t1))
(e (org-ml-unixtime-to-time-long t2))) (e (org-ml-unixtime-to-time-long t2)))
;; TODO rewrite this in terms of org-ml code (org-ml-update-this-headline*
(save-excursion (org-ml-headline-map-logbook-clocks* (org-x-logbook-config)
(org-clock-find-position nil) (cons (org-ml-build-clock! s :end e) it)
(org-indent-line) it)))))))
(->> (org-ml-build-clock! s :end e)
(org-ml-to-string)
(insert))))))))
(defun org-x-refile-logbook () (defun org-x-refile-logbook ()
"Refile the current headline with it's logbook. "Refile the current headline with it's logbook.