Add function to sort entries by urgency
This commit is contained in:
parent
24bf81685d
commit
52d17476ed
1 changed files with 8 additions and 1 deletions
|
@ -92,12 +92,19 @@ the front and focus it. Otherwise, create one and load the data."
|
||||||
(while (not (equal (overlays-at (point)) nil))
|
(while (not (equal (overlays-at (point)) nil))
|
||||||
(forward-char)))))
|
(forward-char)))))
|
||||||
|
|
||||||
|
(defun taskwarrior--sort-by-urgency (entries &optional asc)
|
||||||
|
(let ((cmp (if asc '< '>)))
|
||||||
|
(sort entries #'(lambda (x y)
|
||||||
|
(> (alist-get 'urgency x)
|
||||||
|
(alist-get 'urgency y))))))
|
||||||
|
|
||||||
|
|
||||||
(defun vector-to-list (vector)
|
(defun vector-to-list (vector)
|
||||||
"Convert a vector to a list"
|
"Convert a vector to a list"
|
||||||
(append vector nil))
|
(append vector nil))
|
||||||
|
|
||||||
(defun taskwarrior-write-entries ()
|
(defun taskwarrior-write-entries ()
|
||||||
(let ((entries (append (taskwarrior-export "1-1000") nil)))
|
(let ((entries (taskwarrior--sort-by-urgency (taskwarrior-export "1-1000"))))
|
||||||
(dolist (entry entries)
|
(dolist (entry entries)
|
||||||
(let ((id (alist-get 'id entry))
|
(let ((id (alist-get 'id entry))
|
||||||
(urgency (alist-get 'urgency entry))
|
(urgency (alist-get 'urgency entry))
|
||||||
|
|
Loading…
Reference in a new issue