Fix format of taskwarrior entries

Handle that certain entries don't have a project.
This commit is contained in:
Patrick Winter 2018-10-23 21:32:01 +02:00
parent 8f24fd3dd3
commit df20f9d1c1

View file

@ -8,15 +8,17 @@
(defgroup taskwarrior nil "An emacs frontend to taskwarrior.") (defgroup taskwarrior nil "An emacs frontend to taskwarrior.")
(defconst taskwarrior-mutating-commands '("add" "modify"))
(defvar taskwarrior-description 'taskwarrior-description (defvar taskwarrior-description 'taskwarrior-description
"Taskwarrior mode face used for tasks with a priority of C.") "Taskwarrior mode face used for tasks with a priority of C.")
(setq taskwarrior-highlight-regexps (setq taskwarrior-highlight-regexps
`(("^[0-9]*" . font-lock-variable-name-face) `(("^[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))) ("[:space:].*:" . font-lock-function-name-face)))
(defvar taskwarrior-mode-map nil "Keymap for `taskwarrior-mode'") (defvar taskwarrior-mode-map nil "Keymap for `taskwarrior-mode'")
(progn (progn
(setq taskwarrior-mode-map (make-sparse-keymap)) (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 () (defun taskwarrior-write-entries ()
(let ((entries (append (taskwarrior-export "1-1000") nil))) (let ((entries (append (taskwarrior-export "1-1000") nil)))
(dolist (entry entries) (dolist (entry entries)
(progn (let ((id (alist-get 'id entry))
(insert (format (urgency (alist-get 'urgency entry))
"%-2d (%0.2f) %s: %s?\n" (project (alist-get 'project entry))
(alist-get 'id entry) (description (alist-get 'description entry)))
(alist-get 'urgency entry) (insert (if project
(alist-get 'project entry) (format "%-2d (%05.2f) [%s] %s?\n" id urgency project description)
(alist-get 'description entry))))))) (format "%-2d (%05.2f) %s?\n" id urgency description)))))))