1
0
Fork 0
emacs-config/oni-hydra.el

57 lines
1.9 KiB
EmacsLisp
Raw Normal View History

;;; 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.0715.221700
;; 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.
;; Add the following to your init file in case you want to use this
;; configuraiton:
;;
;; (with-eval-after-load 'hydra (require 'oni-hydra))
;;; 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)
(provide 'oni-hydra)
;;; oni-hydra.el ends here