diff --git a/modules/config/default/+emacs-bindings.el b/modules/config/default/+emacs-bindings.el index 573ba5501..2cf87f2fd 100644 --- a/modules/config/default/+emacs-bindings.el +++ b/modules/config/default/+emacs-bindings.el @@ -140,8 +140,8 @@ (cond ((featurep! :completion ivy) #'ivy-bibtex) ((featurep! :completion helm) #'helm-bibtex))) - :desc "Toggle org-clock" "c" #'+org/toggle-clock - :desc "Cancel org-clock" "C" #'org-clock-cancel + :desc "Toggle last org-clock" "c" #'+org/toggle-last-clock + :desc "Cancel current org-clock" "C" #'org-clock-cancel :desc "Open deft" "d" #'deft (:when (featurep! :lang org +noter) :desc "Org noter" "e" #'org-noter) diff --git a/modules/config/default/+evil-bindings.el b/modules/config/default/+evil-bindings.el index fbbcb3f59..cc1db3ff6 100644 --- a/modules/config/default/+evil-bindings.el +++ b/modules/config/default/+evil-bindings.el @@ -477,8 +477,8 @@ (cond ((featurep! :completion ivy) #'ivy-bibtex) ((featurep! :completion helm) #'helm-bibtex))) - :desc "Toggle org-clock" "c" #'+org/toggle-clock - :desc "Cancel org-clock" "C" #'org-clock-cancel + :desc "Toggle last org-clock" "c" #'+org/toggle-last-clock + :desc "Cancel current org-clock" "C" #'org-clock-cancel :desc "Open deft" "d" #'deft (:when (featurep! :lang org +noter) :desc "Org noter" "e" #'org-noter) diff --git a/modules/lang/org/autoload/org.el b/modules/lang/org/autoload/org.el index 0060cb9e6..9b09d377e 100644 --- a/modules/lang/org/autoload/org.el +++ b/modules/lang/org/autoload/org.el @@ -283,37 +283,24 @@ If on a: ;;;###autoload -(defun +org/dedent () - "TODO" - (interactive) - (cond ((org-at-item-p) - (org-list-indent-item-generic - -1 nil - (save-excursion - (when (org-region-active-p) - (goto-char (region-beginning))) - (org-list-struct)))) - ((org-at-heading-p) - (ignore-errors (org-promote))) - ((call-interactively #'self-insert-command)))) +(defun +org/toggle-last-clock (arg) + "Toggles last clocked item. -;;;###autoload -(defun +org/toggle-clock (arg) - "Toggles clock on the last clocked item. +Clock out if an active clock is running (or cancel it if prefix ARG is non-nil). -Clock out if an active clock is running. Clock in otherwise. - -If in an org file, clock in on the item at point. Otherwise clock into the last -task you clocked into. - -See `org-clock-out', `org-clock-in' and `org-clock-in-last' for details on how -the prefix ARG changes this command's behavior." +If no clock is active, then clock into the last item. See `org-clock-in-last' to +see how ARG affects this command." (interactive "P") - (if (org-clocking-p) - (if arg - (org-clock-cancel) - (org-clock-out)) - (org-clock-in-last arg))) + (cond ((org-clocking-p) + (if arg + (org-clock-cancel) + (org-clock-out))) + ((and (null org-clock-history) + (or (org-on-heading-p) + (org-at-item-p)) + (y-or-n-p "No active clock. Clock in on current item?")) + (org-clock-in)) + ((org-clock-in-last arg)))) ;;; Folds diff --git a/modules/lang/org/config.el b/modules/lang/org/config.el index 3082e0d1a..63c1606bf 100644 --- a/modules/lang/org/config.el +++ b/modules/lang/org/config.el @@ -699,7 +699,8 @@ between the two." "e" #'org-clock-modify-effort-estimate "E" #'org-set-effort "g" #'org-clock-goto - "G" (λ! (org-clock-goto 'select)) + "G" (cmd! (org-clock-goto 'select)) + "l" #'+org/toggle-last-clock "i" #'org-clock-in "I" #'org-clock-in-last "o" #'org-clock-out