[Org] Change API of function to add clock lines to task
Instead of resolving an ID, this function now gets a marker designating the task where the provided clock line should go to.
This commit is contained in:
parent
fa0fb98291
commit
74a26b4d5a
|
@ -1104,18 +1104,17 @@ ending at 23:61. When not given, FILES defaults to
|
||||||
|
|
||||||
(bind-key "C-c C-x C-a" #'db/org-add-clocking-time org-mode-map)
|
(bind-key "C-c C-x C-a" #'db/org-add-clocking-time org-mode-map)
|
||||||
|
|
||||||
(defun db/org-add-clock-line-to-file (id start end)
|
(defun db/org-add-clock-line-to-marker (target-marker start end)
|
||||||
"Add clock line with START and END time to task identified by ID.
|
"Add clock line with START and END time to task identified by TARGET-MARKER.
|
||||||
START and END must be given as time objects as returned by
|
START and END must be given as time objects as returned by
|
||||||
`encode-time’, or as an integer or float denoting seconds since
|
`encode-time’, or as an integer or float denoting seconds since
|
||||||
1970-01-01."
|
1970-01-01. TARGET-MARKER must be positioned on the task where
|
||||||
(let ((location (org-id-find id t)))
|
the clock line is to be added to."
|
||||||
(when (null location)
|
(when (not (markerp target-marker))
|
||||||
(user-error "ID %s cannot be found" id))
|
(user-error "Marker not valid."))
|
||||||
;; Update existing clock lines
|
|
||||||
(let ((new-start (float-time start))
|
(let ((new-start (float-time start))
|
||||||
(new-end (float-time end)))
|
(new-end (float-time end)))
|
||||||
(with-current-buffer (marker-buffer location)
|
(with-current-buffer (marker-buffer target-marker)
|
||||||
(db/org-map-clock-lines-and-entries
|
(db/org-map-clock-lines-and-entries
|
||||||
(lambda (timestamp-1 timestamp-2)
|
(lambda (timestamp-1 timestamp-2)
|
||||||
(let ((current-start (float-time
|
(let ((current-start (float-time
|
||||||
|
@ -1154,8 +1153,8 @@ START and END must be given as time objects as returned by
|
||||||
(lambda ())))
|
(lambda ())))
|
||||||
|
|
||||||
;; Finally add the new clock line
|
;; Finally add the new clock line
|
||||||
(org-with-point-at location
|
(org-with-point-at target-marker
|
||||||
(db/org-add-clocking-time new-start new-end)))))
|
(db/org-add-clocking-time new-start new-end))))
|
||||||
|
|
||||||
|
|
||||||
;;; End
|
;;; End
|
||||||
|
|
Loading…
Reference in New Issue