diff --git a/init.el b/init.el index eee3c45..556c327 100644 --- a/init.el +++ b/init.el @@ -611,6 +611,7 @@ :commands (hydra-toggle/body hydra-zoom/body hydra-rectangle/body + db/define-feature-shortcuts-hydra hydra-feature-shortcuts/body)) (use-package exec-path-from-shell diff --git a/site-lisp/db-customize.el b/site-lisp/db-customize.el index ca85974..310f522 100644 --- a/site-lisp/db-customize.el +++ b/site-lisp/db-customize.el @@ -155,7 +155,12 @@ short description, a shortcut character, and the function to call. Customizing this variable redefines the global `hydra-shortcuts' mapping." :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)))) diff --git a/site-lisp/db-hydras.el b/site-lisp/db-hydras.el index 3856ac8..57bd963 100644 --- a/site-lisp/db-hydras.el +++ b/site-lisp/db-hydras.el @@ -53,13 +53,23 @@ _h_ _l_ _o_k _y_ank ("e" rectangle-exchange-point-and-mark nil) ("o" nil nil)) -(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))) +;; The hydra for our frequently used features should be defined here, but should +;; 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 +;; hydra, that can also be called in the setter of +;; `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) ;; db-hydras.el ends here