Skip to content

Instantly share code, notes, and snippets.

@anachronic
Last active August 24, 2022 13:07
Show Gist options
  • Save anachronic/7af88c62db136727cd1fed17ee0a662f to your computer and use it in GitHub Desktop.
Save anachronic/7af88c62db136727cd1fed17ee0a662f to your computer and use it in GitHub Desktop.
A hydra for js2-refactor in emacs
(defhydra js2-refactor-hydra (:color blue :hint nil)
"
^Functions^ ^Variables^ ^Buffer^ ^sexp^ ^Debugging^
------------------------------------------------------------------------------------------------------------------------------
[_lp_] Localize Parameter [_ev_] Extract variable [_wi_] Wrap buffer in IIFE [_k_] js2 kill [_lt_] log this
[_ef_] Extract function [_iv_] Inline variable [_ig_] Inject global in IIFE [_ss_] split string [_dt_] debug this
[_ip_] Introduce parameter [_rv_] Rename variable [_ee_] Expand node at point [_sl_] forward slurp
[_em_] Extract method [_vt_] Var to this [_cc_] Contract node at point [_ba_] forward barf
[_ao_] Arguments to object [_sv_] Split var decl. [_uw_] unwrap
[_tf_] Toggle fun exp and decl [_ag_] Add var to globals
[_ta_] Toggle fun expr and => [_ti_] Ternary to if
[_q_] quit"
("ee" js2r-expand-node-at-point)
("cc" js2r-contract-node-at-point)
("ef" js2r-extract-function)
("em" js2r-extract-method)
("tf" js2r-toggle-function-expression-and-declaration)
("ta" js2r-toggle-arrow-function-and-expression)
("ip" js2r-introduce-parameter)
("lp" js2r-localize-parameter)
("wi" js2r-wrap-buffer-in-iife)
("ig" js2r-inject-global-in-iife)
("ag" js2r-add-to-globals-annotation)
("ev" js2r-extract-var)
("iv" js2r-inline-var)
("rv" js2r-rename-var)
("vt" js2r-var-to-this)
("ao" js2r-arguments-to-object)
("ti" js2r-ternary-to-if)
("sv" js2r-split-var-declaration)
("ss" js2r-split-string)
("uw" js2r-unwrap)
("lt" js2r-log-this)
("dt" js2r-debug-this)
("sl" js2r-forward-slurp)
("ba" js2r-forward-barf)
("k" js2r-kill)
("q" nil)
)
@NicolasPetton
Copy link

@anachronic would you like to submit a PR with this hydra to js2-refactor?

@anachronic
Copy link
Author

Sure, I'm just not sure about where I should include it. I'll do it over the weekend

@dakra
Copy link

dakra commented Jul 21, 2017

Imho including it in the README is best.. We probably don't want hydra as an added dependency?!

@vxe
Copy link

vxe commented Aug 5, 2018

What's the issue with Hydra? Its solid code from a prominent member of this community. Also I can't imagine how a solution that involves leaving emacs could be consider the best.

@NicholasPetton need it be any more complicated than this? js-emacs/js2-refactor.el#115

@baerrach
Copy link

Thanks for this hydra

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment