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-jump-to-bottom
|
||||||
db/dired-get-size
|
db/dired-get-size
|
||||||
hydra-toggle/body
|
hydra-toggle/body
|
||||||
hydra-rectangle/body
|
hydra-rectangle/body)
|
||||||
hydra-feature-shortcuts/body)
|
|
||||||
:autoload (turn-on-flycheck-when-file
|
:autoload (turn-on-flycheck-when-file
|
||||||
db/sort-nsm-permanent-settings
|
db/sort-nsm-permanent-settings
|
||||||
endless/colorize-compilation
|
endless/colorize-compilation
|
||||||
@ -487,8 +486,7 @@ split horizontally again, but this extra work should not matter much."
|
|||||||
db/replace-variables-in-string
|
db/replace-variables-in-string
|
||||||
db/grep-read-files
|
db/grep-read-files
|
||||||
db/make-selector-from-table-header
|
db/make-selector-from-table-header
|
||||||
db/get-library-version
|
db/get-library-version))
|
||||||
db/define-feature-shortcuts-hydra))
|
|
||||||
|
|
||||||
(use-package diminish
|
(use-package diminish
|
||||||
:ensure t)
|
:ensure t)
|
||||||
@ -3111,7 +3109,7 @@ eventuelly be set to nil, however)."
|
|||||||
(bind-key "<XF86Forward>" #'winner-redo)
|
(bind-key "<XF86Forward>" #'winner-redo)
|
||||||
(bind-key "<Scroll_Lock>" 'scroll-lock-mode)
|
(bind-key "<Scroll_Lock>" 'scroll-lock-mode)
|
||||||
(bind-key "<f1>" #'db/run-or-hide-eshell)
|
(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 "<f5>" #'project-find-regexp)
|
||||||
(bind-key "<f6>" #'text-scale-adjust)
|
(bind-key "<f6>" #'text-scale-adjust)
|
||||||
(bind-key "<f7>" #'dictcc)
|
(bind-key "<f7>" #'dictcc)
|
||||||
|
|||||||
@ -149,6 +149,9 @@ in the main agenda view."
|
|||||||
:group 'personal-settings
|
:group 'personal-settings
|
||||||
:type '(choice (const nil) file))
|
: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
|
(defcustom db/frequently-used-features
|
||||||
'(("Mail" ?m db/gnus)
|
'(("Mail" ?m db/gnus)
|
||||||
("Agenda" ?a db/org-agenda)
|
("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))
|
:type '(repeat (list string (choice character (const nil)) function))
|
||||||
:set #'(lambda (symbol value)
|
:set #'(lambda (symbol value)
|
||||||
(set-default symbol value)
|
(set-default symbol value)
|
||||||
;; Update hydra when already possible available
|
(setq db/frequently-used-features-map (make-sparse-keymap))
|
||||||
(when (fboundp 'db/define-feature-shortcuts-hydra)
|
(mapc #'(lambda (entry)
|
||||||
(db/define-feature-shortcuts-hydra))))
|
(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)
|
("e" rectangle-exchange-point-and-mark nil)
|
||||||
("o" nil 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
|
;;; Base45 Decoding
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user