Rename +org/toggle-clock -> +org/toggle-last-clock

And rewrite it to ask for confirmation before clocking in on the item at
point. Without this, it's much harder to see what exactly it's doing.
This commit is contained in:
Henrik Lissner 2020-07-26 15:55:11 -04:00
parent 076cee4e89
commit 12e414be89
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
4 changed files with 21 additions and 33 deletions

View file

@ -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)

View file

@ -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)

View file

@ -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

View file

@ -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