Dynamically create hydra from `db/frequently-used-features'
This commit is contained in:
parent
60dabe0440
commit
9e0338e683
12
init.el
12
init.el
|
@ -169,8 +169,7 @@
|
|||
(bind-key "<XF86Back>" #'winner-undo)
|
||||
(bind-key "<XF86Forward>" #'winner-redo)
|
||||
(bind-key "<f1>" #'db/run-or-hide-eshell)
|
||||
(bind-key "<f2> i" #'counsel-info-lookup-symbol)
|
||||
(bind-key "<f2> u" #'counsel-unicode-char)
|
||||
(bind-key "<f2>" #'hydra-shortcuts/body)
|
||||
(bind-key "<f5>" #'rgrep)
|
||||
(bind-key "<f6>" #'hydra-zoom/body)
|
||||
(bind-key "<f7>" #'dictcc)
|
||||
|
@ -591,7 +590,9 @@
|
|||
(use-package db-hydras
|
||||
:commands (hydra-toggle/body
|
||||
hydra-zoom/body
|
||||
hydra-rectangle/body))
|
||||
hydra-rectangle/body
|
||||
hydra-shortcuts/body
|
||||
db/define-hydra-from-frequently-used-features))
|
||||
|
||||
(use-package git-commit
|
||||
:commands (global-git-commit-mode))
|
||||
|
@ -657,7 +658,10 @@ them. Can be used in application shortcuts such as
|
|||
short description, a shortcut character, and the function to
|
||||
call."
|
||||
:group 'personal-settings
|
||||
:type '(repeat (list string character function)))
|
||||
:type '(repeat (list string character function))
|
||||
:set #'(lambda (symbol value)
|
||||
(set symbol value)
|
||||
(db/define-hydra-from-frequently-used-features)))
|
||||
|
||||
(defcustom db/important-documents-path "~/Documents/library/"
|
||||
"Path to look for documents that can be listed in extended
|
||||
|
|
|
@ -6,9 +6,6 @@
|
|||
|
||||
(require 'hydra)
|
||||
|
||||
|
||||
;;; Hydras
|
||||
|
||||
(defhydra hydra-toggle (:color blue)
|
||||
"toggle"
|
||||
("c" column-number-mode "column")
|
||||
|
@ -53,8 +50,24 @@ _h_ _l_ _o_k _y_ank
|
|||
("e" rectangle-exchange-point-and-mark nil)
|
||||
("o" nil nil))
|
||||
|
||||
|
||||
;; End
|
||||
(defun hydra-shortcuts/body ()
|
||||
"Dummy default value for shortcuts hydra. Will simply barf."
|
||||
(interactive)
|
||||
(user-error "Shortcuts Hydra not defined yet."))
|
||||
|
||||
(defun db/define-hydra-from-frequently-used-features ()
|
||||
"Defines `hydra-shortcuts/body' based on the current value of
|
||||
`db/frequently-used-features'. Raises an error if the latter is
|
||||
not bound."
|
||||
(if (not (boundp 'db/frequently-used-features))
|
||||
(user-error "Variable `db/frequently-used-features' is not defined, please set that variable first.")
|
||||
(eval
|
||||
`(defhydra hydra-shortcuts (:color blue)
|
||||
""
|
||||
,@(mapcar (lambda (entry)
|
||||
(pcase-let ((`(,description ,shortcut ,function) entry))
|
||||
(list (string shortcut) function description)))
|
||||
db/frequently-used-features)))))
|
||||
|
||||
(provide 'db-hydras)
|
||||
;; db-hydras.el ends here
|
||||
|
|
Loading…
Reference in New Issue