Skip to content

Commit

Permalink
fix: clean up display-wttr-list in each update
Browse files Browse the repository at this point in the history
  • Loading branch information
josegpt committed Feb 28, 2022
1 parent 2f53c92 commit 3d4e777
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions display-wttr.el
Original file line number Diff line number Diff line change
Expand Up @@ -176,18 +176,6 @@ the currently running process."
(add-to-list 'display-wttr-list
(string-join (split-string string) " ") t))

(defun display-wttr-update ()
"Create a new background process to update wttr string."
(make-process
:name "display-wttr"
:command `("sh" "-c"
,(format "%s %s %s"
display-wttr-fetch-executable
display-wttr-fetch-options
(display-wttr-fetch-url)))
:filter 'display-wttr-filter
:sentinel 'display-wttr-sentinel ))

(defun display-wttr-update-handler ()
"Update wttr in mode line.
Calcalutes and sets up the timer for the next update of wttr with
Expand All @@ -204,6 +192,19 @@ the specified `display-wttr-interval'"
current display-wttr-interval)
(timer-activate timer))))))

(defun display-wttr-update ()
"Create a new background process to update wttr string."
(setq display-wttr-list nil)
(make-process
:name "display-wttr"
:command `("sh" "-c"
,(format "%s %s %s"
display-wttr-fetch-executable
display-wttr-fetch-options
(display-wttr-fetch-url)))
:filter 'display-wttr-filter
:sentinel 'display-wttr-sentinel ))

;;;###autoload
(defun display-wttr ()
"Enable display of wttr in mode line.
Expand All @@ -223,7 +224,6 @@ control the number of seconds between updates by customizing
;; Cancel timer if any is running
(and display-wttr-timer (cancel-timer display-wttr-timer))
(setq display-wttr-string "")
(setq display-wttr-list nil)
(or global-mode-string (setq global-mode-string '("")))
(when display-wttr-mode
(or (memq 'display-wttr-string global-mode-string)
Expand Down

0 comments on commit 3d4e777

Please sign in to comment.