2016年10月29日星期六

开源项目:【自动】绘图工具 Graphviz——《太子党关系网络》就是用它制作

文章目录
★先插播一个安全通告
★引子
★Graphviz 是啥?
★Graphviz 能干啥?
★为啥用 Graphviz 而不用 Visio 或类似的工具?
★Graphviz 软件的使用
★DOT 语言入门
★相关资源

★先插播一个安全通告


  一星期前(2月16日)曝光了一个高危漏洞。该漏洞存在于广泛使用的 glibc(GNU C Library)。Linux 和 BSD 上面有非常多的软件依赖了这个库。而且出漏洞的函数是 getaddrinfo——该函数被很多软件(比如:各种脚本语言引擎、SSH、cURL ......)用于 DNS 相关的功能。
  这个漏洞是可以被远程利用的。攻击者可以通过好几种方式来利用该漏洞,俺认为可能性比较大的方式是“中间人攻击”。具体的技术细节就不多谈了,感兴趣的同学可以参见 Google 官方的安全博客(链接在“这里”)。
  值得一提的是:
  这个高危漏洞,又是 Google 的研究人员披露的。为啥俺要说【又】?因为最近几年,已经有好多个影响很广泛的高危漏洞是 Google 安全研究团队曝光的(还记得前些年那个“心脏出血”漏洞吗)。所以,俺把博客架设在 Google 的 Blogspot 平台上还是比较放心的。虽然 Blogspot 博客平台在全球博客市场排名老二,但是份额最大的 Wordpress 平台,出了太多的安全漏洞,令人实在不敢恭维——据说前几天 Linux Mint 官网被入侵,就是因为 WordPress 的漏洞。

  当某个高危漏洞曝光之后,到相关软件提供补丁,这中间有一个很危险的窗口期。
  由于俺是高危险人士,所以前几天先保持静默——暂不使用“编程随想”这个身份进行网络活动。


★引子


  前段时间俺承诺把《太子党关系网络》开源到俺的 GitHub 帐号下。
  对这个项目而言,“开源”只是一种手段而不是目的,开源的目的是:让更多人能够参与到其中,一起曝光天朝的权贵。
  为了更好的达成此目的,今天发一篇博文,扫盲一下 Graphviz 这个牛B的绘图工具。俺制作的《太子党关系网络》就是用它来【自动】生成各种复杂的网状关系图。

★Graphviz 是啥?


  Graphviz 是洋文“Graph Visualization”的缩略词,是一个开源的,跨平台的自动绘图工具,其官网在“这里”,维基百科的介绍在“这里”。
  这玩意儿诞生于上个世纪末,来自 AT&T 的实验室,属于名门正派出身。十多年来,它已经被广泛使用于各个领域。其 Mac OS 版本甚至还获得了2004年的苹果设计奖。
  Graphviz 不但是开源软件,而且是自由软件。使用它完全【无需】付费,也【没有】任何注册码之类的恶心东西。

(下图是 UNIX 操作系统的全家福,基于 Graphviz 绘制)
不见图 请翻墙

★Graphviz 能干啥?


  “绘图工具”有很多种,Graphviz 主要是用来绘制【关系图】。所以它更类似于微软的 Visio。但是它与 Visio 有一个【本质上】的差异:
用 Visio 画图是【手动】的——你需要动用你的肉眼和手指头。
而用 Graphviz 画图是【自动】的——你只需要告诉 Graphviz 这张图包含哪些元素,元素之间有啥关系,然后 Graphviz 可以【自动】帮你画出来。
  那么,你如何告诉 Graphviz 你要画的图形包含哪些元素捏?这就需要用到一个名叫 DOT 的描述语言(待会儿俺会简单介绍 DOT 语言)。

★为啥用 Graphviz 而不用 Visio 或类似的工具?


  客观地讲,Graphviz 和 Visio 之类的工具,各有各的特长。因为本文介绍的是 Graphviz,所以下面聊一下:哪些场景是 Graphviz 胜过 Visio 类工具的。
  简而言之,Graphviz 胜过 Visio 这类工具的关键在于【自动布局】。如果你要绘制的关系图非常复杂,这时候【手动】布局就变得极其繁琐。而 Graphviz 的自动布局功能,再复杂的关系图,也可以自动搞定。
  请看下面几个例子(都是用 Graphviz 自动绘制的)

下图是美国本土48个州的比邻关系(不含2个海外的州)
不见图 请翻墙
可能有读者此图不以为然,觉得48个节点不算多。这张图如果【手工】绘制,难点之一在于:如何让所有联线的交叉最少(图中只有一处交叉)。单单这点就足够伤脑筋了。
而 Graphviz 的自动布局功能,无需人为干预就可以做到“最小化连线交叉”。

下图是俺整理的《太子党关系网络》其中一幅图(原图太大,缩小4倍之后裁剪其中一部分)
不见图 请翻墙

  如果你想看更复杂的关系图,可以去 Graphviz 官网。那上面收集了一些超级复杂的关系图(链接在“这里”)。

★Graphviz 软件的使用


◇下载、安装


  对于用 Windows 的同学,直接上官网的这个页面,可以下载到 Windows 的二进制软件包;
  对于用 Linux 的同学,主流的发行版的“软件仓库”应该都包含了 graphviz,你只需用发行版内置的软件包管理器,就可以把 graphviz 装好;
  对于用 Mac OS 的同学,到官网的“这个页面”下载软件包。

◇DOT 命令行的使用


  (如果你从来没有用过命令行,建议先了解“命令行”相关的基本概念,再来本看小节)
  假设你已经用 DOT 语言写好了一个关系图的描述文件,假设这个文件名是 test.gv 那么你可以进入 test.gv 所在的目录,然后用如下命令生成【png图片】
dot -Tpng -O test.gv
对于 Windows 用户的说明:
  你可以把 graphviz 安装目录下的 bin 目录设置到 PATH 环境变量中,就可以在命令行中直接使用 dot 命令。否则的话,你需要用【全路径】方式来启动 dot 命令。

◇支持的输出格式


  上述命令行中的 -Tpng 表示生成的文件类型是png图片。如果你需要生成其它格式,也可以。目前 Graphviz 支持很多种格式,
图片格式【至少】支持:png、jpg、gif、bmp、tiff、ico、svg
文档格式【至少】支持:pdf、ps/eps
  完全的输出格式说明参见官网这个页面

◇关于扩展名的说明


  DOT 的描述文件有好几种扩展名,用得比较多的就是 .dot
  但是这个扩展名与微软的 Word 模板的扩展名冲突了。所以俺在本文的示例,用的都是 .gv 这个扩展名。

★DOT 语言入门


◇概述


  前面提到,你需要通过 DOT 语言来描述一个关系图,然后 Graphviz 根据这个 DOT 语言的描述来自动生成图形。
  很多读者一听到“语言”就先望而生畏,其实这个 DOT 并不复杂。从原则上讲,它只描述三种东西,分别是:点(node)、线(edge)、图形(graph)。你可以通过 DOT 语言定义这三种东西的属性(比如:颜色、形状)。

◇两种图:有向图(digraph) VS 无向图(graph)


  DOT 语言支持两种图形,分别是“有向图 和 无向图”。通俗地说,“有向图”里面的连线是有箭头(比如前面给出的那张“太子党关系图”);反之,“无向图”里面的连线是没有箭头的,比如前面那张“48州的比邻关系图”。

  定义一个无向图很简单,先看下面这段代码。
graph simple
{
    a -- b -- c;
    b -- d;
}
// 这是个无向图

  上述代码的效果图如下:
不见图 请翻墙

  要定义一个有向图,也很简单,代码如下:
digraph simple
{
    a -> b -> c;
    b -> d;
}
/* 这是个有向图 */

  上述代码的效果图如下:
不见图 请翻墙

  这2段代码中,graph 用来表示一个无向图;digraph 用来表示一个有向图。
  示例中的 simple 表示图的名称。图的名称可以是【英文字母、下划线、数字、中文】。最好【不要包含】其它英文的标点符号(也就是【半角符号】),可能会导致一些语法错误。但是中文标点符号(也就【全角符号】)没有关系。
  花括号/大括号 里面的语句表示【图的定义】——这张图包含哪些内容。每一条语句以【分号】结尾(类似于 C、C++、Java 的语法)。
  顺便提一下 DOT 语言的注释(其注释的语法与 C、C++、Java 类似),包括如下两种:
【单行注释】——以 // 表示:【该行】后续的内容为注释
【多行注释】——以 /**/ 包含起来的内容为注释

◇节点(node)


  通过上面两个例子,你应该已经获得了感性的认识。OK,下面来讨论“节点”(node)的概念。
  在上面两个例子中, a b c d 都是【节点名】,分别代表节点。在图的定义中,相同名称就代表同一个节点。当 DOT 编译器碰到一个新的名称,就认为这是一个新的节点。
  节点的命名规范类似于图的命名规范,此次不再罗嗦。如果某个节点没有设置 label 属性(关于【属性】,下面会聊到),那么图形中就用节点名作为该节点的标题——就好比前面两幅简单的示意图。

◇节点(node)的属性


  在节点名之后可以使用 方括号/中括号 来定义该节点的属性,属性之间用半角逗号分隔。
  属性的定义采用如下形式:
属性名 半角等于号 属性值
(如果属性值会包含空格,需用引号把属性值引用起来)

  常用的【属性名】包括如下:
label——标题
color——颜色
style——样式
shape——形状
(还有更多属性,可以参见官网“这个链接”)

  给一个示例代码及效果图,你一看就明白了:
