diff --git a/site-lisp/db-org.el b/site-lisp/db-org.el index 12c1985..41958c7 100644 --- a/site-lisp/db-org.el +++ b/site-lisp/db-org.el @@ -512,27 +512,24 @@ are equal return nil." (org-use-tag-inheritance nil) (org-agenda-prefix-format '((tags . " "))))))) -(defun db/org-add-clocking-time () - "Add \"CLOCK:\" line to the task under point in the current org-mode file. - -Start and end time will be queried interactively." - (interactive) - ;; FIXME: make this function to take two optional arguments +(defun db/org-add-clocking-time (starting-time ending-time) + "Add \"CLOCK:\" line to the task under point in the current org-mode file." + (interactive + (list (starting-time (org-read-date 4 'totime nil + "Start:" (current-time) nil t)) + (ending-time (org-read-date 4 'totime nil + "End:" (current-time) nil t)))) (if (not (eq major-mode 'org-mode)) (user-error "Must be in org mode") - (let* ((starting-time (org-read-date 4 'totime nil - "Start:" (current-time) nil t)) - (ending-time (org-read-date 4 'totime nil - "End:" (current-time) nil t))) - (save-mark-and-excursion - (org-clock-find-position nil) - (open-line 1) - (indent-according-to-mode) - (insert "CLOCK: ") - (org-insert-time-stamp starting-time t t) - (insert "--") - (org-insert-time-stamp ending-time t t) - (org-clock-update-time-maybe))))) + (save-mark-and-excursion + (org-clock-find-position nil) + (open-line 1) + (indent-according-to-mode) + (insert "CLOCK: ") + (org-insert-time-stamp starting-time t t) + (insert "--") + (org-insert-time-stamp ending-time t t) + (org-clock-update-time-maybe)))) (bind-key "C-c C-x C-a" #'db/org-add-clocking-time org-mode-map)