Extract taskwarrior-add logic into pure function
This make unit testing alot easier
This commit is contained in:
parent
e8914d0308
commit
0fa25884f9
1 changed files with 14 additions and 1 deletions
|
@ -290,7 +290,14 @@
|
|||
|
||||
(defun taskwarrior-add (description)
|
||||
(interactive "sDescription: ")
|
||||
(taskwarrior--mutable-shell-command "add" "" description))
|
||||
(progn
|
||||
(taskwarrior--add description)
|
||||
(taskwarrior--revert-buffer)))
|
||||
|
||||
(defun taskwarrior--add (description)
|
||||
(let ((output (taskwarrior--shell-command "add" "" description)))
|
||||
(when (string-match "Created task \\([[:digit:]]+\\)." output)
|
||||
(match-string 1 output))))
|
||||
|
||||
(defun taskwarrior-mark-p ()
|
||||
"Whether there are any marked tasks"
|
||||
|
@ -328,6 +335,12 @@
|
|||
(let ((id (taskwarrior-id-at-point)))
|
||||
(taskwarrior--mutable-shell-command "annotate" id annotation)))
|
||||
|
||||
(defun taskwarrior--revert-buffer ()
|
||||
"Revert taskwarrior buffer."
|
||||
(let ((line-number (line-number-at-pos)))
|
||||
(taskwarrior-update-buffer)
|
||||
(goto-line line-number)))
|
||||
|
||||
(defun taskwarrior--mutable-shell-command (command &optional filter modifications misc confirm)
|
||||
"Run shell command and restore taskwarrior buffer."
|
||||
(let ((line-number (line-number-at-pos)))
|
||||
|
|
Loading…
Reference in a new issue