digraph node_attr
{
    shape1 [shape=box, label="编程随想注:\n矩形节点"];
    shape2 [shape=circle, label="编程随想注:\n圆形节点"];
    shape3 [shape=ellipse, label="编程随想注:\n椭圆形节点"];
    shape4 [shape=polygon, sides=4, skew=0.4, label="编程随想注:\n平行四边形节点"];
    shape5 [shape=none, label="编程随想注:\n无边框节点"];
    shape1 -> shape2 -> shape3 -> shape4 -> shape5

    color1 [color="blue", label="编程随想注:\n蓝色边框"]
    color2 [color="green", style=filled, label="编程随想注:\n绿色填充"]
    color3 [color="#ff0000", style=filled, fillcolor="yellow", label="编程随想注:\n红色边框+黄色填充"]
    color4 [color="#0000FF" style=filled, fillcolor="green:red", label="编程随想注:\n蓝色边框+从绿色到红色渐变填充"]
    /* 上面两个节点采用 HTML 的颜色语法,dot 支持 这种语法 */
    color1 -> color2 -> color3 -> color4

    text1 [shape=box, fontsize=12, label="编程随想注:\n小字体"]
    text2 [shape=box, fontsize=24, label="编程随想注:\n大字体"]
    text3 [shape=box, fontcolor="blue", label="编程随想注:\n蓝色文字"]
    text4 [shape=box, label=<编程随想注:<br/><b>粗体</b> <i>斜体</i> <u>下划线</u>>]
    // 注意:text4 使用 HTML 风格的 label,无需引号,但必须用尖括号
    text1 -> text2 -> text3 -> text4
}
不见图 请翻墙

  补充说明:
  在上述示例,俺刻意用到了 HTML 的颜色语法。关于这种语法的说明可以参见维基百科的这个链接

◇连线(edge)


  聊完【节点/node】,再来聊【连线/edge】。
  如前面所示,无向图的连线用 -- 表示,有向图的连线用 -> 表示,非常形象。定义连线的语句也是以分号结尾。
  连线与节点的关键差异之处在于——节点有名称而【连线没有名称】。

◇连线(edge)的属性


  连线也可以设置属性,其属性写在定义连线的语句末尾,语法类似节点属性。
  常用的【属性名】包括如下:
label——标题
color——颜色
style——线条的样式
dir——连线的方向(仅用于有向图,可设置:正向箭头、反向箭头、双向箭头)
arrowhead——前端的样式
arrowtail——末端的样式
(还有更多属性,可以参见官网“这个链接”)

  下面给几个示例,你自己去揣摩(以【有向图】作示范)
digraph edge_attr
{
    style0[label="编程随想注:\n以下是样式的示例"];
    style1[label=""] style2[label=""] style3[label=""] style4[label=""];
    
    style0 -> style1 [style=solid, label="实线"];
    style1 -> style2 [style=bold, label="粗线"];
    style2 -> style3 [style=dashed, label="短划线"];
    style3 -> style4 [style=dotted, label="虚线"];

    arrow0[label="编程随想注:\n以下是箭头的示例"];
    arrow1[label=""] arrow2[label=""] arrow3[label=""] arrow4[label=""] arrow5[label=""] arrow6[label=""];
    arrow0 -> arrow1 [dir=both, label="双向箭头"];
    arrow1 -> arrow2 [arrowsize=2.0, label="大箭头"];
    arrow2 -> arrow3 [arrowhead="open", label="带倒钩的箭头"];
    arrow3 -> arrow4 [arrowhead="halfopen", label="单边倒钩"];
    arrow4 -> arrow5 [arrowhead="ediamond", label="菱形箭头"];
    arrow5 -> arrow6 [arrowhead="dot", label="圆形箭头"];

    color0[label="编程随想注:\n以下是颜色的示例"];
    color1[label=""] color2[label=""] color3[label=""];
    color0 -> color1 [color="blue", label="蓝色"];
    color1 -> color2 [color="red:blue", label="双色"];
    color2 -> color3 [color="green:red;0.4:blue", label="颜色分段"];
}
不见图 请翻墙

◇图的属性


  说完了“节点”和“连线”,最后稍微聊一下“图”本身的属性。
  常用的【属性名】包括如下:
label——标题
bgcolor——颜色
fontname——字体名称(【不】影响节点和连线)
fontsize——字体大小(【不】影响节点和连线)
fontcolor——字体颜色(【不】影响节点和连线)
center——是否居中绘制
(还有更多属性,可以参见官网“这个链接”)

digraph graph_attr
{
    graph[bgcolor="cadetblue" label="图的标题" fontsize=24 fontcolor="green"];

    node0 -> node1;
    node0 -> node2;
}
不见图 请翻墙

◇进阶


  前面俺讲的都是 DOT 最基本的概念和使用。DOT 语言还有一些更高级的用法,感兴趣的同学可以参考下一个章节(★相关资源)给出的“dotguide.pdf”。


★相关资源


◇官网的资源


以下是官网上的若干在线文档:
http://www.graphviz.org/doc/Dot.ref
http://www.graphviz.org/doc/info/attrs.html
http://www.graphviz.org/doc/info/shapes.html
http://www.graphviz.org/doc/info/arrows.html
http://www.graphviz.org/doc/info/colors.html

官方提供的 DOT 语言完整的指南(pdf)

Graphviz 官方的 GitHub 帐号

◇编辑器


  自带的编辑器

Graphviz 软件包中自带了 gvedit 和 vimdot。

  Emacs 的 mode

https://github.com/ppareit/graphviz-dot-mode
俺平时用这个 mode 来编辑 dot 数据文件。它可以实现“所见即所得”——每次修改完,直接在 Emacs 另一个窗口预览图片。
其作者提供的效果图如下:
不见图 请翻墙

  VI/VIM 的插件

https://github.com/wannesm/wmgraphviz.vim

◇编程语言的整合


  JavaScript

https://github.com/mdaines/viz.js

https://github.com/gyuque/livizjs

  Python

https://pypi.python.org/pypi/graphviz

  Ruby

https://github.com/glejeune/Ruby-Graphviz

  Java

http://jgraphviz.sourceforge.net/

2016年10月28日星期五

使用Graphviz绘制流程图和关系图

Graphviz概述

Graphviz是一个由AT&T实验室启动的使用DOT语言来绘制关系图/流程图的开源工具包。
DOT语言是一种文本图形描述语言,它提供了一种简单的描述图形的方法。
使用Graphviz,我们只需要将精力集中在逻辑设计上,而不需要花费大量时间在图形布局的调整上,图形绘制布局都由工具引擎来搞定。也因此,需要精确定位的图形就不适合用Graphviz来绘制了。另外,文本代码绘制图形的方式也便于版本管理。
另外,plantuml也包含了dot语法,并且还具有更多的功能,或许你可以尝试一下。

Graphviz工具

工具善其事,必先利其器。原谅我是一个工具痴 :-)
要想使用graphviz,首先需要上官网下载graphviz并安装。安装之后就可以使用graphviz自带的编辑器gvedit来编写dot代码来绘制图形了。快捷键F5来预览生成的图片,Shift+F5打开对话框并点击ok就可以生成指定类型的图片文件。
但是graphviz自带的gvedit编辑器那是非常非常的难用。怎么办呢?经过四处寻找和妥协,最终找到了windows平台下的还挺好用的工具,此工具不仅具有dot代码高亮、代码提示,还阔以预览生成的图片,只是暂时还不能导出图片。该工具就是github出品的代码编辑器Atom,另外需要安装两个插件:language-dotgraphviz-preview
使用Atom来编写和预览图片,最后使用gvedit来导出图片。看起来还不错的样子。
  • windows中安装好graphviz之后,最好配置一下PATH环境变量。
  • Atom的language-dot插件中的代码提示模板(snippet)可能不能满足你的需求,不过你可以自己添加和修改。这里有我自己修改的代码模板。

中文乱码解决

若渲染出的图片中出现乱码,检查两项:
  1. 文件编码需要使用utf-8。
  2. windows平台下需要在dot源码中指定字体名称。具体如下:
    // 影响图片级别的字体
    graph [fontname="宋体"];
    // 影响节点中的文字字体
    node [fontname="宋体"];
    // 影响箭头或线条上的文字字体
    edge [fontname="宋体"];

DOT基本语法

DOT语法相对简单和松散,没有特别的格式要求,也没有复杂的运算符和结构。你可以查看官方文档以了解更多,其实安装完graphviz后,其安装目录中就有文档了,位置如下:
GRAPHVIZ_HOME/share/graphviz/doc/html/index.html

