From e15f66a06da4f82e88497befbad5411648f1ab98 Mon Sep 17 00:00:00 2001 From: Patrick Winter Date: Tue, 4 Dec 2018 18:42:26 +0100 Subject: [PATCH] Add functionality to filter task output --- taskwarrior.el | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/taskwarrior.el b/taskwarrior.el index 400a0db..55fce35 100644 --- a/taskwarrior.el +++ b/taskwarrior.el @@ -12,6 +12,8 @@ (defconst taskwarrior-mutating-commands '("add" "modify")) +(defvar taskwarrior-active-filters '() 'taskwarrior-active-filters) + (defvar taskwarrior-description 'taskwarrior-description "Taskwarrior mode face used for tasks with a priority of C.") @@ -34,6 +36,7 @@ (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 "f") 'taskwarrior-filter) (define-key taskwarrior-mode-map (kbd "P") 'taskwarrior-change-project)) (defun taskwarrior--display-task-details-in-echo-area () @@ -57,6 +60,14 @@ (string-match "^[0-9]*" line) (match-string 0 line))) +(defun taskwarrior-filter () + (interactive) + (let* ((current-filter-string (mapconcat 'identity taskwarrior-active-filters " ")) + (new-filter (read-from-minibuffer "Filter: " current-filter-string))) + (taskwarrior-update-buffer new-filter))) + + + (defun taskwarrior--shell-command (command &optional filter modifications miscellaneous) (shell-command-to-string (format "task %s %s %s %s" @@ -145,7 +156,7 @@ the front and focus it. Otherwise, create one and load the data." (interactive) (taskwarrior-update-buffer)) -(defun taskwarrior-update-buffer () +(defun taskwarrior-update-buffer (&optional filter) (interactive) (let* ((buf (get-buffer-create "taskwarrior"))) (progn @@ -155,7 +166,7 @@ the front and focus it. Otherwise, create one and load the data." (goto-char (point-min)) (toggle-read-only) (erase-buffer) - (taskwarrior-load-tasks "1-1000") + (taskwarrior-load-tasks (concat "1-1000 " filter)) (taskwarrior-write-entries) (toggle-read-only) (hl-line-mode)