1. Open emacs24;

  2. Change CWD to parent folder of project home: M-x cd ~/docs/tmp;

  3. Build a leiningen project: M-! lein new calc-cov (see Run Shell Command in Emacs for other method to run shell command in emacs);

  4. Change CWD to project home: M-x cd calc-cov;

  5. Start nrepl server: M-x nrepl-jack-in;

  6. Open source file in another window: C-x 2 C-x C-f src/.../core.clj;

  7. Change the namespace of the REPL to the namespace of the file you are in: C-c M-n;

  8. Evaluate the whole source file: C-c C-k, evaluate a s-exp before the cursor: C-x C-e;

  9. Open clojure doc of the function under the cursor: C-c C-d

  10. Run test: C-c C-,

Frequently used keyboard shortcuts and commands

  • Toggle focus between nrepl window and clojure source file window: C-c C-z (you should add "(add-to-list 'same-window-buffer-names "nrepl")" to ~/.emacs;

  • Always pretty printing in the REPL: M-x nrepl-toggle-pretty-printing

  • Move over sexp: C-M-b/C-M-f;

  • Interrupt any pending evaluations: C-c C-b;

Evaluate a sexp without evaluate all file

  1. Add this sexp into source file (unnecessary to save source file);

  2. Use following methods to evaluate the sexp:

  3. Move cursor to the sexp for test, C-M-x (or C-c C-c) to evaluate the top-level form (such as a defn expression) under the cursor; If you want insert the evaluation result to current buffer, use C-u C-M-x;

  4. If the the target form is not a "top-level" form, move the cursor to the end of this sexp, C-x C-e to evaluate it, See more shortcuts at nrepl official site;

Then this sexp has been added to the repl, you can use it in repl;

This is very helpful in some circumstances. For example, I want debug function "cell-block" (see p141 in "Clojure Programming"), add

(println "[left mid right] is:")
(println [left mid right])

before "(window (map ...)". But You can't evaluate the whole file because there are some lazy sequences and evaluate whole file will cause JVM heap out of memory; So I only evaluate this modified version with C-x C-e, test it in repl. After I figure out how this function works, undo my modification and move on.

Note:

  • In clojure mode with Evil, you have to switch to insert state and put the cursor after the last parenthsis, then evaluate the expression with C-x C-e. If you put the cursor on the last parenthesis in normal state, The result will be wrong.

  • It unnecessary to put your clojure file in a leiningen-created project, which is more flexible than vim-fireplace;

  • The value of expression will be output to the message area (bottom of the emacs window), while the output by "println" will be output to nrepl buffer;

  • Switch cursor between windows: C-x o;

  • Clear repl output: C-c M-o;

  • Indent code blocks intelligently: C-M-q

  • All the keyboard shortcuts will be more convenient if you swap CapsLock key and Escape key, together with Ctrl key and Alt key, see Define Keymap on Ubuntu for detail;

Ref: http://stackoverflow.com/questions/3636364/can-i-clean-the-repl

Ref: Clojure with Emacs

Using Emacs as Clojure IDE的更多相关文章

  1. emacs 配置 clojure

    安装JDK,Version >= 6.0 java -version 2 安装EMACS,Version>=24 在脚本~/.emacs.d/init.el中增加如下内容 (require ...

  2. emacs配置详解及C/C++IDE全功能配置演示(附配置文件)

    我的emacs插件下载地址: http://pan.baidu.com/share/link?shareid=4196458904&uk=3708780105 说明: 1.为什么使用emacs ...

  3. 为了树莓派IIraspberrypi安装emacs+ecb+cedet+session+color-theme+cscope+linum

    类似这篇文章写的不多,为了避免以后大家转来转去而忽略了写文章的时间,这些特别加上是2014年6月28日,省的对不上一些软件的版本号(下文中有些"最新"的说法就相应这个时间).假设转 ...

  4. CentOS6.x之emacs安装配置编译

    刚开始学习linux,干学没什么意思,想在linux下写写程序,了解到linux下使用较多的是emacs和vim,在youtobe上分别看了看这两个工具进行开发的视频,个人感觉emacs比较酷一点,所 ...

  5. JVM 平台上的各种语言的开发指南

    JVM 平台上的各种语言的开发指南 为什么我们需要如此多的JVM语言? 在2013年你可以有50中JVM语言的选择来用于你的下一个项目.尽管你可以说出一大打的名字,你会准备为你的下一个项目选择一种新的 ...

  6. 2017-05-4-C语言学习笔记

    C语言学习笔记... ------------------------------------ Hello C语言:什么是程序:程序是指:完成某件事的既定方式和过程.计算机中的程序是指:为了让计算机执 ...

  7. YASM User Manual

    This document is the user manual for the Yasm assembler. It is intended as both an introduction and ...

  8. Linux 下配置 Python IDE——Emacs

    工欲善其事,必先利其器.Python作为高级语言,因为其简介.灵活已经被越来越多的程序员所青睐.在尝试了众多IDE之后,终于找到了自己的挚爱.废话少说,下面开始说一下如何在linux下安装配置Emac ...

  9. 只有文本编辑器才是王道, 什么ide都是evil的浮云, 看看linus linux的内核开发工具vim emacs

    只有文本编辑器才是王道, 什么ide都是evil的浮云, 看看linus linux的内核开发工具vim emacs [ide is evil] (http://i.cnblogs.com/EditP ...

随机推荐

  1. docker安装mysql镜像和容器

    下拉镜像 docker pull mysql/mysql-server:5.5 后面的mysql标签是版本号,是可选择的,有: 5.5 5.6 5.7 8.0 创建mysql5.5的容器 docker ...

  2. redis的基本操作指令

    https://www.cnblogs.com/woshimrf/p/5198361.html

  3. 掌握了这几个Linux命令可以让你工作效率提高一倍

    01 top命令 第一个命令就是top,这个命令是Linux下常用的性能分析工具,能够实时显示系统中各个进程的资源占用情况,有点类似Windows下的任务管理器. 最上面每一行都表示一种性能数据: t ...

  4. Acunetix与WAF集成:Acunetix和F5 BigIP ASM

    该的Acunetix API让您有机会来实现任务自动化,从而提高效率-尤其是当你可以用加速您的工作流程的其他组件的功能整合.在此示例中,我们将在上一篇文章的基础上,向您展示如何在Bash脚本中使用Ac ...

  5. 「CF555E」 Case of Computer Network

    「CF555E」 Case of Computer Network 传送门 又是给边定向的题目(马上想到欧拉回路) 然而这个题没有对度数的限制,你想歪了. 然后又开始想一个类似于匈牙利的算法:我先跑, ...

  6. 认识vue-cli脚手架

    ps:脚手架系列主要记录我自己(一名前端小白)对脚手架学习的一个过程,如有不对请帮忙指点一二! [抱拳] 作为一名前端开发工程师,平时开发项目大多都离不开一个重要的工具,那就是脚手架.下面让我们来了解 ...

  7. 【NOIP2007】Hanoi双塔问题

    题目描述 给定A.B.C三根足够长的细柱,在A柱上放有2n个中间有孔的圆盘,共有n个不同的尺寸,每个尺寸都有两个相同的圆盘,注意这两个圆盘是不加区分的(下图为n=3的情形). 现要将这些圆盘移到C柱上 ...

  8. Linux bash命令行常用快捷键(Xshell和secure CRT以及gnome-terminal)

    常用的命令行击键操作 ctrl + insert   xshell中复制,可以设置选中内容自动复制ctrl shift + c crt中复制shift + insert xshell中粘贴ctrl s ...

  9. 如何移除本地文件夹与Git的连接

    1.在需要移除的文件夹下打开Git Bash 2.在命令行中输入如下语句 find . -name ".git" | xargs rm -Rf

  10. Windows10 64位解决无法使用Microsoft.Jet.OLEDB.4.0的方法

    本机软件环境:Windows10 64位+Office2003 (32位) ============================================= 1.下载 ACE2010的驱动, ...