From df20f9d1c1fc10b6a299ef161b96b3728af02cf1 Mon Sep 17 00:00:00 2001 From: Patrick Winter Date: Tue, 23 Oct 2018 21:32:01 +0200 Subject: [PATCH] Fix format of taskwarrior entries Handle that certain entries don't have a project. --- taskwarrior.el | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/taskwarrior.el b/taskwarrior.el index b701882..9e066a8 100644 --- a/taskwarrior.el +++ b/taskwarrior.el @@ -8,15 +8,17 @@ (defgroup taskwarrior nil "An emacs frontend to taskwarrior.") +(defconst taskwarrior-mutating-commands '("add" "modify")) + (defvar taskwarrior-description 'taskwarrior-description "Taskwarrior mode face used for tasks with a priority of C.") (setq taskwarrior-highlight-regexps `(("^[0-9]*" . font-lock-variable-name-face) - ("(.*)" . font-lock-builtin-face) + ("([0-9.]*?)" . font-lock-builtin-face) + ("\\[.*\\]" . font-lock-preprocessor-face) ("[:space:].*:" . font-lock-function-name-face))) - (defvar taskwarrior-mode-map nil "Keymap for `taskwarrior-mode'") (progn (setq taskwarrior-mode-map (make-sparse-keymap)) @@ -92,10 +94,10 @@ the front and focus it. Otherwise, create one and load the data." (defun taskwarrior-write-entries () (let ((entries (append (taskwarrior-export "1-1000") nil))) (dolist (entry entries) - (progn - (insert (format - "%-2d (%0.2f) %s: %s?\n" - (alist-get 'id entry) - (alist-get 'urgency entry) - (alist-get 'project entry) - (alist-get 'description entry))))))) + (let ((id (alist-get 'id entry)) + (urgency (alist-get 'urgency entry)) + (project (alist-get 'project entry)) + (description (alist-get 'description entry))) + (insert (if project + (format "%-2d (%05.2f) [%s] %s?\n" id urgency project description) + (format "%-2d (%05.2f) %s?\n" id urgency description)))))))