From 9d4689de5ffda242e1fbcd172ec80a914ebc8759 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 27 Oct 2022 19:55:07 +0200 Subject: [PATCH] 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 --- modules/ui/indent-guides/config.el | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/modules/ui/indent-guides/config.el b/modules/ui/indent-guides/config.el index d2c3a89d2..662cb5140 100644 --- a/modules/ui/indent-guides/config.el +++ b/modules/ui/indent-guides/config.el @@ -2,21 +2,15 @@ (use-package! highlight-indent-guides :hook ((prog-mode text-mode conf-mode) . highlight-indent-guides-mode) - :init - (setq highlight-indent-guides-method 'character - highlight-indent-guides-suppress-auto-error t) + :init (setq highlight-indent-guides-method 'character) :config - (defun +indent-guides-init-faces-h (&rest _) - (when (display-graphic-p) - (highlight-indent-guides-auto-set-faces))) - - ;; HACK `highlight-indent-guides' calculates its faces from the current theme, - ;; but is unable to do so properly in terminal Emacs, where it only has - ;; access to 256 colors. So if the user uses a daemon we must wait for - ;; 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)) + ;; HACK: If this package is loaded too early (by the user, and in terminal + ;; Emacs), then `highlight-indent-guides-auto-set-faces' will have been + ;; 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 + ;; the current theme is loaded. + (when (doom-context-p 'init) + (add-hook 'doom-first-buffer-hook #'highlight-indent-guides-auto-set-faces)) ;; `highlight-indent-guides' breaks when `org-indent-mode' is active (add-hook! 'org-mode-local-vars-hook