From 28c6ae47a1092e14fbdf314b056bdad3a3d700a2 Mon Sep 17 00:00:00 2001 From: Daniel Borchmann Date: Fri, 15 Dec 2017 21:45:50 +0100 Subject: [PATCH] =?UTF-8?q?[Org]=20make=20=E2=80=98db/org-add-clocking-tim?= =?UTF-8?q?e=E2=80=99=20take=20two=20arguments?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- site-lisp/db-org.el | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) 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)