Refactor setting of an attribute into internal helper function
This commit is contained in:
parent
fe518663c2
commit
1ffe30ca10
1 changed files with 19 additions and 14 deletions
|
@ -79,22 +79,27 @@
|
||||||
(error "Seems like two task have the same id.")
|
(error "Seems like two task have the same id.")
|
||||||
(car task))))
|
(car task))))
|
||||||
|
|
||||||
(defun taskwarrior-change-description ()
|
(defun taskwarrior--change-attribute (attribute)
|
||||||
(interactive)
|
"Change an attribute of a task"
|
||||||
(save-excursion
|
(let* ((prefix (concat (upcase attribute) ": "))
|
||||||
(let* ((id (taskwarrior-id-at-point))
|
(id (taskwarrior-id-at-point))
|
||||||
(task (taskwarrior-export-task id))
|
(task (taskwarrior-export-task id))
|
||||||
(new-text (read-from-minibuffer "Description: " (alist-get 'description task))))
|
(key (make-symbol attribute))
|
||||||
(taskwarrior--shell-command "modify" id new-text)
|
(old-value (alist-get key task))
|
||||||
(taskwarrior-update-buffer))))
|
(new-value (read-from-minibuffer prefix old-value)))
|
||||||
|
(taskwarrior--shell-command "modify" id new-value)
|
||||||
(defun taskwarrior-change-project (project)
|
|
||||||
(interactive "sProject: ")
|
|
||||||
(let ((filter (taskwarrior-id-at-point))
|
|
||||||
(modifications (concat "project:" project)))
|
|
||||||
(taskwarrior--shell-command "modify" filter modifications)
|
|
||||||
(taskwarrior-update-buffer)))
|
(taskwarrior-update-buffer)))
|
||||||
|
|
||||||
|
(defun taskwarrior-change-description ()
|
||||||
|
"Change the description of a task"
|
||||||
|
(interactive)
|
||||||
|
(taskwarrior--change-attribute "description"))
|
||||||
|
|
||||||
|
(defun taskwarrior-change-project ()
|
||||||
|
"Change the project of a task"
|
||||||
|
(interactive)
|
||||||
|
(taskwarrior--change-attribute "project"))
|
||||||
|
|
||||||
(defun taskwarrior-add (description)
|
(defun taskwarrior-add (description)
|
||||||
(interactive "sDescription: ")
|
(interactive "sDescription: ")
|
||||||
(taskwarrior--shell-command "add" "" description))
|
(taskwarrior--shell-command "add" "" description))
|
||||||
|
|
Loading…
Reference in a new issue