From 6a47f6a67b38174bbc75593b776acfd16a7478fb Mon Sep 17 00:00:00 2001 From: Patrick Winter Date: Fri, 11 Jan 2019 21:06:46 +0100 Subject: [PATCH] Reset filter after erase-buffer --- taskwarrior.el | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/taskwarrior.el b/taskwarrior.el index 5d228d6..a9f9488 100644 --- a/taskwarrior.el +++ b/taskwarrior.el @@ -167,25 +167,28 @@ "Open the taskwarrior buffer. If one already exists, bring it to the front and focus it. Otherwise, create one and load the data." (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) (interactive) - (let* ((buf (get-buffer-create "taskwarrior"))) + (let ((filter (taskwarrior--get-filter-as-string))) (progn - (switch-to-buffer buf) - (taskwarrior-mode) - (setq font-lock-defaults '(taskwarrior-highlight-regexps)) (goto-char (point-min)) - (toggle-read-only) + (read-only-mode -1) (erase-buffer) (taskwarrior-load-tasks (concat "1-1000 " filter)) (taskwarrior-write-entries) - (toggle-read-only) - (hl-line-mode) + (read-only-mode t) (goto-char (point-min)) (while (not (equal (overlays-at (point)) nil)) - (forward-char))))) + (forward-char)) + (taskwarrior--set-filter filter)))) (defun taskwarrior--sort-by-urgency (entries &optional asc) ;; TODO: Figure out how to store a function in the cmp variable.