branch: externals/ivy-posframe
commit 3aabf14e24c407c39ee5af85e18cb26f1f157af5
Author: Feng Shu <tuma...@163.com>
Commit: Feng Shu <tuma...@163.com>

    ivy-posframe-demo: let it toggle
---
 ivy-posframe.el | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/ivy-posframe.el b/ivy-posframe.el
index 13953b3..a8863e4 100644
--- a/ivy-posframe.el
+++ b/ivy-posframe.el
@@ -444,12 +444,18 @@ selection, non-nil otherwise."
 
 ;;;###autoload
 (defun ivy-posframe-demo ()
-  "Enable a demo config of ivy-posframe.
-This function is used to test ivy-posframe."
+  "Toggle a demo config of ivy-posframe.
+This function is ONLY used to test ivy-posframe."
   (interactive)
-  (push '(t . ivy-posframe-display-at-frame-center)
-        ivy-display-functions-alist)
-  (ivy-posframe-enable))
+  (ivy-posframe-enable)
+  (let ((config '(t . ivy-posframe-display-at-frame-center)))
+    (if (member config ivy-display-functions-alist)
+        (progn
+          (setq ivy-display-functions-alist
+                (remove config ivy-display-functions-alist))
+          (message "Ivy-posframe: Demo is disabled."))
+      (push config ivy-display-functions-alist)
+      (message "Ivy-posframe: Demo is enabled."))))
 
 (provide 'ivy-posframe)
 

Reply via email to