Add experimental mark support

This commit is contained in:
Patrick Winter 2019-09-02 22:14:28 +02:00
parent 82f4561a05
commit 195a9a5ded

View file

@ -130,20 +130,30 @@
(interactive) (interactive)
(let ((id (taskwarrior-id-at-point))) (let ((id (taskwarrior-id-at-point)))
(if (local-variable-p 'taskwarrior-marks) (if (local-variable-p 'taskwarrior-marks)
(setq-local taskwarrior-marks (remove id taskwarrior-marks))))) (setq-local taskwarrior-marks (remove id taskwarrior-marks))))
(progn
(save-excursion
(read-only-mode -1)
(beginning-of-line)
(delete-forward-char 1)
(insert " ")
(read-only-mode 1))
(next-line)))
(defun taskwarrior-mark-task () (defun taskwarrior-mark-task ()
(interactive) (interactive)
(let ((id (taskwarrior-id-at-point))) (let ((id (taskwarrior-id-at-point)))
(progn
(if (local-variable-p 'taskwarrior-marks) (if (local-variable-p 'taskwarrior-marks)
(setq-local taskwarrior-marks (delete-dups (cons id taskwarrior-marks))) (setq-local taskwarrior-marks (delete-dups (cons id taskwarrior-marks)))
(setq-local taskwarrior-marks (list id)))) (setq-local taskwarrior-marks (list id)))
(progn
(save-excursion (save-excursion
(read-only-mode -1) (read-only-mode -1)
(beginning-of-line) (beginning-of-line)
(delete-forward-char 1)
(insert "*") (insert "*")
(read-only-mode 1)))) (read-only-mode 1))
(next-line))))
(defun taskwarrior-open-annotation () (defun taskwarrior-open-annotation ()
(interactive) (interactive)
@ -286,13 +296,27 @@
(interactive "sDescription: ") (interactive "sDescription: ")
(taskwarrior--mutable-shell-command "add" "" description)) (taskwarrior--mutable-shell-command "add" "" description))
(defun taskwarrior-mark-p ()
"Whether there are any marked tasks"
(and
(boundp 'taskwarrior-marks)
(> (length taskwarrior-marks) 0)))
(defun taskwarrior-done () (defun taskwarrior-done ()
"Mark current task as done."
(interactive) (interactive)
(let ((id (taskwarrior-id-at-point)) (taskwarrior-multi-action 'taskwarrior--done "Done?"))
(confirmation (yes-or-no-p "Done?")))
(when confirmation (defun taskwarrior-multi-action (action confirmation-text)
(taskwarrior--mutable-shell-command "done" id)))) (when (yes-or-no-p confirmation-text)
(if (taskwarrior-mark-p)
(dolist (id taskwarrior-marks)
(funcall action id))
(let ((id (taskwarrior-id-at-point)))
(funcall action id)))))
(defun taskwarrior--done (id)
"Mark task as done."
(taskwarrior--mutable-shell-command "done" id))
(defun taskwarrior-delete () (defun taskwarrior-delete ()
"Delete current task." "Delete current task."