A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/magnars/js2-refactor.el below:

js-emacs/js2-refactor.el: A JavaScript refactoring library for emacs

js2-refactor.el

A JavaScript refactoring library for emacs.

This is a collection of small refactoring functions to further the idea of a JavaScript IDE in Emacs that started with js2-mode.

Add expand-node-at-point and contract-node-at-point function to Expand / Contract bracketed list according to node type at point (array, object, function, call args).

Removed previous ea ca eo co eu cu ec cc key bindings.

js2-refactor.el is now a minor mode that has to be enabled, with something like the following:

(add-hook 'js2-mode-hook #'js2-refactor-mode)

You now choose your own keybinding scheme. If you just want what you had before this change, add this to your init:

(js2r-add-keybindings-with-prefix "C-c C-m")

See Setup keybindings below for more.

I highly recommend installing js2-refactor through elpa.

It's available on melpa:

M-x package-install js2-refactor

You can also install the dependencies on your own, and just dump js2-refactor in your path somewhere:

I also recommend that you get expand-region to more easily mark vars, method calls and functions for refactorings.

Then add this to your emacs settings:

(require 'js2-refactor)
(add-hook 'js2-mode-hook #'js2-refactor-mode)

js2-refactor does not work in a buffer that has Javascript parse errors. To tell js2-mode to treat hashbangs as comments, which prevents them from causing parse errors, add this:

(setq js2-skip-preprocessor-directives t)

All functions in js2-refactor have a two-letter mnemonic shortcut. For instance, extract-function is ef. You get to choose how those are bound. Here's how:

(js2r-add-keybindings-with-prefix "C-c C-m")
;; eg. extract function with `C-c C-m ef`.

If you would rather have a modifier key, instead of a prefix, do:

(js2r-add-keybindings-with-modifier "C-s-")
;; eg. extract function with `C-s-e C-s-f`.

If neither of these appeal to your sense of keyboard layout aesthetics, feel free to pick and choose your own keybindings with a smattering of:

(define-key js2-refactor-mode-map (kbd "C-c C-e C-f") 'js2r-extract-function)

Additionally, for an interactive list of available keybindings the following hydra can be used as a starting point.

There are also some minor conveniences bundled:

A list of some wanted improvements for the current refactorings.

Thanks!

This project is still in its infancy, and everything isn't quite sorted out yet. If you're eager to contribute, please add an issue here on github and we can discuss your changes a little before diving into the elisp. :-)

To fetch the test dependencies, install cask if you haven't already, then:

$ cd /path/to/js2-refactor.el
$ cask

Run the tests with:

Copyright (C) 2012-2014 Magnar Sveen

Copyright (C) 2015-2016 Magnar Sveen and Nicolas Petton

Author: Magnar Sveen magnars@gmail.com, Nicolas Petton nicolas@petton.fr

Keywords: javascript refactorings

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4