概述

  • DOT中使用图(digraph/graph)、节点(node)和边(edge)来描述关系图/流程图。
  • DOT的注释风格和C类似(//用于单行注释,/* */用于多行注释)。

DOT可以描述有向图(使用digraph声明)和无向图(使用graph声明)两种图。图由{}中包含的节点和边构成。
在图的开头使用graph []对图进行设置,如:graph [bgcolor="gray"]将图背景色设置为灰色。属性设置语句也可以不包含在graph []中而直接使用。
子图(使用subgraph声明)可以进行和“父图”类似的设置,唯一注意的是子图必须以cluster做为名称的前缀。

节点

DOT中,节点可以不用声明直接使用,但如果需要设置节点的属性,则需声明节点并在声明处设置属性然后再使用。每个节点首次出现的名称做为该节点的唯一标识。
node []用于设置节点默认属性(对设置位置之后的点有效),在节点后面用[]设置单独一个点的属性。

DOT中有有向边(使用->表示)和无向边(使用--表示)两种,有向边用于有向图,无向边用于无向图,不可混用。
和节点类似的,用edge []设置边默认属性,在边之后用[]设置单独一条边的属性。对于有向边,还可以设置边的起点/终点的位置(用n、e、s、w或它们的组合表示位置)。

常用属性

对于各种结构的通用属性如下:
属性名称 默认值 含义
color black 颜色,颜色设置支持形如red#FF0000两种形式
fontcolor black 文字颜色
fontname Times-Roman 字体
fontsize 14 文字大小
label
显示的标签,支持’\n’换行,对于节点默认为节点名称
penwidth 1.0 线条宽度
style
样式
常用属性如下:
属性名称 默认值 含义
bgcolor
背景颜色
concentrate false 让多条边有公共部分
nodesep .25 节点之间的间隔(英寸)
peripheries 1 边界数
rank
same,min,source, max,sink,设置多个节点顺序
rankdir TB 排序方向
ranksep .75 间隔
size
图的大小(英寸)
labelloc
调整图或子图的标签的上下位置
labeljust
调整图或子图的标签的左右位置
compound false If true, allow edges between clusters. 配合lheadltail使用
常用节点属性如下:
属性名称 默认值 含义
shape ellipse 形状
sides 4 当shape=polygon时的边数
fillcolor lightgrey/black 填充颜色
fixedsize false 标签是否影响节点的大小
常用属性如下:
属性名称 默认值 含义
arrowhead normal 箭头头部形状
arrowsize 1.0 箭头大小
arrowtail normal 箭头尾部形状
constraint true 是否根据边来影响节点的排序
decorate
设置之后会用一条线来连接edge和label
dir forward 设置方向:forward,back,both,none
headclip true 是否到边界为止
tailclip true 与headclip类似
headlabel
边的头部显示的标签
taillabel
边的尾部显示的标签
lhead
compound为true时,lhead用于指定边指向的cluster
ltail
与ltail类似

简单示例

dot代码:
digraph simple_demo {
    // 设置图、节点和边的默认属性
    graph [label="simple demo", bgcolor="#EEEEEE"];
    node [style="filled", fillcolor="#AAAAAA"];
    edge [style="dashed", arrowsize=0.6];
    // 节点和边
    {a, b} -> {c, d};
}
图片效果:
simple_demo

高级用法

绘制二叉树

绘制二叉树使用到了记录形式的节点,代码如下:
digraph g {
    node [shape="record", height=.1];
    node0[label="<f0> |<f1> G|<f2>"];
    node1[label="<f0> |<f1> E|<f2>"];
    node2[label="<f0> |<f1> B|<f2>"];
    node0:f0 -> node1:f1;
    node0:f2 -> node2:f1;
}
其中,用|隔开的串会在绘制出来的节点中展现为一条分隔符,用<>括起来的串称为锚点。
效果如下:
binary_tree

竖排记录

记录形式的节点也可以是竖形排列的。与横向排列的记录的不同只是label的形式不同,label中内容使用{}包围则是竖形排列的。代码如下:
digraph g {
    node [shape="record"];
    a [label="{a | b | c}"];
}
效果如下:
col_record

自定义复杂节点

label还支持HTML格式的,这样你能想得到的大部分样子的节点都可以被自定义出来。代码如下:
digraph html {
    abc [shape=none, margin=0, label=<
    <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
        <TR><TD ROWSPAN="3"><FONT COLOR="red">hello</FONT><BR/>world</TD>
            <TD COLSPAN="3">b</TD>
            <TD ROWSPAN="3" BGCOLOR="lightgrey">g</TD>
            <TD ROWSPAN="3">h</TD>
        </TR>
        <TR><TD>c</TD>
            <TD PORT="here">d</TD>
            <TD>e</TD>
        </TR>
        <TR><TD COLSPAN="3">f</TD></TR>
    </TABLE>>];
}
效果如下:
custom_node

直接指向cluster

边直接指向cluster,需要设置compound为true,并配合lheadltail来实现。代码如下:
digraph G {
    compound=true;
    subgraph cluster0 {
        a;
    }
    subgraph cluster1 {
        b;
    }
    a -> b [lhead=cluster1];
}
效果如下:
point_to_cluster

简单的时序图

简单的时序图代码如下:
digraph g {
    rankdir="LR";
    {
        rank="same";
        a0 -> a1 -> a2;
    }
    {
        rank="same";
        b0 -> b1 -> b2;
    }
    a1 -> b1;
}
其中,rankdir="LR"表示,布局从左L到右R,每一个rank="same"的block中的所有节点都会在同一条线(横线或竖线)上。
效果如下:
sequence

以图片为节点

节点还可以使用图片,通过在节点中使用image="image_path"来设置图片。不过需要注意的是,在使用图片作为节点的时候,需要将本来的形状设置为none,并且将label置为空字符串,避免出现文字对图片的干扰。

Graphviz编程库

2016年10月27日星期四



ace-jump-mode高效移动光标


ace-jump-mode 应该是目前为止 emacs 屏幕可见区域键盘操作移动光标(cursor)最快的方式, 没有之一 :)
刚用 emacs 的时候大都会接触 C-f/C-b/C-n/C-p 等标准的光标移动法, 实际上那些都是很低效的. 很多人可能习惯了 C-s isearch-foreard 这样的, 也还可以, 但是通常都比较低效.
"ace jump的功能,是快速的定位光标到可以见的单词或者字母上", 这个是作者 winterTTr 同学在水木社区发布 ace-jump-mode 2.0 测试版时的原话. 更准确的说 ace-jump-mode 提供的定位能力不局限于单词字母, 也可以到其他字符.
ace-jump-mode 有几种操作模式:
  • ace-jump-word-mode 按照英文语法的单词首字母(特殊字符实际也可以算单词)进行定位
  • ace-jump-char-mode 个人比较常用, 输入一个字符, 屏幕上显示出现该字符的位置, 并自动给每个位置分配一个按键, 按对应的键以后跳转到对应位置.
  • ace-jump-line-mode 快速定位到行. 实际上个人想象的一种扩展方式是定位到行以后, 自动按照列再定位一次, 这样就更通用而同样高效, 几乎可以定位到屏幕任意位置: 也解决非键盘直接输入字符, 包括中文的定位问题了.
ace-jump-mode 大部分情况下比 C-s isearch-forward 等来得高效. 当然他们功能并不完全重叠, isearch-forward 用来搜索屏幕不可见区域之外等地方还是更适用的.
有多个相关 mode 基于此拓展了:
  • ace-isearch 简单的理解, 默认安装配置好以后, C-s 搜1个字符调用 ace-jump, 2到5个单词用 isearch, 6个以及以上用 helm-swoop-from-isearch , 有些小毛病就是折叠的代码可能会被意外的展开
  • ace-jump-buffer 在当前打开的 buffer 之间以类似 ace-jump 的模式快速切换
  • ace-jump-zap zap-to-char 来删除到某个字符比较考眼力, 不是很近的容易出错, 有 ace-jump-zap 来选择就方便多了
  • ace-link 使用范围相对比较小众, 在有链接的一些 mode 比如 org-mode, info-mode eww 等中以 ace-jump 模式切换
  • ace-window 则是在 emacs 的窗口(frame/window) 之间切换, 因为只有俩窗口的时候直接跟系统的 C-x o other-window 一样, 所以可以考虑直接把该键定义为 ace-window
具体在 github 上都可以找到, 也可以直接在 emacs 的包管理中直接安装, 不一一列举.


使用 el-get 就可以安装 Ace-Jump-Mode,然后添加以下配置文件:
(autoload
  'ace-jump-mode
  "ace-jump-mode" t)
