• Stars
    star
    341
  • Rank 119,983 (Top 3 %)
  • Language
    Emacs Lisp
  • License
    GNU General Publi...
  • Created about 11 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

language-specific refactoring in Emacs

emacs-refactor

Coverage Status MELPA MELPA stable

Emacs Refactor (EMR) is a framework for providing language-specific refactoring in Emacs. It includes refactoring commands for a variety of languages, including elisp itself!

Summary

To use EMR when editing, simply move point to an expression and M-x emr-show-refactor-menu.

Example

EMR ships with many refactoring commands, and pull requests for extensions are welcome. See Extension for details on extending EMR to other language modes. It's easy (honest!).

Installation

Install emr from MELPA, then configure your init.el:

(define-key prog-mode-map (kbd "M-RET") 'emr-show-refactor-menu)

Language support

Most EMR commands are context-sensitive and are available through the refactor menu. Some actions affect the whole buffer and are available in the menu bar.

General

These commands are available for all programming languages.

The following context-sensitive refactoring commands are available:

  • comment region
  • uncomment region

C

The following context-sensitive refactoring commands are available:

  • tidy includes

The following buffer-wide actions are available:

  • insert include

Refactoring support for C is a work in progress. Contributions are welcome.

Lisps

These commands are available to all Lisp dialects, including Clojure, Elisp and Common Lisp.

The following context-sensitive refactoring commands are available:

  • comment form
  • uncomment block

Elisp

The following context-sensitive refactoring commands are available:

  • delete unused definition
  • delete unused let binding form
  • eval and replace
  • extract autoload
  • extract constant
  • extract function
  • extract to let
  • extract variable
  • implement function
  • inline function
  • inline let variable
  • inline variable
  • insert autoload directive
  • tidy autoloads

The following buffer-wide actions are available:

  • find unused definitions

JavaScript

JavaScript refactoring support requires js2 refactor.

The following refactoring commands are available:

  • extract function
  • extract method
  • extract variable
  • add parameter
  • local variable to instance variable
  • log region

Ruby

Ruby refactoring support requires ruby refactor.

The following refactoring commands are available:

  • extract function
  • extract variable
  • extract constant
  • add parameter
  • extract to let

Scheme

The following refactoring commands are available:

  • extract function
  • extract variable

Extension

Use the emr-declare-command function to declare a refactoring action. The action will automatically become available in the refactoring popup menu.

This function supports predicate expressions, allowing the options displayed to be context-sensitive.

As an example, here is the declaration for a refactoring command that ships with EMR:

(emr-declare-command 'emr-el-extract-constant
  :title "constant"
  :description "defconst"
  :modes 'emacs-lisp-mode
  :predicate (lambda ()
               (not (or (emr-el:looking-at-definition?)
                        (emr-el:looking-at-let-binding-symbol?)))))

This wires the emr-el-extract-constant function to be displayed in emacs-lisp-mode, provided point is not looking at an Elisp definition or let-binding form.

If your favourite language mode already offers refactoring commands, it is simple to wire them up with EMR using this interface.

More Repositories

1

difftastic

a structural diff that understands syntax 🟥🟩
Rust
15,946
star
2

helpful

A better Emacs *help* buffer
Emacs Lisp
972
star
3

deadgrep

fast, friendly searching with ripgrep and Emacs
Emacs Lisp
671
star
4

ag.el

An Emacs frontend to The Silver Searcher
Emacs Lisp
521
star
5

babyc

A toy C compiler
C
496
star
6

bfc

An industrial-grade brainfuck compiler
Rust
479
star
7

suggest.el

discover elisp functions that do what you want
Emacs Lisp
344
star
8

ht.el

The missing hash table library for Emacs
Emacs Lisp
235
star
9

elisp-refs

semantic code search for emacs lisp
Emacs Lisp
111
star
10

refine

interactive value editing in emacs lisp
Emacs Lisp
85
star
11

tco.el

Tail call optimisation in Emacs lisp
Emacs Lisp
76
star
12

pyimport

Manage Python imports from Emacs!
Emacs Lisp
73
star
13

mustache.el

A mustache templating library for Emacs
Emacs Lisp
68
star
14

elisp-def

Find Emacs Lisp definitions
Emacs Lisp
61
star
15

propcheck

Quickcheck/hypothesis style testing for elisp
Emacs Lisp
59
star
16

.emacs.d

My emacs configuration
Emacs Lisp
52
star
17

pip-requirements.el

Major mode for editing pip requirements files
Emacs Lisp
51
star
18

tree-sitter-elisp

tree-sitter grammar for emacs lisp
C
46
star
19

loop.el

friendly imperative loop structures for Emacs lisp
Emacs Lisp
36
star
20

simpla-vortaro

Inteligenta vortaro de Esperanto / An intelligent Esperanto dictionary
Python
34
star
21

python-info

The python manual in texinfo format, particularly for Emacs users
Makefile
31
star
22

Brainfrack

BF implementations in different languages
Smalltalk
29
star
23

bison-mode

Emacs major mode for Bison/Jison, Yacc and Lex grammars
Emacs Lisp
27
star
24

garden

an interactive programming language
Rust
26
star
25

company-try-hard

Get all completions from company-mode backends
Emacs Lisp
24
star
26

Minimal-scheme

A simple scheme interpreter in Python
Python
23
star
27

logstash-conf.el

Emacs major mode for editing logstash configuration files
Emacs Lisp
21
star
28

trifle

A friendly lisp with a focus on interactivity and collaboration
Python
21
star
29

django-test-mixins

Additional assertions and test conveniences for testing django sites
Python
19
star
30

linkdoc

Rust tool for finding dead links on a site
Rust
14
star
31

cask-mode

Major mode for editing Cask files
Emacs Lisp
12
star
32

flymake-jshint.el

JSHint with flymake for Emacs
Emacs Lisp
12
star
33

emacsbench

Benchmarking Emacs itself
C
12
star
34

Blackjack

Simple blackjack simulator in Haskell
Haskell
11
star
35

flycheck-title

show flycheck errors in the frame title
Emacs Lisp
11
star
36

flycheck-pyflakes

flycheck support for pyflakes
Emacs Lisp
10
star
37

flycheck-pkg-config

Configure flycheck using pkg-config
Emacs Lisp
10
star
38

dotfiles

Configuration files for unix utilities
Shell
10
star
39

ReVo-utilities

a few handy scripts to work with XML dumps from ReVo
XSLT
10
star
40

Lython

Toy Lisp to Python compiler
Python
9
star
41

ez-query-replace

query-replace in Emacs with smarts and history!
Emacs Lisp
9
star
42

mal_pharo

A Make A Lisp implementation in Pharo
Smalltalk
8
star
43

FuzzyBranch

git-checkout with fuzzy branch names
Haskell
7
star
44

peval

partial evaluator for elisp
Emacs Lisp
6
star
45

wilfred.github.com

My personal blog
HTML
6
star
46

versor

Mirror of https://sourceforge.net/projects/emacs-versor/
Emacs Lisp
5
star
47

django-function-cache

Cache (memoize) a function's output using Django's caching API
Python
5
star
48

elisp-complete

Emacs Lisp
5
star
49

metawiki

Proof-of-concept self-hosting metawiki
JavaScript
5
star
50

line-numbers

accessing line numbers by string offsets
Rust
4
star
51

the_end_times

comparing programming language implementation performance
Ruby
4
star
52

autotoc

Generate and insert tables of contents in markdown files
Clojure
4
star
53

elisp-fu

Emacs Lisp
4
star
54

oosh

Object Oriented Shell
Python
4
star
55

company-smart-elisp

a contextual company backend for elisp
Emacs Lisp
4
star
56

podkastaro

Podcast aggregator, targeted at Esperanto radio
PHP
3
star
57

gameboy_emulator

Rust code following along with http://imrannazar.com/GameBoy-Emulation-in-JavaScript
Rust
3
star
58

HandyBot

IRC Bot in Clojure
Clojure
3
star
59

with-namespace.el

interoperable elisp namespaces
Emacs Lisp
3
star
60

advent-of-code

Racket
2
star
61

not-quite-modal.el

Modal-inspired movement in Emacs
Emacs Lisp
2
star
62

srch

Emacs Lisp
2
star
63

sudoku

A sudoku solver in CoffeeScript
CSS
2
star
64

userinfo

cross-platform user details library in Rust
Rust
2
star
65

nmap-service

A service for telling clients what ports they have open
Python
2
star
66

smart-eval.el

helpful eval and re-eval for elisp
Emacs Lisp
2
star
67

Jeweled

A Bejeweled bot
Python
2
star
68

elisp-index

Emacs Lisp
2
star
69

Picky

An opinionated wiki
JavaScript
2
star
70

expenses

Categorising and analysing personal expenses
Python
1
star
71

ButlerBot

Haskell news email bot
Haskell
1
star
72

syntax-cafe

programming languages to suit all tastes
TypeScript
1
star
73

podkastaro2

Nova versio de Podkastaro, uzanta Django-n
Python
1
star
74

commonmark-extract-text

extract plain text from commonmark/markdown source
JavaScript
1
star
75

hubot-tube-status

A hubot script for getting the current tube status
CoffeeScript
1
star
76

bf_bench

BF implementation benchmarking
Brainfuck
1
star
77

rustls.el

Emacs Lisp
1
star
78

emailomatic

web scraper for collecting interesting events to attend
Clojure
1
star
79

sooty

a dumb lisp with a handwritten GC
Rust
1
star
80

overseer.el

Ert-runner Integration Into Emacs
Emacs Lisp
1
star
81

chrome_crash_example

JavaScript
1
star
82

parsimonious

Simple command line calculator using hand written parser
Java
1
star
83

commonmark-wikiwords

Convert WikiWords to links in commonmark source
JavaScript
1
star
84

zorklike

a text adventure game inspired web page
JavaScript
1
star
85

is_my_internet_filtered

A website that tests whether any content is being filtered
JavaScript
1
star
86

dumb-code-quick

more tests, less code
TypeScript
1
star
87

blog-comments

a simple blog comments system in Clojure
Clojure
1
star