All Projects → clojure-emacs → Clj Refactor.el

clojure-emacs / Clj Refactor.el

Licence: gpl-3.0
A collection of Clojure refactoring functions for Emacs

Programming Languages

clojure
4091 projects

Projects that are alternatives of or similar to Clj Refactor.el

Webpaste.el
webpaste.el can paste whole buffers or parts of buffers to several pastebin-like services and supports failover if one service fails.
Stars: ✭ 67 (-90.35%)
Mutual labels:  emacs, emacs-mode
Emacs Solidity
The official solidity-mode for EMACS
Stars: ✭ 120 (-82.71%)
Mutual labels:  emacs, emacs-mode
Fingers.el
Modal editing minor mode for Emacs
Stars: ✭ 51 (-92.65%)
Mutual labels:  emacs, emacs-mode
Nyan Mode
Nyan Cat for Emacs! Nyanyanyanyanyanyanyanyanyan!
Stars: ✭ 590 (-14.99%)
Mutual labels:  emacs, emacs-mode
Zoom
Fixed and automatic balanced window layout for Emacs
Stars: ✭ 252 (-63.69%)
Mutual labels:  emacs, emacs-mode
Psc Ide Emacs
Emacs integration for PureScript's psc-ide tool.
Stars: ✭ 130 (-81.27%)
Mutual labels:  emacs, emacs-mode
Jq Mode
Emacs major mode for editing jq queries.
Stars: ✭ 70 (-89.91%)
Mutual labels:  emacs, emacs-mode
Writegood Mode
Minor mode for Emacs to improve English writing
Stars: ✭ 369 (-46.83%)
Mutual labels:  emacs, emacs-mode
Live Py Plugin
Live coding in Python with PyCharm, Emacs, Sublime Text, or even a browser
Stars: ✭ 222 (-68.01%)
Mutual labels:  emacs, emacs-mode
Org Msg
OrgMsg is a GNU/Emacs global minor mode mixing up Org mode and Message mode to compose and reply to emails in a Outlook HTML friendly style.
Stars: ✭ 153 (-77.95%)
Mutual labels:  emacs, emacs-mode
Swift Mode
Emacs support for Apple's Swift programming language.
Stars: ✭ 308 (-55.62%)
Mutual labels:  emacs, emacs-mode
Deft
Deft for Emacs
Stars: ✭ 521 (-24.93%)
Mutual labels:  emacs, emacs-mode
Markdown Mode
Emacs Markdown Mode
Stars: ✭ 634 (-8.65%)
Mutual labels:  emacs
Meghanada Emacs
A Better Java Development Environment for Emacs
Stars: ✭ 582 (-16.14%)
Mutual labels:  emacs
Editorconfig Emacs
EditorConfig plugin for Emacs
Stars: ✭ 577 (-16.86%)
Mutual labels:  emacs
Emacs Package Dev Handbook
An Emacs package development handbook. Built with Emacs, by Emacs package developers, for Emacs package developers.
Stars: ✭ 666 (-4.03%)
Mutual labels:  emacs
Eslint d.js
Makes eslint the fastest linter on the planet
Stars: ✭ 615 (-11.38%)
Mutual labels:  emacs
God Mode
Minor mode for God-like command entering
Stars: ✭ 570 (-17.87%)
Mutual labels:  emacs
Its
Incompatible Timesharing System
Stars: ✭ 567 (-18.3%)
Mutual labels:  emacs
Racket Mode
Emacs major and minor modes for Racket: edit, REPL, check-syntax, debug, profile, and more.
Stars: ✭ 559 (-19.45%)
Mutual labels:  emacs

MELPA MELPA Stable circleci Gitter

clj-refactor.el

clj-refactor provides refactoring support for Clojure projects. It complements the refactoring functionality you'd find in clojure-mode and CIDER.

Here's a small teaser, helping you add a missing libspec:

Installation

It's highly recommended to install clj-refactor through package.el.

It's available on MELPA and MELPA Stable:

M-x package-install clj-refactor

Setup

