Add fallback for hydra display
In case posframe can’t be used, when working from a non-graphical client for example, fall back to the default ‘lv’.
This commit is contained in:
parent
86afae7567
commit
624b9916d7
1 changed files with 20 additions and 2 deletions
22
oni-hydra.el
22
oni-hydra.el
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
;; Author: Tom Willemse <tom@ryuslash.org>
|
;; Author: Tom Willemse <tom@ryuslash.org>
|
||||||
;; Keywords: local
|
;; Keywords: local
|
||||||
;; Version: 2020.0306.225035
|
;; Version: 2021.0120.162336
|
||||||
;; Package-Requires: (hydra posframe)
|
;; Package-Requires: (hydra posframe)
|
||||||
|
|
||||||
;; This program is free software; you can redistribute it and/or modify
|
;; This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -27,8 +27,26 @@
|
||||||
;;; Code:
|
;;; Code:
|
||||||
|
|
||||||
(require 'hydra)
|
(require 'hydra)
|
||||||
|
(require 'lv)
|
||||||
|
(require 'posframe)
|
||||||
|
|
||||||
(setq hydra-hint-display-type 'posframe)
|
(defun oni-hydra-custom-show (&rest args)
|
||||||
|
"Use ‘hydra-posframe-show’ when possible, fall back to ‘lv-message’.
|
||||||
|
ARGS are passed on without modification."
|
||||||
|
(if (posframe-workable-p)
|
||||||
|
(apply #'hydra-posframe-show args)
|
||||||
|
(apply #'lv-message args)))
|
||||||
|
|
||||||
|
(defun oni-hydra-custom-hide (&rest args)
|
||||||
|
"Use ‘hydra-posframe-hide’ when possible, fall back to ‘lv-delete-window’.
|
||||||
|
ARGS are passed on without modification."
|
||||||
|
(if (posframe-workable-p)
|
||||||
|
(apply #'hydra-posframe-hide args)
|
||||||
|
(apply #'lv-delete-window args)))
|
||||||
|
|
||||||
|
(add-to-list 'hydra-hint-display-alist '(custom oni-hydra-custom-show oni-hydra-custom-hide))
|
||||||
|
|
||||||
|
(setq hydra-hint-display-type 'custom)
|
||||||
|
|
||||||
;;;###autoload(with-eval-after-load 'hydra (require 'oni-hydra))
|
;;;###autoload(with-eval-after-load 'hydra (require 'oni-hydra))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue