From 90bbd7101aa3bec6873b68c16b2a051fa5955e45 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 18 Jul 2024 20:56:10 -0400 Subject: [PATCH] fix(beancount): beancount-fava failing to open browser --- modules/lang/beancount/config.el | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/modules/lang/beancount/config.el b/modules/lang/beancount/config.el index c28f494d2..d54540657 100644 --- a/modules/lang/beancount/config.el +++ b/modules/lang/beancount/config.el @@ -15,6 +15,17 @@ (when (modulep! +lsp) (add-hook 'beancount-mode-local-vars-hook #'lsp! 'append)) + ;; HACK: The intro message changed in newer versions of Fava, plus, the output + ;; could contain ANSI codes, causing the `beancount-fava' command to not + ;; open the server in the browser after the server has started. + ;; REVIEW: PR this uptsream! + (defadvice! +beancount--open-in-browser-after-starting-fix-a (_process output) + :override #'beancount--fava-filter + (save-match-data + (let ((output (ansi-color-filter-apply output))) + (when-let ((url (string-match "\\(?:Starting\\|Running\\) Fava on \\(http://.+:[0-9]+\\)\n" output))) + (browse-url (match-string 1 output)))))) + (map! :map beancount-mode-map "TAB" (cmds! (and outline-minor-mode (outline-on-heading-p)) #'beancount-outline-cycle