From 606bab8584b8ca9f0271214ef5b1149832f9ab0f Mon Sep 17 00:00:00 2001 From: Patrick Winter Date: Wed, 22 May 2019 21:39:44 +0200 Subject: [PATCH 1/2] Add auto completion to project selection --- taskwarrior.el | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/taskwarrior.el b/taskwarrior.el index 3d2bd23..e69e7bd 100644 --- a/taskwarrior.el +++ b/taskwarrior.el @@ -84,7 +84,7 @@ (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)) + (define-key taskwarrior-mode-map (kbd "P") 'taskwarrior-edit-project)) (defun test () @@ -242,6 +242,17 @@ (set-difference old new :test #'string-equal) " "))) (taskwarrior--mutable-shell-command "modify" id (concat added-tags " " removed-tags)))) + +(defun taskwarrior-edit-project () + "Change the project of a task" + (interactive) + (let* ((id (taskwarrior-id-at-point)) + (task (taskwarrior-export-task id)) + (options (split-string (shell-command-to-string "task _projects") "\n")) + (old (alist-get 'project task)) + (new (completing-read "Project: " options nil nil old))) + (taskwarrior--mutable-shell-command "modify" id (concat "project:" new)))) + (defun taskwarrior-change-description () "Change the description of a task" (interactive) @@ -252,11 +263,6 @@ (interactive) (taskwarrior--change-attribute "priority")) -(defun taskwarrior-change-project () - "Change the project of a task" - (interactive) - (taskwarrior--change-attribute "project")) - (defun taskwarrior-add (description) (interactive "sDescription: ") (taskwarrior--mutable-shell-command "add" "" description)) From a513a3fd92f31fc968b71e11eb3f3d23ceffb27b Mon Sep 17 00:00:00 2001 From: Patrick Winter Date: Wed, 22 May 2019 21:49:31 +0200 Subject: [PATCH 2/2] Add auto completion to priority selection --- taskwarrior.el | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/taskwarrior.el b/taskwarrior.el index e69e7bd..75fcfec 100644 --- a/taskwarrior.el +++ b/taskwarrior.el @@ -72,7 +72,7 @@ (define-key taskwarrior-mode-map (kbd "j") 'taskwarrior-next-task) (define-key taskwarrior-mode-map (kbd "q") 'quit-window) (define-key taskwarrior-mode-map (kbd "e") 'taskwarrior-change-description) - (define-key taskwarrior-mode-map (kbd "U") 'taskwarrior-change-priority) + (define-key taskwarrior-mode-map (kbd "U") 'taskwarrior-edit-priority) (define-key taskwarrior-mode-map (kbd "g") 'taskwarrior-update-buffer) (define-key taskwarrior-mode-map (kbd "a") 'taskwarrior-add) (define-key taskwarrior-mode-map (kbd "d") 'taskwarrior-done) @@ -258,10 +258,13 @@ (interactive) (taskwarrior--change-attribute "description")) -(defun taskwarrior-change-priority () +(defun taskwarrior-edit-priority () "Change the priority of a task" (interactive) - (taskwarrior--change-attribute "priority")) + (let* ((id (taskwarrior-id-at-point)) + (options '("" "H" "M" "L")) + (new (completing-read "Priority: " options))) + (taskwarrior--mutable-shell-command "modify" id (concat "priority:" new)))) (defun taskwarrior-add (description) (interactive "sDescription: ")