Replace hydra for frequently used features by simple map
Easier :)
This commit is contained in:
parent
cef425b1f8
commit
ab9245d58f
8
init.el
8
init.el
@ -476,8 +476,7 @@ split horizontally again, but this extra work should not matter much."
|
||||
db/dired-jump-to-bottom
|
||||
db/dired-get-size
|
||||
hydra-toggle/body
|
||||
hydra-rectangle/body
|
||||
hydra-feature-shortcuts/body)
|
||||
hydra-rectangle/body)
|
||||
:autoload (turn-on-flycheck-when-file
|
||||
db/sort-nsm-permanent-settings
|
||||
endless/colorize-compilation
|
||||
@ -487,8 +486,7 @@ split horizontally again, but this extra work should not matter much."
|
||||
db/replace-variables-in-string
|
||||
db/grep-read-files
|
||||
db/make-selector-from-table-header
|
||||
db/get-library-version
|
||||
db/define-feature-shortcuts-hydra))
|
||||
db/get-library-version))
|
||||
|
||||
(use-package diminish
|
||||
:ensure t)
|
||||
@ -3111,7 +3109,7 @@ eventuelly be set to nil, however)."
|
||||
(bind-key "<XF86Forward>" #'winner-redo)
|
||||
(bind-key "<Scroll_Lock>" 'scroll-lock-mode)
|
||||
(bind-key "<f1>" #'db/run-or-hide-eshell)
|
||||
(bind-key "<f2>" #'hydra-feature-shortcuts/body)
|
||||
(bind-key "<f2>" db/frequently-used-features-map)
|
||||
(bind-key "<f5>" #'project-find-regexp)
|
||||
(bind-key "<f6>" #'text-scale-adjust)
|
||||
(bind-key "<f7>" #'dictcc)
|
||||
|
||||
@ -149,6 +149,9 @@ in the main agenda view."
|
||||
:group 'personal-settings
|
||||
:type '(choice (const nil) file))
|
||||
|
||||
(defvar db/frequently-used-features-map (make-sparse-keymap)
|
||||
"Functions from `db/frequently-used-features' bound to shortcuts.")
|
||||
|
||||
(defcustom db/frequently-used-features
|
||||
'(("Mail" ?m db/gnus)
|
||||
("Agenda" ?a db/org-agenda)
|
||||
@ -175,9 +178,11 @@ can be chosen, in which case no entry in the
|
||||
:type '(repeat (list string (choice character (const nil)) 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))))
|
||||
(setq db/frequently-used-features-map (make-sparse-keymap))
|
||||
(mapc #'(lambda (entry)
|
||||
(pcase-let ((`(_ ,shortcut ,function) entry))
|
||||
(keymap-set db/frequently-used-features-map (string shortcut) function)))
|
||||
db/frequently-used-features)))
|
||||
|
||||
|
||||
|
||||
|
||||
@ -714,29 +714,6 @@ _h_ _l_ _o_k _y_ank
|
||||
("e" rectangle-exchange-point-and-mark nil)
|
||||
("o" nil nil))
|
||||
|
||||
;; 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.
|
||||
If instead of a shortcut character nil is provided, no entry in
|
||||
the hydra will be generated. See documentation of
|
||||
`db/frequently-used-features' for details."
|
||||
(eval
|
||||
`(defhydra hydra-feature-shortcuts (:color blue)
|
||||
""
|
||||
,@(mapcar (lambda (entry)
|
||||
(pcase-let ((`(,description ,shortcut ,function) entry))
|
||||
(list (string shortcut) function description)))
|
||||
(cl-remove-if #'(lambda (entry)
|
||||
(null (cl-second entry)))
|
||||
db/frequently-used-features)))))
|
||||
|
||||
(db/define-feature-shortcuts-hydra)
|
||||
|
||||
|
||||
;;; Base45 Decoding
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user