Pārlūkot izejas kodu

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 3 mēnešus atpakaļ
vecāks
revīzija
eae1590e68
Šim parakstam datu bāzē netika atrasta zināma atslēga
2 mainītis faili ar 18 papildinājumiem un 1 dzēšanām
  1. 2
    1
      init.el
  2. 16
    0
      site-lisp/db-org.el

+ 2
- 1
init.el Parādīt failu

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

+ 16
- 0
site-lisp/db-org.el Parādīt failu

@@ -717,6 +717,22 @@ Use `org-store-link' to save link to `org-stored-links'."
717 717
         (org-store-link nil t))
718 718
       (insert (apply #'format "[[%s][%s]]" (cl-first org-stored-links))))))
719 719
 
720
+(defun db/org-add-link-to-current-clock ()
721
+  "Insert link to currently clocked-in item at point.
722
+
723
+Uses `org-store-link' and `org-insert-link'.  Error out when not
724
+in an Org Mode buffer or when the clock is not active."
725
+  (interactive)
726
+  (unless (derived-mode-p 'org-mode)
727
+    (user-error "Not in Org Mode, aborting"))
728
+  (unless org-clock-marker
729
+    (user-error "No clocked-in task, aborting"))
730
+  (save-mark-and-excursion
731
+    (org-with-point-at org-clock-marker
732
+      (org-store-link nil t))
733
+    (pcase-let ((`(,location ,description) (cl-first org-stored-links)))
734
+      (org-insert-link nil location description))))
735
+
720 736
 
721 737
 ;;; End
722 738
 

Notiek ielāde…
Atcelt
Saglabāt