fix(indent-guides): face init in tty Emacs

Ensure that highlight-indent-guides-auto-set-faces is called when the
active theme and frame has been initialized (particularly tricky in
daemon sessions). With this assurance, we don't need to suppress its
errors anymore.

Close: #6900
Co-authored-by: Sleepful <Sleepful@users.noreply.github.com>
This commit is contained in:
Henrik Lissner 2022-10-27 19:55:07 +02:00
parent aa40daf5e8
commit 9d4689de5f
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -2,21 +2,15 @@
(use-package! highlight-indent-guides (use-package! highlight-indent-guides
:hook ((prog-mode text-mode conf-mode) . highlight-indent-guides-mode) :hook ((prog-mode text-mode conf-mode) . highlight-indent-guides-mode)
:init :init (setq highlight-indent-guides-method 'character)
(setq highlight-indent-guides-method 'character
highlight-indent-guides-suppress-auto-error t)
:config :config
(defun +indent-guides-init-faces-h (&rest _) ;; HACK: If this package is loaded too early (by the user, and in terminal
(when (display-graphic-p) ;; Emacs), then `highlight-indent-guides-auto-set-faces' will have been
(highlight-indent-guides-auto-set-faces))) ;; called much too early to set its faces correctly. To get around this, we
;; need to call it again, but at a time when I can ensure a frame exists an
;; HACK `highlight-indent-guides' calculates its faces from the current theme, ;; the current theme is loaded.
;; but is unable to do so properly in terminal Emacs, where it only has (when (doom-context-p 'init)
;; access to 256 colors. So if the user uses a daemon we must wait for (add-hook 'doom-first-buffer-hook #'highlight-indent-guides-auto-set-faces))
;; the first graphical frame to be available to do.
(add-hook 'doom-load-theme-hook #'+indent-guides-init-faces-h)
(when doom-theme
(+indent-guides-init-faces-h))
;; `highlight-indent-guides' breaks when `org-indent-mode' is active ;; `highlight-indent-guides' breaks when `org-indent-mode' is active
(add-hook! 'org-mode-local-vars-hook (add-hook! 'org-mode-local-vars-hook