Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aliases for defhydra #397

Open
enisozgen opened this issue Apr 2, 2021 · 0 comments
Open

Aliases for defhydra #397

enisozgen opened this issue Apr 2, 2021 · 0 comments

Comments

@enisozgen
Copy link

Hello Oleh,

First thanks for this awesome tool which increase Emacs usability.

I want to make some request related with hydra.

TLDR

Giving aliases for auto generated interactive functions can make the tool more user friendly.

Explanation

Every defhydra functions like this

(defhydra hydra/feature-request ()
  ("i" (insert "foo") "insert foo")
  ("a" (progn
         (org-agenda nil "t")
         (message "Agenda is ready"))
   "Open agenda and say agenda is ready"
   :exit t)
  ("mcs" (progn
           (more)
           (if something
               (complex)
             (stuff)))
   "More complex stuff"
   :exit t))

Produces some interactive Lambda functions which are visible in M-x. Even
they are ready to serve for their purpose. I must say that those lambda function
names are not human friendly since they are not memorable. Therefore, I guess
nobody uses it via M-x.

Picture

image

We can always define different aliases like in below or we can use standalone
functions in hydra but I have better idea.

(defalias 'insert-foo         'hydra/feature-request/lambda-i)
(defalias 'my-agenda-todo     'hydra/feature-request/lambda-a-and-exit)
(defalias 'more-complex-stuff 'hydra/feature-request/lambda-mcs-and-exit)

My request

It can be good to define alias in the defhydra functions so users can reach
by using aliases in M-x buffer

Ex:

((defhydra hydra/feature-request ()
  ("i" (insert "foo")
   :alias "insert-foo"
   "insert foo")
  ("a" (progn
         (org-agenda nil "t")
         (message "Agenda is ready"))
   :exit t
   :alias "my-agenda-todo"
   "Open agenda and say agenda is ready")
  ("mcs" (progn
           (more)
           (if something
               (complex)
             (stuff)))
   :alias "more-complex-stuff"
   :exit t
 "More complex stuff"))

Best Regards,
Enis

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant