From 9064d99a018040e6fb4d260ac5cf12550058da78 Mon Sep 17 00:00:00 2001 From: Patrick Winter Date: Tue, 21 May 2019 13:35:40 +0200 Subject: [PATCH] Add abilitiy to create tasks from org links This is very handy to create tasks based on mu4e mails and dired files. --- taskwarrior.el | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/taskwarrior.el b/taskwarrior.el index 4d19bc6..70d351c 100644 --- a/taskwarrior.el +++ b/taskwarrior.el @@ -148,6 +148,18 @@ (switch-to-buffer-other-window buf) (insert (taskwarrior--shell-command "info" "" id))))) +(defun taskwarrior--parse-created-task-id (output) + (when (string-match "^.*Created task \\([0-9]+\\)\\.*$" output) + (message (match-string 1 output)))) + +(defun taskwarrior-org-store-link (arg) + (interactive "P") + (let* ((link (org-store-link arg)) + (description (read-from-minibuffer "Description: ")) + (id (taskwarrior--parse-created-task-id + (shell-command-to-string (format "task add %s" description))))) + (shell-command-to-string (format "task %s annotate %s" id link)))) + (defun taskwarrior-id-at-point () (let ((line (thing-at-point 'line t))) (string-match "^ [0-9]*" line)