(require 'clj-refactor)

(defun my-clojure-mode-hook ()
    (clj-refactor-mode 1)
    (yas-minor-mode 1) ; for adding require/use/import statements
    ;; This choice of keybinding leaves cider-macroexpand-1 unbound
    (cljr-add-keybindings-with-prefix "C-c C-m"))

(add-hook 'clojure-mode-hook #'my-clojure-mode-hook)

The more advanced refactorings require our nREPL middleware refactor-nrepl. From version 2.2.0 onwards if cider-jack-in is used it is injected automatically.

profiles.clj or profile.boot don't need to be modified anymore for the above usecase!

On the other hand if a standalone REPL or an embedded nREPL server is used you will need to manually add this dependency (see below).

Either in your project's project.clj or in the :user profile found at ~/.lein/profiles.clj:

:plugins [[refactor-nrepl "2.5.0"]
          [cider/cider-nrepl "0.24.0"]]

Check out the much longer installation page in the wiki for a less opinionated approach.

clj-refactor has quite a few settings you can tweak to change the behavior of various commands. You can read more about that here.

Compatibility

clj-refactor refactor-nrepl CIDER Clojure Java
2.4.0 2.4.0 0.17, 0.18 1.7+ 8+
2.5.0 2.5.0 0.24 1.8+ 8+

Middleware

Most users will not need to worry about this, but if you wish to configure middleware yourself, the name of the middleware is:

refactor-nrepl.middleware/wrap-refactor

Unlike cider-nrepl which defines many middleware with a handful of related ops, refactor-repl defines a single middleware which houses all of the provided nREPL ops.

In case refactor-nrepl is used for advanced (AST-based) refactorings

The analyzer refactor-nrepl uses needs to eval the code too in order to be able to build the AST we can work with. If that causes side effects like writing files, opening connections to servers, modifying databases, etc. performing certain refactoring functions on your code will do that, too.

By default the user is warned about this when an AST dependent feature is invoked. If this warning is an annoyance and the project can be evalled without any risks set cljr-warn-on-eval to nil so cljr-eagerly-build-asts-on-startup can take effect.

We create ASTs for all the namespaces at REPL start up if cljr-warn-on-eval is set to nil. If that is not desired set cljr-eagerly-build-asts-on-startup to nil in your emacs configuration. AST dependent features at the moment are find usages, rename symbol, extract function, inline symbol, rename file or dir, change function signature, promote function.

Usage

All functions in clj-refactor have a two-letter mnemonic shortcut. E.g. rs for cljr-rename-symbol. Given the prefix choice in the example setup you'd call this function by hitting C-c C-m rs

See the wiki for a complete list of available refactorings, demonstrations and customization points.

If you're having trouble remembering the mnemonic shortcuts, check out the hydra powered popup menus. They are described here.

Changelog

An extensive changelog is available here.

Contribute

Yes, please do. There's a suite of tests, so remember to add tests for your specific feature, or we might break it later.

You'll find the repo at:

https://github.com/clojure-emacs/clj-refactor.el

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

$ cd /path/to/clj-refactor
$ cask

Run the tests with:

$ make test

Before submitting a patch, or a pull request, make sure all tests are passing and that your patch is in line with the contribution guidelines.

Thanks to everyone who's contributed so far!

Get Help

Due to clj-refactor's kinship with CIDER, you can get help for it in most CIDER-related support channels.

Discord

CIDER has its own Discord chat server, created by CIDER's author Bozhidar. You can join the Discord server https://discord.com/invite/nFPpynQPME[here].

Slack

CIDER has an official https://clojurians.slack.com/[Clojurians Slack] - #cider. The channel is very active and is a great way to get a handle on some of the maintainers and interact with other CIDER/clj-refactor users. If you need an invite you can go http://clojurians.net/[here].

There's also another channel named #emacs for generic Emacs discussions.

License

Copyright © 2012-2014 Magnar Sveen Copyright © 2014-2021 Magnar Sveen, Lars Andersen, Benedek Fazekas, Bozhidar Batsov

Author: Magnar Sveen [email protected] Lars Andersen [email protected] Benedek Fazekas Keywords: convenience, clojure, cider

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/.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].