Browse Source

Add function to add link to currently clocked-in task

This might be handy while working on a task and realizing that it's related to
another one.
master
Daniel Borchmann 1 year ago
parent
commit
eae1590e68
No known key found for this signature in database
GPG Key ID: 1C7071A75BB72D64
  1. 3
      init.el
  2. 16
      site-lisp/db-org.el

3
init.el

@ -732,7 +732,8 @@
db/export-diary
db/org-copy-template-for-periodic-task
db/org-find-links-to-current-item
db/org-add-link-to-other-item))
db/org-add-link-to-other-item
db/org-add-link-to-current-clock))
(use-package org
:pin "gnu"

16
site-lisp/db-org.el

@ -717,6 +717,22 @@ Use `org-store-link' to save link to `org-stored-links'."
(org-store-link nil t))
(insert (apply #'format "[[%s][%s]]" (cl-first org-stored-links))))))
(defun db/org-add-link-to-current-clock ()
"Insert link to currently clocked-in item at point.
Uses `org-store-link' and `org-insert-link'. Error out when not
in an Org Mode buffer or when the clock is not active."
(interactive)
(unless (derived-mode-p 'org-mode)
(user-error "Not in Org Mode, aborting"))
(unless org-clock-marker
(user-error "No clocked-in task, aborting"))
(save-mark-and-excursion
(org-with-point-at org-clock-marker
(org-store-link nil t))
(pcase-let ((`(,location ,description) (cl-first org-stored-links)))
(org-insert-link nil location description))))
;;; End

Loading…
Cancel
Save