From 6183e008d782d1b00e16c81a78daf22e6068c68f Mon Sep 17 00:00:00 2001 From: Daniel Borchmann Date: Sat, 27 Jun 2020 10:08:39 +0200 Subject: [PATCH] Remove unused `hydra-shortcuts' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The idea of having a hydra to access frequently used features is certainly nice, but quite hard to achive when one wants to redefine the hydra every time `db/frequently-used-features' changes. Regrettably, there are not „ephemeral hydras“ that are created every time one would like to access it. Therefore, the shortcuts hydra is removed for now, but may come back again when we have found a better way to handle its dynamic nature. --- init.el | 26 +------------------------- site-lisp/db-customize.el | 21 +++++++++++++++++++++ site-lisp/db-hydras.el | 19 ------------------- 3 files changed, 22 insertions(+), 44 deletions(-) diff --git a/init.el b/init.el index 91b00ab..47617ae 100644 --- a/init.el +++ b/init.el @@ -162,7 +162,6 @@ (bind-key "" #'winner-undo) (bind-key "" #'winner-redo) (bind-key "" #'db/run-or-hide-eshell) - (bind-key "" #'hydra-shortcuts/body) (bind-key "" #'rgrep) (bind-key "" #'hydra-zoom/body) (bind-key "" #'dictcc) @@ -579,9 +578,7 @@ (use-package db-hydras :commands (hydra-toggle/body hydra-zoom/body - hydra-rectangle/body - hydra-shortcuts/body - db/define-hydra-from-frequently-used-features)) + hydra-rectangle/body)) (use-package git-commit :commands (global-git-commit-mode)) @@ -630,27 +627,6 @@ ;; * Start Menu via Helm -(defcustom db/frequently-used-features - '(("Mail" ?m db/gnus) - ("Agenda" ?a db/org-agenda) - ("Init File" ?i db/find-user-init-file) - ("EMMS" ?M emms) - ("Shell" ?s db/run-or-hide-shell) - ("EShell" ?e db/run-or-hide-eshell) - ("scratch" ?r db/scratch) - ("Info Lookup" ?I counsel-info-lookup-symbol) - ("Unicode Lookup" ?U counsel-unicode-char)) - "Mapping of frequently used features to functions implementing -them. Can be used in application shortcuts such as -`db/helm-shortcuts’. Each entry is a list of three items: a -short description, a shortcut character, and the function to -call." - :group 'personal-settings - :type '(repeat (list string character function)) - :set #'(lambda (symbol value) - (set symbol value) - (db/define-hydra-from-frequently-used-features))) - (defun db/helm-shortcuts (arg) "Open helm completion on common locations. With given ARG, display files in `db/important-document-path’." diff --git a/site-lisp/db-customize.el b/site-lisp/db-customize.el index 4eb4d34..a4da800 100644 --- a/site-lisp/db-customize.el +++ b/site-lisp/db-customize.el @@ -6,6 +6,8 @@ (require 'gnutls) + + (defgroup personal-settings nil "A bunch of functions and variables for personalizing emacs." :prefix "db/" @@ -128,6 +130,25 @@ in the main agenda view." :group 'personal-settings :type '(choice (const nil) file)) +(defcustom db/frequently-used-features + '(("Mail" ?m db/gnus) + ("Agenda" ?a db/org-agenda) + ("Init File" ?i db/find-user-init-file) + ("EMMS" ?M emms) + ("Shell" ?s db/run-or-hide-shell) + ("EShell" ?e db/run-or-hide-eshell) + ("scratch" ?r db/scratch) + ("Info Lookup" ?I counsel-info-lookup-symbol) + ("Unicode Lookup" ?U counsel-unicode-char)) + "Mapping of frequently used features to functions implementing +them. Can be used in application shortcuts such as +`db/helm-shortcuts’. Each entry is a list of three items: a +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))) + (provide 'db-customize) diff --git a/site-lisp/db-hydras.el b/site-lisp/db-hydras.el index 7a6d13b..9c73b35 100644 --- a/site-lisp/db-hydras.el +++ b/site-lisp/db-hydras.el @@ -52,24 +52,5 @@ _h_ _l_ _o_k _y_ank ("e" rectangle-exchange-point-and-mark nil) ("o" nil nil)) -(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