mirror of
https://github.com/doomemacs/doomemacs
synced 2025-08-01 12:17:25 -05:00
refactor(beancount): simplify +beancount--open-in-browser-after-starting-fix-a
This commit is contained in:
@ -18,16 +18,13 @@
|
|||||||
(when (modulep! +lsp)
|
(when (modulep! +lsp)
|
||||||
(add-hook 'beancount-mode-local-vars-hook #'lsp! 'append))
|
(add-hook 'beancount-mode-local-vars-hook #'lsp! 'append))
|
||||||
|
|
||||||
;; HACK: The intro message changed in newer versions of Fava, plus, the output
|
;; HACK: The intro message could contain ANSI color codes, causing the regexp
|
||||||
;; could contain ANSI codes, causing the `beancount-fava' command to not
|
;; in `beancount--fava-filter' to fail to match it (and thus the browser
|
||||||
;; open the server in the browser after the server has started.
|
;; isn't automatically opened after executing `beancount-fava').
|
||||||
;; REVIEW: PR this upstream!
|
;; REVIEW: PR this upstream!
|
||||||
(defadvice! +beancount--open-in-browser-after-starting-fix-a (_process output)
|
(defadvice! +beancount--open-in-browser-after-starting-fix-a (fn process output)
|
||||||
:override #'beancount--fava-filter
|
:around #'beancount--fava-filter
|
||||||
(save-match-data
|
(funcall fn process (ansi-color-filter-apply output)))
|
||||||
(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
|
(map! :map beancount-mode-map
|
||||||
:m "[[" #'+beancount/previous-transaction
|
:m "[[" #'+beancount/previous-transaction
|
||||||
|
Reference in New Issue
Block a user