branch: externals/indent-bars
commit d59d94d6223f775208718c101cab3c959cd54c25
Author: JD Smith <[email protected]>
Commit: JD Smith <[email protected]>
2nd attempt defer setup when running under daemon
See dinkonin #10
---
README.md | 8 --------
indent-bars.el | 12 +++++++++++-
2 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/README.md b/README.md
index 8e7f07aa32..82ca0bb501 100644
--- a/README.md
+++ b/README.md
@@ -46,14 +46,6 @@ To clone with `use-package` and `straight`:
:hook ((python-mode yaml-mode) . indent-bars-mode)) ; or whichever modes you
prefer
```
-## With `--daemon`
-If you open files via emacsclient which start emacs, and for which
`indent-bars` will be enabled using the emacs daemon, you may need to delay
loading until after the server-start, e.g.:
-
-```elisp
- :hook
- (server-after-make-frame-hook . (lambda () (add-hook 'prog-mode-hook
'indent-bars-mode)))
-```
-
## Compatibility
For `indent-bars` to display fancy guide bars, your port and version of emacs
must correctly display the `:stipple` face attribute. **Most do.** It can
also be used *without stipples*, drawing a simple vertical character (like `│`)
instead. It automatically does this in non-graphical displays (terminals), but
can optionally be configured to always do so; see [Non-stipple
Display](#non-stipple-display).
diff --git a/indent-bars.el b/indent-bars.el
index fae08f145b..fa9f56715d 100644
--- a/indent-bars.el
+++ b/indent-bars.el
@@ -982,13 +982,23 @@ Adapted from `highlight-indentation-mode'."
(indent-bars-teardown)
(indent-bars-setup))
+(defun indent-bars-setup-and-remove ()
+ "Setup indent bars and remove from `after-make-frame-functions'."
+ (remove-hook 'after-make-frame-functions #'indent-bars-setup-and-remove)
+ (indent-bars-setup))
+
;;;###autoload
(define-minor-mode indent-bars-mode
"Indicate indentation with configurable bars."
:global nil
:group 'indent-bars
(if indent-bars-mode
- (indent-bars-setup)
+ (if (and (daemonp) (not (frame-parameter nil 'client)))
+ (let ((buf (current-buffer)))
+ (add-hook 'after-make-frame-functions
+ (lambda () (with-current-buffer buf
(indent-bars-setup-and-remove)))
+ nil t))
+ (indent-bars-setup))
(indent-bars-teardown)))
(provide 'indent-bars)