From 715cc8df1ac59dd80e46531b77d65624024b39b3 Mon Sep 17 00:00:00 2001 From: Patrick Winter Date: Tue, 13 Nov 2018 21:17:43 +0100 Subject: [PATCH] Add done and delete functions --- taskwarrior.el | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/taskwarrior.el b/taskwarrior.el index b1335e2..0bb2ee0 100644 --- a/taskwarrior.el +++ b/taskwarrior.el @@ -32,6 +32,8 @@ (define-key taskwarrior-mode-map (kbd "e") 'taskwarrior-change-description) (define-key taskwarrior-mode-map (kbd "u") 'taskwarrior-update-buffer) (define-key taskwarrior-mode-map (kbd "a") 'taskwarrior-add) + (define-key taskwarrior-mode-map (kbd "d") 'taskwarrior-done) + (define-key taskwarrior-mode-map (kbd "D") 'taskwarrior-delete) (define-key taskwarrior-mode-map (kbd "P") 'taskwarrior-change-project)) (defun taskwarrior--display-task-details-in-echo-area () @@ -103,7 +105,26 @@ (defun taskwarrior-add (description) (interactive "sDescription: ") - (taskwarrior--shell-command "add" "" description)) + (message (taskwarrior--shell-command "add" "" description))) + +(defun taskwarrior-done () + "Mark current task as done." + (interactive) + (let ((id (taskwarrior-id-at-point)) + (confirmation (read-from-minibuffer "Done [y/n]?: "))) + (when (string= confirmation "y") + (message (taskwarrior--shell-command "done" id))))) + +(defun taskwarrior-delete () + "Delete current task." + (interactive) + (let ((id (taskwarrior-id-at-point)) + (confirmation (read-from-minibuffer "Delete [y/n]?: "))) + (when (string= confirmation "y") + (progn + (taskwarrior--shell-command "config" "" "confirmation off") + (message (taskwarrior--shell-command "delete" id)) + (taskwarrior--shell-command "config" "" "confirmation on"))))) ;; Setup a major mode for taskwarrior ;;;###autoload