Automatically update hydra for shortcuts after customization
This commit is contained in:
parent
14cfae155a
commit
a576ef123d
1
init.el
1
init.el
|
@ -611,6 +611,7 @@
|
||||||
:commands (hydra-toggle/body
|
:commands (hydra-toggle/body
|
||||||
hydra-zoom/body
|
hydra-zoom/body
|
||||||
hydra-rectangle/body
|
hydra-rectangle/body
|
||||||
|
db/define-feature-shortcuts-hydra
|
||||||
hydra-feature-shortcuts/body))
|
hydra-feature-shortcuts/body))
|
||||||
|
|
||||||
(use-package exec-path-from-shell
|
(use-package exec-path-from-shell
|
||||||
|
|
|
@ -155,7 +155,12 @@ short description, a shortcut character, and the function to
|
||||||
call. Customizing this variable redefines the global
|
call. Customizing this variable redefines the global
|
||||||
`hydra-shortcuts' mapping."
|
`hydra-shortcuts' mapping."
|
||||||
:group 'personal-settings
|
:group 'personal-settings
|
||||||
:type '(repeat (list string character function)))
|
:type '(repeat (list string character function))
|
||||||
|
:set #'(lambda (symbol value)
|
||||||
|
(set-default symbol value)
|
||||||
|
;; Update hydra when already possible available
|
||||||
|
(when (fboundp 'db/define-feature-shortcuts-hydra)
|
||||||
|
(db/define-feature-shortcuts-hydra))))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -53,13 +53,23 @@ _h_ _l_ _o_k _y_ank
|
||||||
("e" rectangle-exchange-point-and-mark nil)
|
("e" rectangle-exchange-point-and-mark nil)
|
||||||
("o" nil nil))
|
("o" nil nil))
|
||||||
|
|
||||||
(eval
|
;; The hydra for our frequently used features should be defined here, but should
|
||||||
`(defhydra hydra-feature-shortcuts (:color blue)
|
;; also be redefined every time `db/frequently-used-features' is redefined via
|
||||||
""
|
;; customize. To this end, we provide a special function here that defines this
|
||||||
,@(mapcar (lambda (entry)
|
;; hydra, that can also be called in the setter of
|
||||||
(pcase-let ((`(,description ,shortcut ,function) entry))
|
;; `db/frequently-used-features'.
|
||||||
(list (string shortcut) function description)))
|
|
||||||
db/frequently-used-features)))
|
(defun db/define-feature-shortcuts-hydra ()
|
||||||
|
"Globally define `hydra-feature-shortcuts' for feature shortcuts."
|
||||||
|
(eval
|
||||||
|
`(defhydra hydra-feature-shortcuts (:color blue)
|
||||||
|
""
|
||||||
|
,@(mapcar (lambda (entry)
|
||||||
|
(pcase-let ((`(,description ,shortcut ,function) entry))
|
||||||
|
(list (string shortcut) function description)))
|
||||||
|
db/frequently-used-features))))
|
||||||
|
|
||||||
|
(db/define-feature-shortcuts-hydra)
|
||||||
|
|
||||||
(provide 'db-hydras)
|
(provide 'db-hydras)
|
||||||
;; db-hydras.el ends here
|
;; db-hydras.el ends here
|
||||||
|
|
Loading…
Reference in New Issue