1
0
Fork 0
emacs-config/oni-hydra.el
Tom Willemse 624b9916d7 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’.
2021-01-20 16:33:44 -08:00

54 lines
1.8 KiB
EmacsLisp
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

;;; oni-hydra.el --- Configuration for using Hydra -*- lexical-binding: t; -*-
;; Copyright (C) 2020 Tom Willemse
;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local
;; Version: 2021.0120.162336
;; Package-Requires: (hydra posframe)
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;; Configuration for hydra. Set it up to use posframe instead of the default lv.
;;; Code:
(require 'hydra)
(require 'lv)
(require '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))
(provide 'oni-hydra)
;;; oni-hydra.el ends here