Using Emacs as Clojure IDE
Open emacs24;
Change CWD to parent folder of project home: M-x cd ~/docs/tmp;
Build a leiningen project: M-! lein new calc-cov (see Run Shell Command in Emacs for other method to run shell command in emacs);
Change CWD to project home: M-x cd calc-cov;
Start nrepl server: M-x nrepl-jack-in;
Open source file in another window: C-x 2 C-x C-f src/.../core.clj;
Change the namespace of the REPL to the namespace of the file you are in: C-c M-n;
Evaluate the whole source file: C-c C-k, evaluate a s-exp before the cursor: C-x C-e;
Open clojure doc of the function under the cursor: C-c C-d
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
Add this sexp into source file (unnecessary to save source file);
Use following methods to evaluate the sexp:
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;
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的更多相关文章
- emacs 配置 clojure
安装JDK,Version >= 6.0 java -version 2 安装EMACS,Version>=24 在脚本~/.emacs.d/init.el中增加如下内容 (require ...
- emacs配置详解及C/C++IDE全功能配置演示(附配置文件)
我的emacs插件下载地址: http://pan.baidu.com/share/link?shareid=4196458904&uk=3708780105 说明: 1.为什么使用emacs ...
- 为了树莓派IIraspberrypi安装emacs+ecb+cedet+session+color-theme+cscope+linum
类似这篇文章写的不多,为了避免以后大家转来转去而忽略了写文章的时间,这些特别加上是2014年6月28日,省的对不上一些软件的版本号(下文中有些"最新"的说法就相应这个时间).假设转 ...
- CentOS6.x之emacs安装配置编译
刚开始学习linux,干学没什么意思,想在linux下写写程序,了解到linux下使用较多的是emacs和vim,在youtobe上分别看了看这两个工具进行开发的视频,个人感觉emacs比较酷一点,所 ...
- JVM 平台上的各种语言的开发指南
JVM 平台上的各种语言的开发指南 为什么我们需要如此多的JVM语言? 在2013年你可以有50中JVM语言的选择来用于你的下一个项目.尽管你可以说出一大打的名字,你会准备为你的下一个项目选择一种新的 ...
- 2017-05-4-C语言学习笔记
C语言学习笔记... ------------------------------------ Hello C语言:什么是程序:程序是指:完成某件事的既定方式和过程.计算机中的程序是指:为了让计算机执 ...
- YASM User Manual
This document is the user manual for the Yasm assembler. It is intended as both an introduction and ...
- Linux 下配置 Python IDE——Emacs
工欲善其事,必先利其器.Python作为高级语言,因为其简介.灵活已经被越来越多的程序员所青睐.在尝试了众多IDE之后,终于找到了自己的挚爱.废话少说,下面开始说一下如何在linux下安装配置Emac ...
- 只有文本编辑器才是王道, 什么ide都是evil的浮云, 看看linus linux的内核开发工具vim emacs
只有文本编辑器才是王道, 什么ide都是evil的浮云, 看看linus linux的内核开发工具vim emacs [ide is evil] (http://i.cnblogs.com/EditP ...
随机推荐
- 2300+字!在不同系统上安装Docker!看这一篇文章就够了
辰哥准备出一期在Docker跑Python项目的技术文,比如在Docker跑Django或者Flask的网站.跑爬虫程序等等. 在Docker跑Python程序的时候不会太过于细去讲解Docker的基 ...
- sonarqube 8.9版本配置发信邮箱
admin登陆sonarqube系统 安装部署sonarqube 请参见我的安装博文: https://www.cnblogs.com/cndevops/p/14934434.html 配置邮箱 配置 ...
- nginx开启tls1.2及一些注意问题
因为http传输是明文,通过抓包很容易获取到报文, 所以现在很多站点都开启了https,HTTPS在HTTP的基础上加入了SSL协议,对传输的数据进行加密. 目前主流的ssl协议是tlsv1.2 ng ...
- maven与eclipse的集成
由于篇幅问题,本文将不介绍maven的安装和配置. 一.maven的概念 Maven(翻译为"专家","内行")是跨平台的项目管理工具.主要服务于基于Java平 ...
- C# 8.0和.NET Core 3.0高级编程 分享笔记三:控制流程和转换类型
控制流程和转换类型 本章的内容主要包括编写代码.对变量执行简单的操作.做出决策.重复执行语句块.将变量或表达式值从一种类型转换为另一种类型.处理异常以及在数值变量中检查溢出. 本章涵盖以下主题: 操作 ...
- python import 导入两个模块同时有同一名称的方法如何调用 ?
from moudule import *(这种方法不推荐) 一般不推荐使用"from 模块 import"这种语法导入指定模块内的所有成员,因为它存在潜在的风险. 比如同时导入 ...
- Java基础00-Java概述1
1. Java语言发展史 1.1 Java语言 语言:人与人交流沟通的表达方式 计算机语言:人与计算机之间进行信息交流沟通的一种特殊语言 Java语言是美国Sun公司(Stanford Univers ...
- poj 折半搜索
poj2549 Sumsets 题目链接: http://poj.org/problem?id=2549 题意:给你一个含有n(n<=1000)个数的数列,问这个数列中是否存在四个不同的数a,b ...
- ZooKeeper 分布式锁 Curator 源码 04:分布式信号量和互斥锁
前言 分布式信号量,之前在 Redisson 中也介绍过,Redisson 的信号量是将计数维护在 Redis 中的,那现在来看一下 Curator 是如何基于 ZooKeeper 实现信号量的. 使 ...
- Python+Requests+Xpath(解析)爬取某站点简历图片(数据分析三)
1.环境安装 pip install lxml 2.解析原理 使用通用爬虫爬取网页数据 实例化etree对象,且将页面数据加载到该对象中 使用xpath函数结合xpath表达式进行标签定位和指定数据提 ...