Skip to content

Instantly share code, notes, and snippets.

@maninalift
Created November 16, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maninalift/a6adfe961d008b1d4fa0 to your computer and use it in GitHub Desktop.
Save maninalift/a6adfe961d008b1d4fa0 to your computer and use it in GitHub Desktop.
(defvar hydra-map-of-major-modes nil)
(defun concat-syms (&rest syms)
(intern (apply #'concat (mapcar #'symbol-name syms))))
(defvar hydra-leader-key "¡")
(defvar hydra-map-of-minor-modes nil)
(defun add-hydra-minor (mode name key hydra)
(let* ((hydra-body (concat-syms hydra `/body))
(mode-map (symbol-value (concat-syms mode `-map)))
(key-chord (concat hydra-leader-key key))
)
(progn
(key-chord-define mode-map key-chord hydra-body)
(setq hydra-map-of-minor-modes
(plist-put hydra-map-of-minor-modes mode
`(name ,name key ,key action ,hydra-body))))))
(eval-after-load "flycheck" (progn (add-hydra-minor 'flycheck-mode "Flycheck" "f" 'hydra-error)))
(eval-after-load "projectile" (progn (add-hydra-minor 'projectile-mode "Projectile" "p" 'hydra-projectile)))
(defun build-minor-modes-master-hydra () (interactive)
(let* ((active (-non-nil (--map (plist-get hydra-map-of-minor-modes it) (active-minor-modes) )))
(mms (--map `(,(plist-get it 'key) ,(plist-get it 'action) ,(plist-get it 'name)) active)))
(eval `(defhydra minor-modes-master-hydra () "Active Minor Modes"
,@mms
("q" nil "quit")))))
(defun run-minor-modes-hydra () (interactive) (and (build-minor-modes-master-hydra) (minor-modes-master-hydra/body)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment