diff options
| author | JD Smith <93749+jdtsmith@users.noreply.github.com> | 2026-04-18 08:58:11 -0400 |
|---|---|---|
| committer | JD Smith <93749+jdtsmith@users.noreply.github.com> | 2026-04-18 09:03:39 -0400 |
| commit | f95fee11d9932cba71d686807025239be0319e91 (patch) | |
| tree | db6207525f99b3b04ebaca4b67437bdec9a8670c | |
| parent | 09f83c4ef8aaa654bd8ffeff0427051be6e31924 (diff) | |
introduce defer-setup customize optionexternals/indent-bars
| -rw-r--r-- | NEWS.org | 4 | ||||
| -rw-r--r-- | indent-bars.el | 17 |
2 files changed, 20 insertions, 1 deletions
@@ -2,6 +2,10 @@ #+author: J.D. Smith #+language: en +* DEVELOPMENT + +- Add custom option ~indent-bars-defer-setup~ to help with late setup of indentation parameters, including file/dir-local and other helper modes like ~dtrt-indent~. + * v1.0 (2025-01-19) - Implement /bar-skipping/ in multiply-nested list contexts (with ~indent-bars-no-descend-lists~ set to ~skip~). diff --git a/indent-bars.el b/indent-bars.el index 571e3e5..29f4a97 100644 --- a/indent-bars.el +++ b/indent-bars.el @@ -533,6 +533,19 @@ buffer-local automatically." :initialize #'custom-initialize-default :group 'indent-bars) +(defcustom indent-bars-defer-setup nil + "Whether to defer indent-bars setup to `after-change-major-mode-hook'. +Setting up `indent-bars' correctly in a buffer requires correct +information about the indentation spacing and tabs vs. spaces. If these +are set after `indent-bars' is initialized, via another minor mode, or +in file or directory-local variables, this can lead to incorrect +behavior. In these cases, it can be useful to defer `indent-bars' setup +to the `after-change-major-mode-hook'. Enable this only if you only +experience problems, and enable `indent-bars' via major mode +hooks (e.g. `python-base-mode')." + :type 'boolean + :group 'indent-bars) + ;;;;; Color Utilities (defun indent-bars--background (&optional no-remap) "Return the background color. @@ -1910,7 +1923,9 @@ Adapted from `highlight-indentation-mode'." (if (and (daemonp) (not (frame-parameter nil 'client))) (add-hook 'after-make-frame-functions #'indent-bars-setup-and-remove nil t) - (indent-bars-setup)) + (if indent-bars-defer-setup + (add-hook 'after-change-major-mode-hook #'indent-bars-setup nil t) + (indent-bars-setup))) (indent-bars-teardown))) ;; Theme support |
