Refactor buffer update logic into separate function

This commit is contained in:
Patrick Winter 2018-10-02 18:10:03 +02:00
parent 5164517e09
commit 9f50620214

View file

@ -72,12 +72,15 @@
"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))
(defun taskwarrior-update-buffer ()
(let* ((buf (get-buffer-create "taskwarrior"))) (let* ((buf (get-buffer-create "taskwarrior")))
(progn (progn
(switch-to-buffer buf) (switch-to-buffer buf)
(setq font-lock-defaults '(taskwarrior-highlight-regexps)) (setq font-lock-defaults '(taskwarrior-highlight-regexps))
(toggle-read-only)
(goto-char (point-min)) (goto-char (point-min))
(toggle-read-only)
(erase-buffer) (erase-buffer)
(taskwarrior-write-entries) (taskwarrior-write-entries)
(taskwarrior-mode) (taskwarrior-mode)