branch: externals/hydra commit d96180865cefbb0ef9973cc1e529eddb4aada3f2 Author: Oleh Krehel <ohwoeo...@gmail.com> Commit: Oleh Krehel <ohwoeo...@gmail.com>
hydra.el (hydra-hint-display-alist): Add Fixes #317 --- hydra.el | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/hydra.el b/hydra.el index 8de37de035..aba74ca7ab 100644 --- a/hydra.el +++ b/hydra.el @@ -207,6 +207,26 @@ the body or the head." :type 'sexp :group 'hydra) +(declare-function posframe-show "posframe") +(declare-function posframe-hide "posframe") +(declare-function posframe-poshandler-window-center "posframe") + +(defun hydra-posframe-show (str) + (require 'posframe) + (posframe-show + " *hydra-posframe*" + :string str + :poshandler #'posframe-poshandler-window-center)) + +(defun hydra-posframe-hide () + (posframe-hide " *hydra-posframe*")) + +(defvar hydra-hint-display-alist + (list (list 'lv #'lv-message #'lv-delete-window) + (list 'message #'message (lambda () (message ""))) + (list 'posframe #'hydra-posframe-show #'hydra-posframe-hide)) + "Store the functions for `hydra-hint-display-type'.") + (defcustom hydra-hint-display-type 'lv "The utility to show hydra hint" :type '(choice @@ -494,9 +514,8 @@ Remove :color key. And sort the plist alphabetically." (setq hydra-curr-map nil) (unless (and hydra--ignore (null hydra--work-around-dedicated)) - (if hydra-lv - (lv-delete-window) - (message ""))) + (funcall + (nth 2 (assoc hydra-hint-display-type hydra-hint-display-alist)))) nil) (defvar hydra-head-format "[%s]: " @@ -912,9 +931,9 @@ KEY is forwarded to `plist-get'." (message (eval hint))) (t (when hydra-is-helpful - (if hydra-lv - (lv-message (eval hint)) - (message (eval hint)))))))) + (funcall + (nth 1 (assoc hydra-hint-display-type hydra-hint-display-alist)) + (eval hint))))))) (defmacro hydra--make-funcall (sym) "Transform SYM into a `funcall' to call it."