srefactor

https://github.com/tuhdo/semantic-refactor.git

git clone 'git://github.com/tuhdo/semantic-refactor.git'
59

Table of Contents

What is Semantic Refactor?

Semantic Refactor is a C/C++ refactoring tool based on Semantic parser framework.

Semantic is a package that provides a framework for writing parsers. Parsing is a process of analyzing source code based on programming language syntax. relies on Semantic for analyzing source code and uses its results to perform smart code refactoring that based on code structure of the analyzed language, instead of plain text structure.

NOTE: semantic-refactor only supports Emacs 24.4 or above at the moment.

Features

C/C++:

More info and demos

Lisp:

More info and demos

Installation

This package can be obtained from MELPA:

    (require 'srefactor)
    (require 'srefactor-lisp)
    
    ;; OPTIONAL: ADD IT ONLY IF YOU USE C/C++. 
    (semantic-mode 1) ;; -> this is optional for Lisp
    
    (define-key c-mode-map (kbd "M-RET") 'srefactor-refactor-at-point)
    (define-key c++-mode-map (kbd "M-RET") 'srefactor-refactor-at-point)
    (global-set-key (kbd "M-RET o") 'srefactor-lisp-one-line)
    (global-set-key (kbd "M-RET m") 'srefactor-lisp-format-sexp)
    (global-set-key (kbd "M-RET d") 'srefactor-lisp-format-defun)
    (global-set-key (kbd "M-RET b") 'srefactor-lisp-format-buffer)

NOTICE: If you only use Lisp formatting, you don't have to enable semantic-mode.

Usage

To use this package, a user only needs to use this single command: srefactor-refactor-at-point and semantic-mode activated. Based on the context at point, appropriate menu items are offered. When the menu opens up, the top line contains the tag at point, which is the context for offering appropriate refactor actions.

Key bindings of contextual menu:

You can hide the help message in the menu with by customizing srefactor-ui-menu-show-help and set it to nil.

(setq srefactor-ui-menu-show-help nil)