Reset filter after erase-buffer

This commit is contained in:
Patrick Winter 2019-01-11 21:06:46 +01:00
parent bfa2c2c465
commit 6a47f6a67b

View file

@ -167,25 +167,28 @@
"Open the taskwarrior buffer. If one already exists, bring it to "Open the taskwarrior buffer. If one already exists, bring it to
the front and focus it. Otherwise, create one and load the data." the front and focus it. Otherwise, create one and load the data."
(interactive) (interactive)
(taskwarrior-update-buffer)) (let* ((buf (get-buffer-create taskwarrior-buffer-name)))
(progn
(switch-to-buffer buf)
(taskwarrior-update-buffer)
(setq font-lock-defaults '(taskwarrior-highlight-regexps))
(taskwarrior-mode)
(hl-line-mode))))
(defun taskwarrior-update-buffer (&optional filter) (defun taskwarrior-update-buffer (&optional filter)
(interactive) (interactive)
(let* ((buf (get-buffer-create "taskwarrior"))) (let ((filter (taskwarrior--get-filter-as-string)))
(progn (progn
(switch-to-buffer buf)
(taskwarrior-mode)
(setq font-lock-defaults '(taskwarrior-highlight-regexps))
(goto-char (point-min)) (goto-char (point-min))
(toggle-read-only) (read-only-mode -1)
(erase-buffer) (erase-buffer)
(taskwarrior-load-tasks (concat "1-1000 " filter)) (taskwarrior-load-tasks (concat "1-1000 " filter))
(taskwarrior-write-entries) (taskwarrior-write-entries)
(toggle-read-only) (read-only-mode t)
(hl-line-mode)
(goto-char (point-min)) (goto-char (point-min))
(while (not (equal (overlays-at (point)) nil)) (while (not (equal (overlays-at (point)) nil))
(forward-char))))) (forward-char))
(taskwarrior--set-filter filter))))
(defun taskwarrior--sort-by-urgency (entries &optional asc) (defun taskwarrior--sort-by-urgency (entries &optional asc)
;; TODO: Figure out how to store a function in the cmp variable. ;; TODO: Figure out how to store a function in the cmp variable.