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" . "http://melpa.milkbox.net/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]
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]
Let's say, we've got the following namespace in the Clojure project: myns.core
. Compile it, pressing in its buffer:
C-c C-k
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]
After the command was invoked, the buffer decompiled apears showing the bytecode of the function.