AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Hydra symbol12/22/2023 ![]() To insert a dynamic Elisp variable, use %` followed by the variable. The only use of this is to have your code aligned as The key will make the hydra exit, the color will be blue. The key will be highlighted with the color that is appropriate to the behavior of the key, i.e. Note that the key must belong to one of the heads. To highlight a key, just wrap it in underscores. Newline, the key-highlighting and Ruby-style string interpolation becomes enabled, as you can see in This can be a simple string used to build the final hydra hint. Use this option if you want to override hydra-base-map for the current hydra. This is useful if you want to have a few heads thatĪre not bound outside the hydra. The :bind key can be overridden by each head. Instead of define-key you can use this option. But if you would like to bind your heads with e.g. The :bind key provides a lambda to be used to bind each head. See below for an explanation of head hint. Each head is allowed to override it, of course. The :hint key will be inherited by each head. The :timeout key starts a timer for the corresponding amount of seconds that disables the hydra.Ĭalling any head will refresh the timer. The keys will be highlighted with the appropriate color. It's also a trick to make you instantly aware of the current hydra keys that you're about to press: It aggregates :exit and :foreign-keys key in the following way: :foreign-keys run will not stop the hydra state, and try to run the foreign key.:foreign-keys warn will not stop the hydra state, but instead will issue a warning without.:foreign-keys nil (the default) means that the hydra state will stop and the foreign key willĭo whatever it was supposed to do if there was no hydra state.The :foreign-keys key belongs to the body and decides what to do when a key is pressed that doesn't :exit t means that the hydra state will stop.:exit nil (the default) means that the hydra state will continue - you'll still see the hint and be able to use short bindings.The :exit key is inherited by every head (they can override it) and influences what will happen Thanks to :pre, each time any head is called, the cursor color is changed.Īnd when the hydra quits, the cursor color will be made black again with :post. (defhydra hydra-vi ( :pre ( set-cursor-color "#40e0d0 ") The Rules of Hydra-ticsĮach hydra (take awesome as a prefix to make it more specific) looks like this: You can find some user created hydras and more documentation in the project's The docstrings and comments in the source. Either modify an existing hydra to do what you want to do.Is usually the entry point to complex hydras. This function does nothing except setting up the hint and the keymap, and One additional function is created and returned as the result of defhydra. Looking at the code, you can see hydra-buffer-menu as sort of a namespace construct that wrapsĮach function that it's given in code that shows that hint and makes it easy to call the relatedįunctions. ( "o " Buffer-menu-other-window "other-window " :color blue) ( "v " Buffer-menu-select "select " :color blue) ( "R " Buffer-menu-isearch-buffers-regexp :color blue) ( "I " Buffer-menu-isearch-buffers :color blue) ( "O " Buffer-menu-multi-occur :color blue) ![]() " ^Mark^ ^Unmark^ ^Actions^ ^Search ^^^^^^^^- _m_: mark _u_: unmark _x_: execute _R_: re-isearch _s_: save _U_: unmark up _b_: bury _I_: isearch _d_: delete ^ ^ _g_: refresh _O_: multi-occur _D_: delete up ^ ^ _T_: files only: % -28`Buffer-menu-files-only _~_: modified " (defhydra hydra-buffer-menu ( :color pink Sample Hydras The one with the least amount of code If you want to quickly understand the concept, see the video demo. Any key other than j or k exits this state.Īssign a custom hint to this group of functions, so that you know immediatelyĪfter pressing C-c that you can follow up with j or Hydra allows you to:īind your functions in a way that pressing C-c jjkk3j5k isĮquivalent to pressing C-c j C-c j C-c k C-c k M-3 C-c j M-5 C-c Imagine that you have bound C-c j and C-c k in yourĬonfig. This makes the Hydra very seamless, it's like a minor mode that disables itselfĪuto-magically. Hercules, besides vanquishing the Hydra, will still serve his original purpose, calling his properĬommand. The Hydra is vanquished once Hercules, any binding that isn't the Hydra's head, arrives. Once you summon the Hydra through the prefixed binding (the body + any one head), all heads can beĬalled in succession with only a short extension. This is a package for GNU Emacs that can be used to tie related commands into a family of short
0 Comments
Read More
Leave a Reply. |