From 8a3b557d45652bd7d06de113a1bbe0d406132c96 Mon Sep 17 00:00:00 2001
From: Amir Dekel <6893125+adql@users.noreply.github.com>
Date: Mon, 18 Apr 2022 12:07:12 +0200
Subject: [PATCH] [#1335] Workaround for which-key display bug (#1349)

---
 CHANGELOG.md       | 2 ++
 core/prelude-ui.el | 8 ++++++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index fcb726b..11fc8f8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -19,6 +19,8 @@
 ### Bugs fixed
 
 * Fix `company` still being visible in the mode line.
+* [#1335](https://github.com/bbatsov/prelude/issues/1335): Workaround
+  for `which-key` bug causing display issues in clients to `emacs --daemon`.
 * Fix **Edit on GitHub** link in ReadTheDocs site.
 
 ## 1.1.0 (2021-02-14)
diff --git a/core/prelude-ui.el b/core/prelude-ui.el
index d2fb1f8..f3fb092 100644
--- a/core/prelude-ui.el
+++ b/core/prelude-ui.el
@@ -83,8 +83,12 @@
   (load-theme prelude-theme t))
 
 ;; show available keybindings after you start typing
-(require 'which-key)
-(which-key-mode +1)
+;; add to hook when running as a daemon as a workaround for a
+;; which-key bug
+;; https://github.com/justbur/emacs-which-key/issues/306
+(if (daemonp)
+    (add-hook 'server-after-make-frame-hook 'which-key-mode)
+  (which-key-mode +1))
 
 (provide 'prelude-ui)
 ;;; prelude-ui.el ends here