From 6ab4ae183c61aff90b4c79a7631b65a422d106ef Mon Sep 17 00:00:00 2001 From: Patrick Winter Date: Tue, 21 May 2019 09:37:48 +0200 Subject: [PATCH] Add ability to edit tags on task --- taskwarrior.el | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/taskwarrior.el b/taskwarrior.el index 16485cc..e3a27de 100644 --- a/taskwarrior.el +++ b/taskwarrior.el @@ -44,6 +44,7 @@ (define-key taskwarrior-mode-map (kbd "u") 'taskwarrior-unmark-task) (define-key taskwarrior-mode-map (kbd "f") 'taskwarrior-filter) (define-key taskwarrior-mode-map (kbd "r") 'taskwarrior-reset-filter) + (define-key taskwarrior-mode-map (kbd "t") 'taskwarrior-edit-tags) (define-key taskwarrior-mode-map (kbd "RET") 'taskwarrior-info) (define-key taskwarrior-mode-map (kbd "P") 'taskwarrior-change-project)) @@ -167,6 +168,22 @@ (quoted-value (concat "\"" new-value "\""))) (taskwarrior--mutable-shell-command "modify" id (concat prefix quoted-value)))) +(defun taskwarrior-edit-tags () + (interactive) + (let* ((id (taskwarrior-id-at-point)) + (task (taskwarrior-export-task id)) + (options (split-string (shell-command-to-string "task _tags") "\n")) + (old (vector-to-list (alist-get 'tags task))) + (current-tags (mapconcat 'identity old " ")) + (new (split-string (completing-read "Tags: " options nil nil current-tags) " ")) + (added-tags (mapconcat + (function (lambda (x) (concat "+" x))) + (set-difference new old :test #'string-equal) " ")) + (removed-tags (mapconcat + (function (lambda (x) (concat "-" x))) + (set-difference old new :test #'string-equal) " "))) + (taskwarrior--mutable-shell-command "modify" id (concat added-tags " " removed-tags)))) + (defun taskwarrior-change-description () "Change the description of a task" (interactive)