Skip to content

Commit

Permalink
Fix the output expected from Fava on startup
Browse files Browse the repository at this point in the history
Fava outputs "Starting Fava on ..." instead of "Running Fava on ..."
since [this commit][1].

Also, if the Fava process was already running, `beancount-fava` would
just kill it. Now it will kill it and try to start a new one.

[1]: beancount/fava@8bb3994
  • Loading branch information
dgchurchill authored and blais committed Sep 8, 2024
1 parent 7b437ab commit 452621f
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions beancount.el
Original file line number Diff line number Diff line change
Expand Up @@ -1262,21 +1262,21 @@ Essentially a much simplified version of `next-line'."
(defun beancount-fava ()
"Start (and open) or stop the fava server."
(interactive)
(if beancount--fava-process
(progn
(delete-process beancount--fava-process)
(setq beancount--fava-process nil)
(message "Fava process killed"))
(setq beancount--fava-process
(start-process "fava" (get-buffer-create "*fava*") "fava"
(if (eq 'beancount-mode major-mode) (buffer-file-name)
(read-file-name "File to load: "))))
(set-process-filter beancount--fava-process #'beancount--fava-filter)
(message "Fava process started")))
(when beancount--fava-process
(delete-process beancount--fava-process)
(setq beancount--fava-process nil)
(message "Fava process killed"))
(setq beancount--fava-process
(start-process "fava" (get-buffer-create "*fava*") "fava"
(if (eq 'beancount-mode major-mode) (buffer-file-name)
(read-file-name "File to load: "))))
(set-process-filter beancount--fava-process #'beancount--fava-filter)
(message "Fava process started"))

(defun beancount--fava-filter (_process output)
"Open fava url as soon as the address is announced."
(if-let ((url (string-match "Running Fava on \\(http://.+:[0-9]+\\)\n" output)))
(with-current-buffer "*fava*" (insert output))
(if-let ((url (string-match "Starting Fava on \\(http://.+:[0-9]+\\)\n" output)))
(browse-url (match-string 1 output))))

;;; Xref backend
Expand Down

0 comments on commit 452621f

Please sign in to comment.