GithubHelp home page GithubHelp logo

jagger's Introduction

jagger.el

Move/swap things (including regions, sexps, lines, words) more convenient in Emacs.

Install

Copy file jagger*.el to directory ~/.emacs.d/site-lisp/jagger/, for example, and add this to your .emacs

(add-to-list 'load-path (expand-file-name "~/.emacs.d/site-lisp/jagger"))
(require 'jagger)

Usage

Swap two regions

  • Select region1
  • jagger-swap-regions-mark-region set mark and highlight it with overlay
  • Select region2
  • jagger-swap-regions apply swap, clean overlay

A more natural way is attach swap function to yank. There is a example for evil:

(defun evil-yank@set-mark (begin end &rest argv)
  (jagger-swap-regions-mark-region-1 begin end))

(advice-add 'evil-yank :before 'evil-yank@set-mark)
(define-key evil-visual-state-map (kbd "M-p") 'jagger-swap-regions)

Then you can use it like this:

  • y yank region1 as usual, there is no highlight
  • Select region2
  • M-p to apply swap

Swap things (sexps/words/lines) surround point

(foo| bar) -> (|bar foo)  ;; jagger-swap-sexps

Swap things (sexps/words/lines) surround region

(foo [(qux "quux")] bar) -> (bar (qux "quux")| foo) ;; jagger-swap-sexps

Move things backward/forward at point

(|foo bar) -> (bar |foo) ;; jagger-move-sexp-forward

Move region backward/forward by sexp

([foo] (qux "quux") bar) -> ((qux "quux") [foo] bar) ;; jagger-move-sexp-forward
([foo (qux "quux")] bar) -> (bar [foo (qux "quux")])

Move line up/down

|foo  =>  bar   ;; jagger-move-line-down
bar       |foo

Move region up/down

[foo      qux   ;; jagger-move-line-down
bar]  =>  [foo
qux       bar]

Sort sexps at point in temp buffer

Original bffer:

(foo (qux "quux") bar)

M-x jagger-sort-sexps-at-point-in-temp-buffer switch to temp buffer in other window:

foo               (qux "quux")   ;; M-j/k to move one line at point \
(qux "quux")  =>  bar            ;; or multiple lines in region \down/down
bar               foo

C-c C-c commit changes to original buffer:

((qux "quux") bar foo)

or C-c C-k discard changes.

jagger's People

Contributors

twlz0ne avatar xuchunyang avatar

Watchers

Fangrui Song avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.