(eval-after-load "ace-jump-mode"
  '(ace-jump-mode-enable-mark-sync))

(define-key global-map (kbd "C-c SPC") 'ace-jump-mode)
(define-key global-map (kbd "C-x SPC") 'ace-jump-mode-pop-mark)
Ace-Jump-Mode 提供三种跳跃方式:
  • "C-c SPC” ==> ace-jump-word-mode
    enter first character of a word, select the highlighted key to move to it.
  • "C-u C-c SPC” ==> ace-jump-char-mode
    enter a character for query, select the highlighted key to move to it.
  • "C-u C-u C-c SPC” ==> ace-jump-line-mode
    each non-empty line will be marked, select the highlighted key to move to it.
具体使用就是,输入以上三种中任意之一的快捷键,MiniBuffer 就会提示你输入一个字母,比如你想跳到 World 这个单词,就输入 W。之后 Ace-Jump-Mode 会将文件中所有 W 打头的单词显示为一个单个字母,然后你在按这个字母就会跳到那个单词的开头了。语言比较难解释,所以最好还是看作者制作的说明动画,一看就能明白了。
估计大家都知道 Emacs 能分割出很多个窗口,这样能在某些方面可以极大的提高效率。如果我分出两个窗口,可以使用 C-x o 来从两个窗口中快捷的切换,但是如果我分割的窗口多于三个,在用 C-x o 来切换就很蛋疼了。如果你跟我一样经常使用三个以上的窗口分割,那么你也需要 Switch-Windows 这个扩展包。它唯一的功能就是:当你的分割窗口大于等于三的时候,在你按下 C-x o 时,会自动的在所有的分割窗口上显示一个数字,然后你在按下这个数字键就会快速的跳跃到这个窗口了。
这个扩展包比较简单,用 el-get 安装的话,默认什么配置都不需要就可以使用了。

Helm 工具包(gif 动画演示)


     helm 是个好东西, 也是一种不错交互体验, 形成了一系列的工具, 没接触过的  Emacs 爱好者至少通过本文众多的 gif 演示动画可以感受感受.  
本文所有 gif 图片来自 http://tuhdo.github.io/helm-intro.html
我的设置 init-helm.el
(require-package 'helm)
(require 'helm)
(require 'helm-config)
;(require 'helm-dash)

(helm-mode 1)
(helm-autoresize-mode 1)
;(setq helm-ff-auto-update-initial-value nil)    ; 禁止自动补全

(global-set-key (kbd "M-x") 'helm-M-x)
(global-set-key (kbd "M-y") 'helm-show-kill-ring)
(global-set-key (kbd "C-c h") 'helm-command-prefix)
(global-set-key (kbd "C-x b") 'helm-mini)
(global-set-key (kbd "C-x C-f") 'helm-find-files)
(global-set-key (kbd "C-s") 'helm-occur)
(global-set-key (kbd "C-h SPC") 'helm-all-mark-rings)

(setq helm-split-window-in-side-p           t
      helm-move-to-line-cycle-in-source     t
      helm-ff-search-library-in-sexp        t
      helm-M-x-fuzzy-match                  t   ; 模糊搜索
      helm-buffers-fuzzy-matching           t
      helm-locate-fuzzy-match               t
      helm-recentf-fuzzy-match              t
      helm-scroll-amount                    8
      helm-ff-file-name-history-use-recentf t)

(provide 'init-helm)

1 基本使用

C-h f           相当于 describle-function ,列出所有函数
C-h v           相当于 describle-variable ,列出所有变量
C-h w           相当于 where-is ,列出所有键绑定
.....

在 minibuffer 下
C-s             相当于 grep,可模糊/正则搜索,helm-ff-run-grep
C-n/C-p         移动光标
C-v/M-v         快速移动
C-k             回到根目录,清空原先的内容
C-l             返回上一级
C-c C-i         将选中的文件绝对插入缓冲区
C-t             Helm.org
C-x @           用 root 打开文件
C-c h           切换到文件打开历史列表
M-p             切换到其他目录
M-a             选择所有,可与 C-c C-i 配合使用
                本来还有 C-SPC 标记一个,但与中文输入法冲突……
M-D             删除选中的文件
M-R             重命名选定文件
M-C             复制选定文件
M-S             选定文件建立软连接
M-H             选定文件建立硬链接
简单演示: helm_projectile.gif
1.首先键入 main.c ,出现众多候选。我只想要在 x86 目录下的 main.c ,所以再次键入 x86 。完整的过程即键入 main.c x86 , Helm 自动搜索到正确的候选 arch/x86/boot/main.c
2.模糊搜索。比如路径是 driver/edac/i5100_edac.c 的文件,键入 dedi51d表示 drivered表示 edaci51表示 i5100_edac.c

2 命令 Command

2.1 helm-M-x

(global-set-key (kbd "M-x") 'helm-M-x)
(setq helm-M-x-fuzzy-match t)
helm-M-x 代替 M-x 命令,多出一个候选列表,且可以进行模糊搜索
演示:
helm-m-x.gif

2.2 helm-show-kill-ring

(global-set-key (kbd "M-y") 'helm-show-kill-ring)
helm-show-kill-ring 代替默认的 M-y ,可以在 emacs 剪切和复制的内容列表中选择/搜索
演示:
helm-kill-ring.gif

2.3 helm-mini

(global-set-key (kbd "C-x b") 'helm-mini)
(setq helm-buffers-fuzzy-matching t
      helm-recentf-fuzzy-match    t)
helm-mini 代替默认的 C-x b ,显示缓冲区列表,可搜索,完全可以代替默认的缓冲区列表命令,即 C-x b/C-x C-b
演示:
helm-mini.gif

2.4 helm-ff-do-grep

也可以用 ack-grep 代替 grep
(when (executable-find "ack-grep")
  (setq helm-grep-default-command "ack-grep -Hn --no-group --no-color %e %p %f"
        helm-grep-default-recurse-command "ack-grep -H --no-group --no-color %e %p %f"))
在 helm-find-files 的 minibuffer 中,键入 C-s 即可进入
演示:
helm-ff-do-grep.gif

2.5 helm-semantic-or-imenu

(setq helm-semantic-fuzzy-match t
      helm-imenu-fuzzy-match    t)
键入 C-c h i 进入,列出当前文件章节/节点列表,选择后跳转到指定章节/节点
演示:
helm-semantic-or-imenu.gif

2.6 helm-man-woman

(add-to-list 'helm-sources-using-default-as-input 'helm-source-man-pages)
快速调整到指定 man 文档,需自己手工设置快捷键
演示:
helm-man-woman.gif

2.7 helm-find

C-c h / 默认情况下只搜索当前目录, C-u C-c h / 可指定要搜索的目录。
helm-find-files (即 C-x C-f )窗口中键入 C-c / 同样可以调用该命令。
演示:
helm-find.gif

2.8 helm-locate

(setq helm-locate-fuzzy-match t)        ; 仅供 Linux 平台下设置
C-c h l 启动, C-! 暂停/继续进行实时搜索,大硬盘搜索迟缓时可用。
类似 helm-find ,但进行全局搜索。Mac OS 下 需要用到 mdfind ,Windows 下需要安装 Everthing search engine 并添加 es.exe 环境变量。
演示:
helm-locate.gif

2.9 helm-occur

(global-set-key (kbd "C-s") 'helm-occur)
文件全文搜索,个人感觉完全可以代替 Emacs 默认搜索命令,按 TAB 显示扩展命令。
演示:
helm-occur.gif

2.10 helm-apropos

(setq helm-apropos-fuzzy-match t)
显示 Emacs 指定命令简述(包括可用函数、变量、属性、功能等等),可模糊/正则搜索
截图:
helm-apropos.png

2.11 helm-info-*

helm emacs info 帮助系统,提供搜索/补全功能,键入 M-x helm-info 可以看到所有可选择的列表
截图:
helm-info.png

2.12 helm-lisp-completion-at-point

(setq helm-lisp-fuzzy-completion t)
提供 lisp 命令补全/候选,使用该命令之前必须先键入几个 lisp 关键词,哪怕是一个括号
截图:
helm-lisp-completion-at-point.png

2.13 helm-resume

用于回复以前的缓冲区,且恢复那个缓冲区已有的输入,哪怕你没有保存
键入 C-c h b 启动

2.14 helm-all-mark-rings

(global-set-key (kbd "C-h SPC") 'helm-all-mark-rings)
在窗口处列出当前文件和全局 mark-rings ,可以使用 C-n/C-p 上下移动,也可以直接输入标记编号,回车跳转到指定行
截图:
helm-all-mark-rings.png

2.15 helm-regexp

实时显示某个正则表达式效果,测试时可用
F1 保存正则表达式作为一个 kill-ring
F2 替换当前正则表达式
F3 保存正则表达式作为当前提示
演示:
helm-regexp.gif

2.16 helm-register

(global-set-key (kbd "C-c h x") 'helm-register)
查看并列出所有 Emacs 寄存器(emacs register)
演示:
helm-registers.gif

2.17 helm-eval-expression-with-eldoc

在该命令下输入的 Emacs Lisp 表达式其结果可以马上在缓冲区中表现出来。如果你有一个命令希望马上看到效果,该命令会有很大帮助
演示:
helm-eval-expression.gif

2.18 helm-top

类似 Linux top 命令
Key| 用途  
---|---  
C-c C-u| 刷新  
M-C| 按照 Shell command 排序  
M-P| 按照 CPU 使用率排序  
M-U| 按照用户名称排序  
M-M| 按照内存占用排序  
演示:helm-top.gif

2.19 helm-surfraw

一个快速搜索命令,包含多个搜索引擎,会跳转到浏览器
演示:
helm-surfraw.gif

2.20 helm-google-suggest

(global-set-key (kbd "C-c h g") 'helm-google-suggest)
交互式输入检索词,并得到 helm 来自 google 的结果,当然可以用于其他服务,诸如:Google Maps、Google News、Youtube、Wikipedia 等等
演示:
helm-google-suggest.gif

2.21 helm-color

用于查看/复制颜色的十六进制值
Key| 用途  
---|---  
[f1] or C-c N| 复制名称  
[f2] or C-c R| 复制 RGB  
[f3] or C-c n| 插入名称  
[f4] or C-c r| 插入 RGB  
演示:
helm-color.gif

2.22 helm-calcul-expression

一个相当于计算器(calc)命令,可以使用符号诸如:+、-、*、/、sin、cos、tan、sqrt 等等
演示:
helm-calc.gif

2.23 helm-eshell-history

(require 'helm-eshell)

(add-hook 'eshell-mode-hook
          #'(lambda ()
              (define-key eshell-mode-map (kbd "C-c C-l")  'helm-eshell-history)))
查看 eshell 命令历史
演示:
helm-eshell-history.gif
原文出处: mudan
原文地址: http://mudan.github.io/Emacs/Helm/Helm.html
原文时间: 2015-06-16 00:56
本文地址: http://emacsist.com/10295
整理时间: 2015-06-17 01:32

本文由 Hick 整理,转载请保留以上信息;
COPYLEFTThe articles on this site come from Internet, thanks to all the original authors.
      If anything about COPYRIGHT, or LEFT, please contact Emacsist at gmail dot com .

A Package in a league of its own: Helm

Table of Contents

Author:
  • Tamas Patrovic (original author), from 2007. At this time, Helm was named Anything.
  • rubikitch rubikitch@ruby-lang.org, from 2008-2011. Helm was still named Anything
  • Thierry Volpiatto (current maintainer). thierry.volpiatto@gmail.com, from 2011-present. Anything was renamed to Helm during this period.
Homepage: GitHub
Features:
Helm is an incremental completion and selection narrowing framework for Emacs. It will help steer you in the right direction when you're looking for stuff in Emacs (like buffers, files, etc).
Helm is a fork of anything.el (originally written by Tamas Patrovic) and can be considered to be its successor. Helm sets out to clean up the legacy code in anything.el and provide a cleaner, leaner and more modular tool, that's not tied in the trap of backward compatibility.
Installation:
You can use Emacs Prelude or Spacemacs, which are already setup properly. You can skip all configuration code in this guide. But note that by default, Emacs Prelude does not enable Helm. Please follow these instructions to enable Helm. Spacemacs enables Helm by default.
If you are a Spacemacs user, you don't have to do anything. If you have your own Emacs configuration, run M-x list-packages and select the helm package, then install it. After finish installing, add this configuration to activate the package:
Minimal config:
(require 'helm-config)
(helm-mode 1)
Extended config:
(require 'helm)
(require 'helm-config)

;; The default "C-x c" is quite close to "C-x C-c", which quits Emacs.
;; Changed to "C-c h". Note: We must set "C-c h" globally, because we
;; cannot change `helm-command-prefix-key' once `helm-config' is loaded.
(global-set-key (kbd "C-c h") 'helm-command-prefix)
(global-unset-key (kbd "C-x c"))

(define-key helm-map (kbd "<tab>") 'helm-execute-persistent-action) ; rebind tab to run persistent action
(define-key helm-map (kbd "C-i") 'helm-execute-persistent-action) ; make TAB work in terminal
(define-key helm-map (kbd "C-z")  'helm-select-action) ; list actions using C-z

(when (executable-find "curl")
  (setq helm-google-suggest-use-curl-p t))

(setq helm-split-window-in-side-p           t ; open helm buffer inside current window, not occupy whole other window
      helm-move-to-line-cycle-in-source     t ; move to end or beginning of source when reaching top or bottom of source.
      helm-ff-search-library-in-sexp        t ; search for library in `require' and `declare-function' sexp.
      helm-scroll-amount                    8 ; scroll 8 lines other window using M-<next>/M-<prior>
      helm-ff-file-name-history-use-recentf t
      helm-echo-input-in-header-line t)

(defun spacemacs//helm-hide-minibuffer-maybe ()
  "Hide minibuffer in Helm session if we use the header line as input field."
  (when (with-helm-buffer helm-echo-input-in-header-line)
    (let ((ov (make-overlay (point-min) (point-max) nil nil t)))
      (overlay-put ov 'window (selected-window))
      (overlay-put ov 'face
                   (let ((bg-color (face-background 'default nil)))
                     `(:background ,bg-color :foreground ,bg-color)))
      (setq-local cursor-type nil))))


(add-hook 'helm-minibuffer-set-up-hook
          'spacemacs//helm-hide-minibuffer-maybe)

(setq helm-autoresize-max-height 0)
(setq helm-autoresize-min-height 20)
(helm-autoresize-mode 1)

(helm-mode 1)

Usage:

After using Helm, you are going to have a big change in the way you use Emacs. After you get used to the Helm way, you won't want to leave it. However, if you don't like Helm, you can still use Ido, which is introduced in a later section. Let's learn how to use helm by playing with it.
Completion with Helm is very different from the usual Emacs completion:
  • You type something.
  • Instead of TAB to expand the common part until you find your candidates, in Helm, you type parts of the candidate you want to search for, separated by spaces. In Helm, these strings are called patterns. Patterns can also be regexps.
  • Helm will try to search and sort according to highest match, from top to bottom. The best match is at the top, so you can press RET and select it.
  • You can navigate the buffer with C-n and C-p or <up> and <down> to move up/down, C-v and M-v to move to next/previous pages, and M-< and M-> to move to the top and bottom of the Helm buffer.
  • You can mark candidates with C-SPC; this is useful when you need to perform an action on many candidates of your choice. M-a to select all.
  • You can insert marked candidates into the current buffer with C-c C-i. This is useful when you have narrowed to a list of candidates, i.e. files, and then you want to save such candidates.
  • If you find the current horizontal Helm window is small, you can always switch it to a vertical window with C-t. Running C-t again returns the Helm window back to horizontal and so on.
You can practice the above commands with C-x b, which runs helm-mini. If you mark more than one buffer, RET opens the selected buffers.
IMPORTANT: Please remember that, when you use Helm, you never TAB to complete prefixes like vanilla or other packages like Ido and its related packages. In Helm, when you type something, candidates get updated automatically. In vanilla Emacs, you have to TAB to get a list of candidates. This is a great feature from Helm, not a lack of a feature. You have to forget the habit of TAB'ing to get candidates. If you want quick completion of search patterns in the Helm prompt, you always have hippie-expand to replace the TAB behavior, as introduced at the beginning of this section. This is the biggest confusion for new people switching to Helm. When you are used to Helm, you will love it.
When you execute a Helm command, you enter a Helm session. A Helm session is a dedicated state to working with Helm features; while in a Helm session, a dedicated Helm buffer is always opened. When you quit a Helm session, a Helm buffer is closed. In Helm, you basically need to remember these 3 commands:
  • Access the action menu with TAB. An action is a command to run on marked candidates (one or more) and quits the current Helm session; an action menu is a text-based menu that lists actions you can take. For example, Find File (open file), Find File in Dired, Grep File
  • C-z executes helm-execute-persistent-action; a persistent action is an action that you use in a Helm session that does not quit the session.
  • In some Helm sessions, such as helm-find-files or helm-mini, you can select more than one candidates and execute actions on them, such as grep or open.
However, for convenience, let's TAB with C-z in the above settings, so we can use TAB more comfortably, because you actually use helm-execute-persistent-action more than helm-select-action by adding the code snippet below:
(define-key helm-map (kbd "<tab>") 'helm-execute-persistent-action) ; rebind tab to do persistent action
(define-key helm-map (kbd "C-i") 'helm-execute-persistent-action) ; make TAB works in terminal
(define-key helm-map (kbd "C-z")  'helm-select-action) ; list actions using C-z
In a Helm session, if you need help, use C-c ?, or refer to this manual again. The commands in the key bindings above are good enough to help you use Helm productively.

Why is Helm powerful?

  • Simple and Consistent interface: Every Helm session starts with the same, simple interface: a prompt for entering search patterns and a Helm buffer for displying results as the user types. Because of the consistent and simple interface, new people use Helm with ease.
  • Interactivity: By nature, Helm is very interactive: as a user types, results get updated immediately in the Helm buffer. Because of this feature, Helm provides a unique interactive version of many commmands that do not exist outside of Helm. For example, helm-ff-run-grep, which updates grep results as you type.
  • Focus on finding what you want first, decide what to do with it later: With Helm, you don't have to think about what you are going to do with a candidate until you have found it. For example, needing to decide whether you should open a file in the current window or in other window before opening a file. In contrast, Helm helps you focus on what you want to find; once you find your desired object (such as a file or directory), you only then decide what to do with it, such as opening the file in another window or opening the file as root. This has the advantage that you don't have to cancel your executing command if you decide that the action you are taking is not appropriate anymore. For example, if you are executed C-x C-f to open a file, but have a second thought that opening the file in another window is better. Then you press C-g to cancel the command and re-execute the C-x 4 C-f version and have to start your navigating session all over again!
  • Matching mechanism: This is a powerful feature in Helm that I haven't seen in other packages: out of order matching, with regular expression. That's right, you can enter every search pattern as a regexp!. A really powerful concept: it enhances explanatory power for many things. One use cases is exploring a new project: using Helm, you can "learn" the project structure interactively. For example, suppose I'm completely new to the Linux kernel source tree, and I wonder whether a file main.c exists for x86 architecture. I know that they must have x86 directory somewhere, and the file could contain main.c in it, i.e. It can be main.c or x86-main.c. These are the only pieces of information I know, so I tried it in Helm Projectile (a package that makes use of Helm framework, which does not come with stock Helm. You can read more about it in my Helm Projectile guide):
    helm_projectile.gif
    First, I enter main.c, and I got lots of candidates. Then, I only want the main.c inside the x86 directory, so I type x86. The whole pattern is main.c x86 and Helm returns the correct candidate: arch/x86/boot/main.c.
    It does exist. I also wonder where i5100_edac.c exists, because Intel has had a datasheet for it available for a long time, so it must be implemented. As demonstrated in the above screencast, there was only one i5100_eda.c. Using the so-called "fuzzy-matching" mechanism, you are still required to know things in advance and this severely limits the explanatory power. For example, to get to the file driver/edac/i5100_edac.c, you have to know the path to fuzzy match like this: dedi51; d for matching driver, ed for matching edac because other directories also start with "e"; i51 for matching i5100_edac.c because several files also start with "i5", or contain "1" and "0" or "edac" in it. "i51" is the only unique prefix. Using Helm, you can immediately enter the unique pattern of a candidate and ignore the common prefix to get a candidate. For example, in the screencast above, I got driver/edac/i5100_edac.c immediately just by typing "i51" and the file was narrowed down.
    Fuzzy matching can also be less useful when working with a large source tree, where many files share a common prefix.
    Starting from Helm 1.6.5, Helm includes fuzzy matching for many commands and a way for a package writer to activate fuzzy matching.
  • Performance: Helm can work with over 30000 candidates or more with no problems.

Operate on text at point:

If you are already in a Helm session, you can still get input from the current editing buffer by the following key bindings:
  • C-w yanks word at point, starting from point to the end of the word, into the Helm prompt (the minibuffer).
  • M-n yanks symbol at point
If helm-mode is activated, help commands also automatically recognize symbols at point if such symbols exist in Emacs, and use the Helm interface for interactive selection. For example:
  • C-h f, which runs describe-function, automatically takes the symbol at point as the default for searching function.
  • C-h v, which runs describe-variable, automatically takes the symbol at point as the default for searching variable.
  • C-h w, which runs where-is, automatically takes the symbol at point as the default for showing the key binding for a command.
  • … and so on… (C-h C-h to view all commands)
All of those commands automatically make use of Helm.

Autoresize

Helm can resize its buffer automatically to fit the number of candidates if you enable helm-autoresize-mode:
(helm-autoresize-mode t)
You can customize the minimum and maximum height that Helm can resize with these two variable:
  • helm-autoresize-max-height
  • helm-autoresize-min-height
By default, helm-autoresize-max-height is set to 40, meaning the Helm candidate buffer has a maximum height of 40% of the current frame height. Similarly, helm-autoresize-min-height specifies a minimum height for the Helm candidate buffer as a percentage of the current frame height.
If you don't want the Helm window to be resized, you can set helm-autoresize-max-height equal to helm-autoresize-min-height.
If you use golden-ratio, you have to disable its interference with the Helm window (Note: If you are using Spacemacs, you don't have to add this bit of configuration):
(defun pl/helm-alive-p ()
  (if (boundp 'helm-alive-p)
      (symbol-value 'helm-alive-p)))

(add-to-list 'golden-ratio-inhibit-functions 'pl/helm-alive-p)
In DEMO 1, helm-autoresize-max-height is not equal to helm-autoresize-min-height (begins when START DEMO appears in minibuffer):
helm-autoresize-mode.gif
In DEMO 2, helm-autoresize-max-height is equal to helm-autoresize-min-height (begins when START DEMO appears in minibuffer):
helm-autoresize-fix.gif

Command: helm-M-x

Key binding:
No default key binding. We should give it one:
(global-set-key (kbd "M-x") 'helm-M-x)
Description:
M-x and see the difference. You will see a buffer that lists commands in Emacs. Some of you may not like it because it seems overkill at first. However, even if you really don't like, please bear with me until the end.
Now, type li pa; that's right li , a space and pa. You will see, list-packages is at the top. Surprise! Let's try another input. Now, type pa ^li, and you will receive list-package as the first entry.
helm-M-x is also better then the default M-x, because it provides key bindings right next to the commands, and TAB provides you the built-in documentation of that command in another buffer.
Starting from 1.6.5, helm-M-x can fuzzy match candidates, but this is not enabled by default. To enable fuzzy matching, add the following setting:
(setq helm-M-x-fuzzy-match t) ;; optional fuzzy matching for helm-M-x
NOTE: You have to bind helm-M-x to M-x manually. Otherwise, you still get Helm completion, but using the vanilla M-x that does not provides the above features like showing key bindings and TAB to open built-in documentation. Another important thing is, you have to pass the prefix argument AFTER you run helm-M-x, because your prefix argument will be displayed in the modeline when in helm-M-x buffer. Passing prefix argument BEFORE helm-M-x has no effect.
Demo:
helm-m-x.gif

Command: helm-show-kill-ring

Key binding:
No default key binding. We should give it one:
(global-set-key (kbd "M-y") 'helm-show-kill-ring)
Description:
Do you remember the binding C-y cycle the kill ring? However, working with default kill ring is painful because you have a burden to remember an invisible thing, that is the kill ring, at which position you kill what. To view the kill ring, you have to C-h v and type kill-ring to see content of the kill ring, and it is not pretty.
helm-show-kill-ring solves this problem: Helm shows the kill ring in a readable format and allows you to narrow down by entering sub-strings of candidates. You are freed from the cognitive burden of the default M-y.
If you follow my Helm configuration, M-y binds to helm-show-kill-ring. Try it and see! Much easier than the default.
Demo:
helm-kill-ring in action (the demo starts when you see START in the minibuffer):
helm-kill-ring.gif

Command: helm-mini

Key binding:
No default key binding. We should give it one:
(global-set-key (kbd "C-x b") 'helm-mini)
To enable fuzzy matching, add the following settings:
(setq helm-buffers-fuzzy-matching t
      helm-recentf-fuzzy-match    t)
helm-mini is comprised of multiple sources:
  • Current open buffers, under the header Buffers.
  • Recently opened files, under the header Recentf.
  • Allows you to create a new buffer by pressing RET, under the header Create Buffer.
You can move back and forth between the groups by using <left> and <right> arrow keys. Or you can just scroll down/up with C-v and M-v.
You can filter out buffers by major mode using the pattern *<major-mode>. For example, *dired narrows to only Dired buffers. You can also filter out buffers that belong to a major mode by adding ! to the pattern. For example, *!dired select all buffers that are not in Dired mode.
You can also select buffers in a specific directory by using the pattern /directory. For example, /.emacs.d/ narrows to buffers that are only inside .emacs.d. Add ! before the pattern for reverse version. For example, !/.emacs.d/ narrows to buffers not in .emacs.d.
You can even use helm-mini to narrow to buffers that contain a regexp in their contents, by prepending @ to the search pattern. For example, you can select buffers that only contain the string "test": @test. If you want to see the locations of the string in the buffers, mark all the buffer with M-a and C-s while in helm-mini session, to switch to helm-moccur. You can mark buffers to search with C-SPC. When you switch to helm-moccur, matches that are in selected buffers are displayed. You can also perform occur only on the current buffer with prefix argument: C-u C-s; this is useful when you already marked buffers but don't want to unmark just to view only in a buffer. However, in general, you won't need C-u C-s.
Meaning of colors and prefixes for buffers:
  • Remote buffers are prefixed with '@'.
  • Red => Buffer has had its file modified on disk by an external process.
  • Indianred2 => Buffer exists but its file has been deleted.
  • Orange => Buffer is modified and its file has not been saved to disk.
  • Italic => A non-file buffer.
Some Emacs themes change the colors. You should check the corresponding color in your color themes.
Example:
  • If I enter the pattern: *lisp ^helm @moc, Helm will narrow down the list by selecting only buffers that are in lisp mode, start by helm and match "moc" in their contents.
  • If I want to specify more than one major-mode, separate them with ,, e.g *!lisp,!sh,!fun will list all buffers but the ones in lisp-mode, sh-mode and fundamental-mode.
  • If I enter the pattern: *lisp ^helm moc. Notice there is no @ this time helm will look for lisp mode buffers starting by "helm" and have "moc" in their name.
  • If I enter the pattern: *!lisp !helm Helm will narrow down to buffers that are not in "lisp" mode and that do not match "helm".
  • If I enter the pattern: /helm/ w3 Helm will narrow down buffers that are in any "helm" sub-directory and matching w3.
    helm-mini is like an interactive version of ibuffer.
Demo:
helm-mini.gif
The demo starts when you see Eval: START in the minibuffer. Note that the demo use helm-buffers-list, which is almost the same as helm-mini. The only difference is that helm-buffers-list uses ido-virtual-buffers for listing recently used files, while helm-mini uses recentf.
  • All the C buffers are selected using the pattern *C. In the demo, I also select Tcl buffers with *Tcl and then switched back to C buffers with *C.
  • I only want to have buffers that contain only the string crash. To do that, I add a space, then add the pattern @crash. After the initial search pattern, I hand the currently highlighted buffer over to helm-moccur (moccur with Helm interface) using C-s. Candidates can be filtered gradually by adding more patterns, e.g., I added memory to filter down to buffers that contain the string "memory" among the buffers that contain crash. You can also mark multiple with C-SPC or mark all buffers with M-a to search all buffers listed in helm-mini.
  • As you can see, as I filtered, the number of candidates decreased, as displayed in the modeline. At the end, there were 12 buffers remained as the result of filtering, down from the total 253 buffers.
The demo above is part of Helm's homepage now.
Similar Commands:
  • helm-multi-files: this command lists buffers and recent files and files in current directory. However, when no match is found, helm-mini asks if you want to create a new buffer by highlighting the only entry, which look like this:
    helm-new-file-buffer.gif
    while helm-multi-files shows a blank buffer. However, you can start a helm-locate session to search the whole file system for the desired file by pressing C-c p. By default, helm-for-files is bound to <prefix> f (current prefix is C-c h).
  • helm-buffer-list: similar to helm-mini, but instead of listing recent files from recentf, it uses ido-virtual-buffers, which is a list of recently visited files managed by ido. The virtual buffers do not contain paths. Depending on your preference, you can use this command in place of helm-mini. To enable fuzzy matching ido-virtual-buffers, if you set helm-buffers-fuzzy-matching to t already, you also get fuzzy matching for ido-virtual-buffers.

Command: helm-find-files

Key binding:
<prefix> C-x C-f or C-x C-f (prefix is C-x c by default, or C-c h if set). This is a rather long key sequence, and *=helm-find-files= deserves a better binding:
(global-set-key (kbd "C-x C-f") 'helm-find-files)
Description:
helm-find-files is file navigation on steroids:
  • helm-find-files can fuzzy match candidates in the current directory. e.g "fob" or "fbr" will complete "foobar".
  • You can also execute a persistent action, which is bound to C-z (by default) or TAB if you use my configuration, to narrow the current highlighting candidate; C-z or TAB again to view the contents of the buffer. You can scroll the other buffer up/down with M-<next> and M-<prior>.
  • Alternatively, you can hit C-j to narrow to the highlighting candidate and C-j again to view the content of the other buffer. C-l goes back.
  • You can also go up one directory level with C-l. NOTE: if you use C-l, Helm goes up one level and places the cursor on the directory you've just exited. If you want to go up and have the cursor on the parent directory, in Helm prompt, enter ../.
  • After you go up with C-l, you can go back to the exact visited directories with C-r.
  • To create a directory, enter a new name that does not exist in the current directory and append / at the end. After you create a directory, Helm continues in that directory.
  • To create a new file, enter a name and select the top row that has the symbol [?] next to it. By default, Helm always selects the first match in the directory.
  • You can invoke grep on the currently highlighted entry with C-s. C-u C-s performs a recursive grep.
  • Enter ~/ at the end of the pattern to quickly reach home directory.
  • Enter / at the end of the pattern to quickly reach root of your file system.
  • Enter ./ at the end of the pattern to quickly reach `default-directory' (initial start of session). If you are in `default-directory' move cursor on top.
You can perform more actions on the highlighted entry by running helm-select-action, which is bound to TAB by default and C-z in my configuration. The guide for each action in the action menu is written in the guide Exploring large projects with Projectile and Helm Projectile. It is written there because you will end up using Projectile (a project manage for Emacs, introduced in later section) to navigate to files much more efficiently, anywhere and anytime you need.
Demo:
I only needed to type into the prompt a few character to get the candidate I wanted among many candidates. The demo starts when you see START in the minibuffer:
helm-find-files.gif
  • Find file at point:
    Did you know the command ffap? It was introduced in part 1, but here is the demo:
    ffap.gif
    helm-find-files can do that too: all you need to do is move your point onto a proper filepath, and Helm will reach the correct path for you, similar to the screenshot. Now, you no longer have to use a separate command to open the file at point, but using the same C-x C-f. It's really convenient.
  • File and directory histories:
    With a prefix argument, helm-find-files displays a list of visited directories. If one is selected at point, helm-find-files starts in that directory and you can navigate from there.
    During a helm-find-files session, you can get a list of visited files and directories with C-c h. From there, the default action is RET to open the file/directory at point, or continue with helm-find-files starting at that file/directory.
    You can use M-p and M-n to move back and forth between previously visited directory.

Command: helm-ff-do-grep, live grep in Helm

Key binding:
From within a helm-find-files session, you can invoke helm-ff-run-grep with C-s to search a file/directory on highlighted entry in the Helm buffer. With prefix argument C-u, recursively greps a selected directory.
You can also save the result into a Grep buffer using the action Save results in Grep buffer. Note that this Grep buffer is created by Helm, not the default Emacs grep buffer. It has minimal key bindings. In *hgrep* buffer, press C-h m to view all key bindings.
Description:
Every time you type a character, helm updates grep result immediately. You can use ack-grep to replace grep with this configuration:
(when (executable-find "ack-grep")
  (setq helm-grep-default-command "ack-grep -Hn --no-group --no-color %e %p %f"
        helm-grep-default-recurse-command "ack-grep -H --no-group --no-color %e %p %f"))
Demo:
live_grep.gif

Command: helm-semantic-or-imenu

Key binding:
<prefix> i (prefix is C-x c by default, or C-c h if set).
Description:
The Imenu facility offers a way to find the major definitions, such as function definitions or variable definitions in a file by name. You can run imenu command individually.
Semantic is a package that provides language-aware editing commands based on 'source-code parsers'. When enabled, each file you visit is automatically parsed. Semantic provides execellent support for C/C++. To enable Semantic mode, execute (semantic-mode 1).
Helm offers an interface to both Semantic and Imenu at the same time: If `semantic-mode' is active in the current buffer, then use semantic for generating tags, otherwise fall back to imenu. If point is on a symbol, helm feeds the symbol into input prompt by default.
helm-semantic-or-imenu works with many modes like C/C++, Java, Python, Ruby, Emacs Lisp and Lisp in general, shell script, Org-mode…
To enable fuzzy matching for both Semantic and Imenu listing, add the following setting:
(setq helm-semantic-fuzzy-match t
      helm-imenu-fuzzy-match    t)
Usage:
  • Invoke the command (by default, C-c h i).
  • You can use the arrow keys or C-p/C-n to move up and down between candidates. You can also use C-<down> and C-<up>; as you move the selection between tags inside the Helm Semantic buffer, the point moves between tag locations as well.
  • A nice feature of helm-semantic-or-imenu is that whenever you activate the command, if point is inside a Semantic tag (such as a function definition), the selection is positioned at the tag in the Helm buffer. This works nicely in combination with C-<down> and C-<up> to move between definitions in your buffer.
Helm gives you finer control: you can move between functions using beginning-of-defun (bound to C-M-a) and end-of-defun (bound to C-M-e), but it will also move the point and scroll your buffer. Using helm-semantic-or-imenu, you have similar behavior and you have more choices: either C-g to return back to the position where you originally invoked helm-semantic-or-imenu because you only needed to look up a function interface (e.g., to see what kinds of parameters a function accepts), or RET to jump to the tag location. Currently, only the Semantic part of helm-semantic-or-imenu is supported. If a buffer only has imenu support from the command, you won't be able to use this feature.
helm-semantic-or-imenu provides these types of Semantic tags:
  • Dependencies: the dependencies of the current file as defined by the current major mode. For example, Dependencies in C/C++ include header files. When you execute a persistent action on a dependency, the point moves to the location of that dependency in the current window.
  • Variables: variables defined in current buffer.
  • Functions: function defined in current buffer
  • Provides: modules that this buffer provides; for example, (provide ...) expression in Emacs Lisp.
If you want to filter by tag type, enter caret character ^ (beginning of line in regex) and follow the first character of that type. For example, to see only function tags, type ^f in the prompt.
Demo 1:
DEMO (begin when START DEMO is in minibuffer):
  • First, I use helm-semantic-or-imenu to move to the function helm-define-key-with-subkeys and move point there.
  • Then, I start helm-semantic-or-imenu again and helm-define-key-with-subkeys is pre-selected.
  • Then, I move point to the variable helm-map and execute helm-semantic-or-imenu again on two function: helm-next-source and helm-previous-source. This time, instead of showing the current semantic tag I'm operating in (which is helm-map), it shows the other two tags in Helm Semantic buffer. This is because I supplied a prefix argument before running the command.
    helm-semantic-or-imenu-2.gif
Demo 2:
Here is helm-semantic-or-imenu in action, please notice the "pattern: " prompt in the minibuffer:
  • At first, I narrow to candidates that are functions with this pattern in the prompt: Functi.
  • Then, I narrow to candidates that are functions and contain void in them with this pattern: functi void, effectively selecting functions that have type void or accept void arguments.
  • Then, I narrow to candidates that are functions and contain int in them with this pattern: functi int, effectively selecting functions that have type int or accept int arguments.
  • Then, I narrow to candidates that are variables and contain u16 in them, effectively selecting only variables that have type u16; the same for u32 in the demo.
    helm-semantic-or-imenu.gif
Press RET to visit the the candidate location. The above examples are just demonstrations. You can narrow to anything you want with search patterns separated by spaces, e.g., you can use two patterns, "func" and a part of a function name, and Helm can narrow to it fine.
In the demo, you see things like class u16 and class u32; that is because u16 and u32 are defined by typedef.

Command: helm-man-woman

Key binding:
<prefix> m (prefix is C-x c by default, or C-c h if set).
Description:
With helm-man-woman, you can quickly jump to any man entry using the Helm interface, either by typing in Helm prompt or if the point is on a symbol, opening the man page at point. To enable man page at point, add the following code:
(add-to-list 'helm-sources-using-default-as-input 'helm-source-man-pages)
Demo:
helm-man-woman.gif

Command: helm-find

Key binding:
<prefix> / (prefix is C-x c by default, or C-c h if set).
Description:
Normally, you use find command with arguments in terminal, then press RET and wait for a big list of result, and if the result is not as expected, repeat the whole thing. You can shorten this process by interactively get results from Unix find for every character you enter into Helm prompt.
You can separate search patterns by spaces. However, since Helm is using Unix find utility, you have to enter search patterns according to the search string of find; use helm-man-woman to read the find man page.
By default, invoking helm-find only searches current directory. With prefix argument C-u (i.e. C-u C-c h /), a prompt asks for a directory to find. helm-find can be invoked within helm-find-files session, by using C-c /. To open more than one file, mark individual candidates with C-SPC or mark all with M-a, then RET. You can switch to helm-find-files with C-x C-f.
If you use helm-find on a large directory and feel live updating is too sluggish, you can always suspend the live updating with C-! and resume the live updating with C-! later.
Demo:
helm-find.gif

Command: helm-locate

Key binding:
<prefix> l (prefix is C-x c by default, or C-c h if set).
Description:
Similar to helm-find, but uses the locate command and accepts search patterns according to locate input. Use helm-man-woman to read locate man page. In Mac OS, mdfind is used instead. On Windows, you need to install Everything search engine; once you installed Everything and expose es.exe to Emacs via the PATH environment variable, helm-locate will use Everything and work out of the box without any configuration.
To use a local database, execute helm-locate with prefix argument C-u.
If you use helm-locate on a large hard drive and feel live updating is too sluggish, you can always suspend the live updating with C-! and resume the live updating with C-! later.
To enable fuzzy matching in helm-locate, add this setting:
(setq helm-locate-fuzzy-match t)
Note that it is currently working with locate command in Linux. If you are on other platform, don't set it or you won't have any result.
Demo:
helm-locate.gif

Command: helm-occur

Key binding:
<prefix> M-s o (prefix is C-x c by default, or C-c h if set). Since this is a rather long binding, we should bind a more convenient key sequence:
(global-set-key (kbd "C-c h o") 'helm-occur)
Description:
Similar to occur, but using Helm interface. As you type, matching lines are updated immediately. This is convenient when you want to have a list of matches in the current buffer to jump back and forth. TAB to temporarily move the point to the location of the currently highlighted match. C-g cancels the current Helm session and returns to the original location where helm-occur was invoked. RET on a match jumps to that match.
Demo:
You can see that candidates keep getting updated when I type. The demo starts when you see START in the minibuffer.
helm-occur.gif

Command: helm-apropos

Key binding:
<prefix> a (prefix is C-x c by default, or C-c h if set).
Description:
Pre-configured helm to describe commands, functions, variables and faces - all in one command!. It is similar to C-h a which runs apropos-command, but interactive includes more than just commands. helm-apropos combines 5 sources:
  • Commands: Lists all available commands.
  • Fucntion: Lists all available functions.
  • Classes: Lists all classes created by defclass. See Building Classes.
  • Generic Functions: Lists all functions created by defmethod. See Writing Methods
  • Variables: Lists all available variables.
  • Faces: Lists all available faces.
  • Helm attributes: Lists all attributes that you can use to build a Helm source. Useful if you want to write extension with Helm.
To enable fuzzy matching, add this setting:
(setq helm-apropos-fuzzy-match t)

Command: helm-info-*

Key binding:
<prefix> h <key> (prefix is C-x c by default, or C-c h if set); <key>, by default, is one of g, i or r:
Key Binding
<prefix> h g Command: helm-info-gnus
<prefix> h i Command: helm-info-at-point
<prefix> h r Command: helm-info-emacs
Description:
The prefix for info commands is <prefix> h. You can think of h as stands for help and <key> is one of the info topic to make it easier to remember.
helm offers a wide ranges of info commands for various topics. M-x helm info to see these commands, i.e. helm-info-as, helm-info-gdb… You can search for info nodes easily with the Helm interface and press TAB on an entry to view. M-<next> moves to the next page, and M-<prior> moves to the previous page in the other buffer.
You can have more helm-info- commands, such as:
  • helm-info-gdb.
  • helm-info-find.
  • helm-info-elisp.
….
Use M-x helm-info to see the list of helm-info- commands using the default info prefix: <prefix> h or key bindings of your choice.

Command: helm-lisp-completion-at-point

Key binding:
<prefix> <tab> (prefix is C-x c by default, or C-c h if set).
Description:
If you work with Emacs Lisp, this command provides a list of available loaded functions in Emacs. To get a list of completions, you first have to write a prefix, even just one character. Then execute the command and get a list of completion candidates. To enable fuzzy matching, add this setting:
(setq helm-lisp-fuzzy-completion t)

Command: helm-resume

Key binding:
<prefix> b (prefix is C-x c by default, or C-c h if set).
Description:
This command allows you to resume the previous Helm session, along with your previous patterns in the prompt. For example, if your last helm session was helm-ff-run-grep and you entered patterns in Helm prompt, helm-resume resumes that session along with your previous input.
With prefix argument, helm-resume allows you to choose among all existing Helm buffers. helm-mini or helm-buffer-list does not show existing Helm buffers; they ignore it by default; but if you run ibuffer, you will see a list of Helm buffers visible there. Don't kill them or you won't be able to resume.
This is really convenient when you have complex input ,and preparation steps. For example, if you have multiple regexp patterns in your previous Helm session, then you don't have to type it again. Or in your previous Helm session, you have to travel to a deep directory, and helm-resume helps you to reuse your previous session without going through all the troubles again.

Command: helm-all-mark-rings

Key binding:
<prefix> C-c SPC (prefix is C-x c by default, or C-c h if set). This is a rather long key sequence, this command deserves a better binding, for example:
(global-set-key (kbd "C-h SPC") 'helm-all-mark-rings)
Description:
One handy command. It allows you to view the content of the both the local and global mark rings in a friendly interface, so you can always jump back to where you were. Without this command, if you want to view the mark rings, you have to run M-: and enter mark-ring or global-mark-ring to view their contents. And even so, Emacs only displays the bare content of the mark-ring and global-mark-ring lists, which is the line number and its buffer like this:
(#<marker at 23614 in helm.org> #<marker at 2343 in setup-helm.el> #<marker at 4280 in helm.org> #<marker in no buffer> #<marker at 1271 in helm.org> #<marker at 643 in emacs-tutor.org> #<marker in no buffer> #<marker at 1 in setup-applications.el> #<marker at 1 in emacs-tutor3.org>)
With helm-all-mark-rings, you have this nice interface with line content and syntax highlighting:
helm-all-mark-rings.gif

Command: helm-regexp

Key binding: <prefix> r (prefix is C-x c by default, or C-c h if set).
Description:
Pre-configured helm to build regexps. This commands is useful when you want to test out a regexp interactively. The following actions are available with C-z:
Key Action
[f1] Kill regexp as sexp
  Saves the regexp as a string in kill-ring
[f2] Query Replace Regexp
  Invoke query-replace with current regexp to be replaced
[f3] Kill regexp
  Saves the regexp as is in the current Helm prompt
Demo:
helm-regexp.gif

Command: helm-register

Key binding:
<prefix> C-x r i (prefix is C-x c by default, or C-c h if set). Let's bind it to something else:
(global-set-key (kbd "C-c h x") 'helm-register)
Pre-configured for viewing Emacs registers. By simply executing helm-register, you can view what is in registers. RET or TAB inserts content of selected register.
Key Action
[f1] Insert Register
  Insert register content into buffer
[f2] Append Region to Register
  Append an active region to current content
  in selected register
[f3] Prepend Region to Register
  Prepend an active region to current content
  in selected register
Demo:
helm-registers.gif

Command: helm-top

Key binding:
<prefix> t (prefix is C-x c by default, or C-c h if set).
Description:
This command provides a Helm interface for the top program. You can interact with each process with the following actions:
Key Binding
[f1] kill (SIGTERM)
[f2] kill (SIGKILL)
[f3] kill (SIGINT)
[f4] kill (Choose signal)
helm-top specific commands:
Key Binding
C-c C-u Refresh helm-top
M-C Sort by shell commands
M-P Sort by CPU usage
M-U Sort by user
M-M Sort by memory
user and shell commands are sorted alphabetically.
Demo:
helm-top.gif

Command: helm-surfraw

Key binding:
<prefix> s (prefix is C-x c by default, or C-c h if set).
Description:
surfraw provides a fast UNIX command line interface to a variety of popular WWW search engines and other artifacts of power. It reclaims google, altavista, dejanews, freshmeat, research index, slashdot…
helm-surfraw provides a Helm interface to the surfraw program that is easy to use. All you have to do is enter a search term, and then Helm provides a number of services, such as Google, Stackoverflow… to use.
Demo:
helm-surfraw.gif

Command: helm-google-suggest

Key binding:
<prefix> C-c g (prefix is C-x c by default, or C-c h if set). Let's bind it to something else:
(global-set-key (kbd "C-c h g") 'helm-google-suggest)
Description:
This command allows you to interactively enter search terms and get results from Google in a Helm buffer. Then, you can open one of the candidates in other services, such as Google, Wikipedia, Youtube, Imbd, Google Maps, Google News. If you are on Windows, don't type too fast or, you will have an error and you have to abandon this Helm session.
Demo:
helm-google-suggest.gif

Command: helm-color

Key binding:
<prefix> c (prefix is C-x c by default, or C-c h if set).
Description:
If you want to quickly view and copy hexadecimal values of colors, helm-color provides such a feature. But, helm-color is beyond a mere color picker. The real usage for helm-color is for face customization: the command list ALL available faces, with a preview of each face in the same row. This makes theme customization really quick because you can quickly view a face with its color. Because of the way Helm works, you can look at a group of faces together to have a global view of whether or not the colors work well with each other.
helm-color contains two groups, with actions in each:
  • Colors:
Key Action
[f1] or C-c N Copy Name
  Copy color name into kill-ring
[f2] or C-c R Copy RGB
  Copy hex value into kill-ring
[f3] or C-c n Insert Name
  Insert color name into current buffer
[f4] or C-c r Insert RGB
  Insert hex value into current buffer
  • Customize Face:
Key Action
[f1] Customize
  Open Customization window
[f2] Copy Name
  Copy face name
Demo:
helm-color.gif

Command: helm-eval-expression-with-eldoc

Key binding:
<prefix> C-: (prefix is C-x c by default, or C-c h if set). C-: is a bit difficult to press, it would be better with:
(global-set-key (kbd "C-c h M-:") 'helm-eval-expression-with-eldoc)
Description:
This command allows you to enter Emacs Lisp expressions and get instant results in a Helm buffer for every character you type. The changed key binding above makes it easier to remember, since the stock eval-expression binds to M-:. So, from now on, to eval expression without live update, use M-:, and with live update, use C-c h M-:. This command is useful when you want to try out a command with various inputs, and want to see the results as fast as possible.
Demo:
helm-eval-expression.gif

Command: helm-calcul-expression

Key binding:
<prefix> C-, (prefix is C-x c by default, or C-c h if set).
Description:
This commands provides a Helm interface for the calc command. What is calc? According to Calc Manual:
Calc is an advanced calculator and mathematical tool that runs as part of the GNU Emacs environment. Very roughly based on the HP-28/48 series of calculators, its many features include:
  • Choice of algebraic or RPN (stack-based) entry of calculations.
  • Arbitrary precision integers and floating-point numbers.
  • Arithmetic on rational numbers, complex numbers (rectangular and polar), error forms with standard deviations, open and closed intervals, vectors and matrices, dates and times, infinities, sets, quantities with units, and algebraic formulas.
  • Mathematical operations such as logarithms and trigonometric functions.
  • Programmer's features (bitwise operations, non-decimal numbers).
  • Financial functions such as future value and internal rate of return.
  • Number theoretical features such as prime factorization and arithmetic modulo m for any m.
  • Algebraic manipulation features, including symbolic calculus.
  • Moving data to and from regular editing buffers.
  • Embedded mode for manipulating Calc formulas and data directly inside any editing buffer.
  • Graphics using GNUPLOT, a versatile (and free) plotting program.
  • Easy programming using keyboard macros, algebraic formulas, algebraic rewrite rules, or extended Emacs Lisp.
You can enter valid calc mathematic expressions such as +, -,*, /, sin, cos, tan, sqrt…. To make the most out of this command, obviously you should carefully study calc itself by reading the Calc Manual.
Demo:
helm-calc.gif

Command: helm-eshell-history

Key binding:
No key binding. Let's bind it to a key to be used in Eshell:
(require 'helm-eshell)

(add-hook 'eshell-mode-hook
          #'(lambda ()
              (define-key eshell-mode-map (kbd "C-c C-l")  'helm-eshell-history)))
Description:
If you usually re-execute an old shell command in Eshell with M-r, then helm-eshell-history provides an easy and efficient way to work with command history. Using stock M-r, you have to actively remember past commands you worked with; otherwise Eshell cannot find the command. If you forget, you will have to type in the command history to refresh your memory. helm-eshell-history combines the two: you can interactively use a regexp to select past commands and get live feedback with a list of commands that satisfy the search. Now you don't have to remember which commands exist. Let Helm handle that problem for you.
Demo:
helm-eshell-history.gif

Command: helm-comint-input-ring

Similar to helm-eshell-history, but used for M-x shell.
(define-key shell-mode-map (kbd "C-c C-l") 'helm-comint-input-ring)

Command: helm-mini-buffer-history

Do you ever feel uneasy operating on the minibuffer history when it's getting large (say, hundreds of history items)? If so, Helm can help you easily manage a large number of items in the history list with ease using the Helm interface.
(define-key minibuffer-local-map (kbd "C-c C-l") 'helm-minibuffer-history)

Package: helm-projectile

Author: Bozhidar Batsov, bozhidar@batsov.com
Homepage: GitHub
Features:
Provide a Helm interface for quickly selecting files in a project using Projectile.
helm_projectile.gif
Installation:
M-x list-packages and select helm-projectile package, then install it. After it finishes installing, you can start using helm-projectile immediately.
Usage:
For basic usage, C-c p h to run helm-projectile and select files in your project. Please refer to the full guide.

Package: helm-descbinds

Author
  • 2008-2010: Taiki SUGAWARA, buzz.taiki@gmail.com
  • 2012-2013 Michael Markert, markert.michael@googlemail.com
  • 2013-present: Daniel Hackney dan@haxney.org
Homepage: GitHub
Features: Helm Descbinds provides an interface to Emacs’ describe-bindings, making the currently active key bindings interactively searchable with helm.
Additionally you have the following actions
  • Execute the command
  • Describe the command
  • Find the command
Installation:
M-x list-packages and select helm-descbinds package, then install it. After finish installing, add this code snippet to activate the package:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; PACKAGE: helm-descbinds                      ;;
;;                                              ;;
;; GROUP: Convenience -> Helm -> Helm Descbinds ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require 'helm-descbinds)
(helm-descbinds-mode)
Usage:
Enter a prefix key and C-h after it. You will see a list of bindings using the Helm interface for narrowing.

Summary of Keybindings

This chapter summarizes the key bindings introduced in the above chapters.
Key Binding Command Description
M-x helm-M-x List commands
M-y helm-show-kill-ring Shows the content of the kill ring
C-x b helm-mini Shows open buffers, recently opened files
C-x C-f helm-find-files The helm version of find-file
C-s helm-ff-run-grep Run grep from within helm-find-files
C-c h i helm-semantic-or-imenu Helm interface to semantic/imenu
C-c h m helm-man-woman Jump to any man entry
C-c h / helm-find Helm interface to find
C-c h l helm-locate Helm interface to locate
C-c h o helm-occur Helm interface for occur
C-c h a helm-apropos Describes commands, functions, variables, …
C-c h h g helm-info-gnus  
C-c h h i helm-info-at-point  
C-c h h r helm-info-emacs  
C-c h <tab> helm-lisp-completion-at-point Provides a list of available functions
C-c h b helm-resume Resumes a previous helm session
C-h SPC helm-all-mark-rings Views contents of local and global mark rings
C-c h r helm-regex Visualizes regex matches
C-c h x helm-register Shows content of registers
C-c h t helm-top Helm interface to top
C-c h s helm-surfraw Command line interface to many web search engines
C-c h g helm-google-suggest Interactively enter search terms and get results from Google in helm buffer
C-c h c helm-color Lists all available faces
C-c h M-: helm-eval-expression-with-eldoc Get instant results for Emacs lisp expressions in the helm buffer
C-c h C-, helm-calcul-expression Helm interface to calc
C-c C-l helm-eshell-history Interface to eshell history
C-c C-l helm-comint-input-ring Interface to shell history
C-c C-l helm-mini-buffer-history Interface to mini-buffer history