From 0461c5de5fa34d6b374f27eff1965f171049f987 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sat, 7 Sep 2024 21:54:48 -0400 Subject: [PATCH] tweak(indent-guides): subtle bars & bitmaps (almost) by default In e0a926d, I defaulted to not using bitmaps for indent-guides, but after some more research, I realize this slowness is more prominent on MacOS, older PGTK builds, and (possibly) Windows, so I've opted to re-enable bitmaps by default, unless you're on one of those systems (except Windows; still testing that). This change also makes the guide bars more subtle, since the default is too distracting and colorful. Ref: #8052 Ref: e0a926dc1ec9 --- modules/ui/indent-guides/config.el | 41 +++++++++++++++--------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/modules/ui/indent-guides/config.el b/modules/ui/indent-guides/config.el index f0bbed9a8..fc527baba 100644 --- a/modules/ui/indent-guides/config.el +++ b/modules/ui/indent-guides/config.el @@ -20,11 +20,26 @@ be enabled. If any function returns non-nil, the mode will not be activated." (unless (run-hook-with-args-until-success '+indent-guides-inhibit-functions) (indent-bars-mode +1))) :config - ;; Bitmap performance is inconsistent across display systems (pgtk, ns, mac, - ;; gtk, etc). There's also a bitmap init bug in PGTK builds of Emacs before - ;; v30 that could cause crashes (see jdtsmith/indent-bars#3). If you use PGTK - ;; and reverse this setting, you've been warned! - (setq indent-bars-prefer-character t) + (setq indent-bars-prefer-character + (or + ;; Bitmaps are far slower on MacOS, inexplicably, but this needs more + ;; testing to see if it's specific to ns or emacs-mac builds, or is + ;; just a general MacOS issue. + (featurep :system 'macos) + ;; FIX: A bitmap init bug in PGTK builds of Emacs before v30 that could + ;; cause crashes (see jdtsmith/indent-bars#3). + (and (featurep 'pgtk) + (< emacs-major-version 30))) + + ;; Show indent guides starting from the first column. + indent-bars-starting-column 0 + ;; Make indent guides subtle; the default is too distractingly colorful. + indent-bars-width-frac 0.15 ; make bitmaps thinner + indent-bars-color-by-depth nil + indent-bars-color '(font-lock-comment-face :face-bg nil :blend 0.425) + ;; Don't highlight current level indentation; it's distracting and is + ;; unnecessary overhead for little benefit. + indent-bars-highlight-current-depth nil) ;; TODO: Uncomment once we support treesit ;; (setq indent-bars-treesit-support (modulep! :tools tree-sitter)) @@ -45,18 +60,4 @@ be enabled. If any function returns non-nil, the mode will not be activated." ;; completion or eldoc popups). ;; REVIEW: Swap with `frame-parent' when 27 support is dropped (defun +indent-guides-in-childframe-p () - (frame-parameter nil 'parent-frame))) - - ;; HACK: Out of the box, indent-bars offers no way to fully disable - ;; "highlighting the current line", so I advise on in, since the feature is - ;; unnecessary work (and allocation of timers) for users that don't want it, - ;; and for our performance-leaning defaults. - (setq indent-bars-depth-update-delay nil) - (defadvice! +indent-guides--disable-highlight-current-line-a (fn &rest args) - :around #'indent-bars-setup - (letf! (defun indent-bars--highlight-current-depth () - (when indent-bars-depth-update-delay - (funcall indent-bars--highlight-current-depth))) - (prog1 (apply fn args) - (unless indent-bars-depth-update-delay - (remove-hook 'post-command-hook #'indent-bars--highlight-current-depth t)))))) + (frame-parameter nil 'parent-frame))))