Git Product home page Git Product logo

cider-decompile's Introduction

Installation

Via package.el

package.el is the built-in package manager in Emacs 24+. On Emacs 23 you will need to get package.el yourself if you wish to use it.

cider-decompile is available on both major package.el community maintained repos - Marmalade and MELPA.

If you're not already using Marmalade, add this to your ~/.emacs.d/init.el (or equivalent) and load it with M-x eval-buffer.

(require 'package)
(add-to-list 'package-archives
             '("marmalade" . "http://marmalade-repo.org/packages/"))
(package-initialize)

For MELPA the code you need to add is:

(require 'package)
(add-to-list 'package-archives
             '("melpa" . "https://melpa.org/packages/") t)
(package-initialize)

And then you can install CIDER with the following command:

M-x package-install [RET] cider-decompile [RET]

or by adding this bit of Emacs Lisp code to your Emacs initialization file(.emacs or init.el):

(unless (package-installed-p 'cider-decompile))
  (package-install 'cider-decompile))

If the installation doesn't work try refreshing the package list:

M-x package-refresh-contents [RET]

Usage

First you have to install javap-mode because it will be used to display JVM-bytecode. You also need to compile your clojure files to bytecode by running lein compile on a command prompt inside your project directory.

Next. Since cider-decompile depends on cider, it has to be installed and running. Start cider session like this:

M-x cider-jack-in [RET]

Plugin cider-decompile doesn't compile the functions, you need to do this manually for now (this is the place for future enhancements). Easiest way to compile the whole project is to run the command

$ lein jar

Check the target/classes directory: it should contain compiled classes. If the directory is empty -- check your project.clj file. Add :aot :all option to it so that leiningen will have to compile ahead-of time all the clojure code.

Let's say, we've got the following namespace in the Clojure project: myns.core. Switch to this namespace in the cider buffer.

(in-ns 'myns.core)

Now you may decompile any function in the current namespace using command cider-decompile-func. For instance, if you have function myns.core/main, then you may decompile it like this:

M-x cider-decompile-func [RET] main [RET]

If you want to decompile a function from the other namespaces, you may use command cider-decompile-ns-func. For example, decompiling function myotherns.core/other-main would look like this:

M-x cider-decompile-ns-func [RET] myotherns.core/other-main [RET]

You need to run these commands from one of the buffers belonging to the project. Cider-decompile uses the buffer to get the relative path to target/classes.

After the command was invoked, the buffer decompiled apears showing the bytecode of the function.

Note: you may not decompile variables or macros. Pay attention on what you are decompiling: your function should be defined with defn.

cider-decompile's People

Contributors

bbatsov avatar dbushenko avatar purcell avatar syohex avatar vedang 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.