2016年12月13日星期二

小日本投下原子弹,中国经济走到鬼门关? 
 

12月9日,中国商务部新闻发言人在新闻发布会上回应美、欧、日等国关于不承认“中国市场经济国家”时表示,中方强烈不满,并坚决扞卫自身合法权益!但是,抗议有个毛用?

五月份,欧洲不承认中国市场经济地位。七月份,美国不承认中国市场经济地位。但美欧至少还没有从官方层面定性,也就是说还有得谈。然而,昨天日本直接从官方层面不承认中国市场地位,也就是没得谈,这TM就动真格了。

中国市场经济地位这破事也算老生常谈,但为毛美日欧同在今年集体动手?真不是什么阴谋,而是中国加入WTO十五年的保护期到了,12月11日就是截止日。所以,请记住12月11日这一天,中国经济的鬼门关!

众所周知,中国经济的崛起源于2001年加入WTO,参与到全球经济一体化中。不提枯燥的经济数据,想一想2001年你所在的城市是什么样,今天又是什么样吧。毫无疑问,美日欧不承认中国市场经济地位,对于中国经济的影响不亚于一颗原子弹!


古人云,“兵马未动,粮草先行”,所以一堆专家与媒体先出来嘴炮,各种抗议、阴谋论、帝国主义亡我之心不死……但是,美日欧的市场经济地位标准都设立几十年了,从未变过啊!

市场经济的认定主要由五条组成……

1、决策没有明显受国家干预;

2、有一套按国际通用准则建立的会计账簿;

3、生产成本、财务状况未受非市场经济体系的显着影响;

4、企业不受政府干预成立或关闭;

5、货币汇率变化由市场决定。

好吧,你觉得我们达到了哪一条?或者别说对外贸易,你看看国内还有什么暴利行业不是被国企垄断?国内都呵呵,更别提对外贸易了。

那么,既然中国“从未”有过市场经济,为什么还会有中国是不是市场经济的争论呢?这要从美日欧给中国经济开小灶说起。



我们有很多很多事都是“自古以来”,但市场经济除外。90年代初,中国最激烈的争论是到底姓资还是姓社。换句话说也就是,中国实行市场经济,还是实行计划经济。这次争论直到1992年的那次着名的南巡后,才算结束。

然而,争论结束的结果不是中国姓资或姓社,而是姓“中国特色社会主义”。毕竟,鲁迅在《娜拉走后怎样》中曾说过,“可惜中国太难改变了,即使搬动一张桌子,改装一个火炉,几乎也要血;而且即使有了血,也未必一定能搬动,能改装……”

老外们不懂什么是特色社会主义,但我们都知道啊,意思就是中国既不会是计划经济,也不会是市场经济,而是一个世界上独一无二的经济混合体模式。

这种经济模式肯定不符合加入WTO的标准,但为毛美日欧会答应中国加入WTO呢?呵呵,为了让中国有钱!



面对美日欧不承认中国市场地位,“帝国主义亡我之心不死”的阴谋论又开始了。但是,你又打不过帝国主义(除非用核弹同归于尽),它亡你干毛?再说,你要是“亡”了,帝国主义还怎么从你身上发大财?不仅帝国主义没兴趣“亡”你,还要千方百计地让你变成有钱人。

千万不要以为帝国主义是天使,而是人类自诞生以来就有一条亘古不变的真理:你永远无法从一个穷人身上发大财,你只能从有钱人身上赚钱!所以,美日欧想在中国发大财的唯一办法是,让中国先有钱!

这绝不是马屁,而是这个道理中国现在也开始懂了。举个最简单的例子,非洲拥有12亿人口,这对于中国这个“世界工厂”是多么大的诱惑啊?但是,非洲现在很多地方连电都没有,你能卖给他电器吗?所以,中国现在拼命帮助非洲兄弟们发展经济,希望非洲兄弟们也能有钱啊。

同样,现在非洲的lowB中也流行“中国亡我之心不死”!请问,你是想去“亡”那些你连名字都念不准的非洲小国,还是想让他们变得有钱,之后从他们身上发大财呢?

言归正传,世界有那么多穷国,美日欧为什么在WTO中只给中国开小灶,让中国人变得有钱呢?中国是世界第一人口国,当年就有12亿人啊。但是,当年的中国经济让这12亿人只是“人”,不是消费者。如果中国经济能够崛起,我艹,那就是12亿消费者啊!地球上还有比这更大的金矿吗?

更重要的是,不同于那些一条道走到黑的“老朋友”们,当年中国正在姓资姓社之间摇摆。马云说,梦想一定要有的,万一实现了呢?对于美日欧而言,中国万一姓资了呢?这就不仅仅是钱那么简单了。

所以,当年克林顿说,中国虽然不符合加入WTO的标准(市场经济地位),但如果不让中国加入WTO,它将失去改变的机会。而且,美日欧还给了中国一个超大的红包,15年的特惠期。光阴似箭,现在15年特惠期到期了,这就是中国市场地位问题的起源。

15年前,美日欧搞不明白中国姓社还是姓资,十五年后,依然搞不清。所以,他们也不愿再去思考这个问题。

日本第一个从官方层面下了定论,相信川普很快会紧跟其后,极右势力逐步上台的欧洲,必定也将如此……那就都没得谈了。这对于本来就处于L型经济的中国来说,就我艹了,但专家们和一堆嘴炮又有什么用?要是有用,我们早就赶英超美了!

实际问题是如果美日欧都不承认中国市场经济地位,对中国实行严厉的反倾销政策,我们怎么办?那么,是不是可以开发其他市场呢?毕竟,如商务部所说,世界上大多数国家还是承认中国市场经济地位,只有美日欧等少数国家不承认中国市场经济地位。

商务部统计,全球80多个国家承认了我们的市场经济地位。听起来是不是觉得美日欧只是一小撮?没错,美日欧就是一小撮,但占据绝大多数的80多个国家,加起来也不如这一小撮的一根毛!

不提那80多个国家中你连名字都没听过的国家,就先说其中最牛逼的老大哥俄罗斯。老斯基不明白为什么总有人觉得俄罗斯非常牛逼?那是半个世纪之前的事了,现在俄罗斯的GDP还不如中国的一个广东省!

我们和俄罗斯的关系已经铁得不能再铁,但即使在这种极端友好的环境中,中俄贸易也只有830亿美元。而且,830亿美元中还有一大堆石油滥竽充数!仅从经济角度而言,别说一个俄罗斯对中国经济没什么毛用,就是十个俄罗斯又有什么用?

“三个臭皮匠顶个诸葛亮”是最大谎言,渣渣就是渣渣,80多个渣渣加在一起还是渣渣!

再看看中国与美日欧的贸易额吧!中美贸易额达到逆天的5583亿美元,而且主要是制造业商品,没有石油滥竽充数。中欧贸易虽然比中美贸易额低,但也有5210亿欧元。最后,中日贸易额虽然在这两年狂降,但“瘦死的骆驼比马大“,也达到了3033亿美元……

也就是说,中国和美日欧的贸易总额一万多亿美元,从而让我们有了“世界工厂”的威名。那么,我们还能从地球上找到代替美日欧的经济体吗?



经济就是,没有永远的敌人,也没有永远的朋友,只有永远的钱!全世界人民都是一个德性,“有钱不赚王八蛋”!所以,都这个时候了,就别扯那些没用的抗议,我们必须在两个实际的选择中挑一个。

一是,达到美日欧所说的市场经济标准。如果中国达到市场经济标准,我相信美日欧会一个跑得比一个快,跑过来跪舔中国。谁TM吃饱了撑的,和钱有仇?

二是,帮助那80多个承认中国市场经济地位的国家,帮他们变成有钱人,从而填补美日欧的空缺。

呵呵,你觉得哪个选择更实际呢?
美国大选启示录:民主的黄昏

 
“政治正确,我们再也承受不起!”——特朗普
 
提示语:时来天地皆同力,运去英雄不自由。美国建国初期,政坛上群星璀璨,涌现出一批像华盛顿、麦迪逊、汉密尔顿、杰斐逊那样的杰出政治家;国运衰落,民主步入黄昏,只剩下希拉里、特朗普这类三流政客。
 

美国建国初期,政坛上群星璀璨

1. 政治正确就是普世价值

什么是政治正确?政治正确就是普世价值。坚持政治正确,你就不能说女人胖,不能说黑人笨,不能说穷人懒,更不能说民主不好。
 
特朗普的胜利是政治正确的失败。政治正确是以平等为核心,包括自由,民主,法治,人权在内的一系列西方价值观,俗称普世价值。然而,任何价值都有一定的界限,不能像地平线那样无限延伸。当自由到男人可以随意进入女厕所,民主到教师讲课必须坚持政治正确,否则将面临解雇,法治到警察不敢对黑人执法,人权到老人交了一辈子的税,最后拿的退休金还不如非法移民福利金的时候,普世价值就走向反面,与自由、民主、法治、人权的初衷背道而驰了。
 
学者李零不相信普世价值:“什么最普世?美元、美军最普世。但美国说了,谁也不许学。”话虽尖刻,却不无道理。让美联储放弃国际铸币权,解放军成为世界警察,美国第一个不答应。可见,普世价值也分三六九等,归巴黎统筹委员会管辖。
 
在公知眼里,希拉里当选,是民主的胜利;特朗普当选,更证明民主伟大——它还有纠错功能。总之,民主不会错,普世价值不容置疑。这就是政治正确。如此正确、普世下去,美国就是下一个希腊。
 
去年,坚持政治正确的希腊政府破产。希腊是民主的摇篮,也是民主的坟墓。这个曾经投票处死苏格拉底的民族,投票赖掉了所有的债务。国家破产前夕,希腊人载歌载舞,一片欢腾。总理齐普拉斯带头高呼:“民主万岁!”“民主战胜了恐惧!”
 
愿赌服输,欠债还钱,是起码的人品。希腊人民集体赖账,破产的不仅是国家,也是希腊的民主制度。公元前5世纪,西方历史学之父希罗多德一部《伯罗奔尼撒战争史》,把民主钉在历史耻辱柱上达两千年之久;今天,希腊再次让民主蒙羞:昨天是暴民政治,今天是无赖刁民!
 
史学界公认,雅典亡于民主。在亚里士多德的词典里,民主与暴民政治是同义语。在雅典民主制度下,公民参与政治。素质低下的公民被野心家操纵,使雅典政坛陷入混乱,引发伯罗奔尼撒战争,为后来马其顿南下征服希腊创造了机会。
 
政治正确是美国立国之本。特朗普当选,美国价值观分裂,一半人不再正确。
 
2. 民主步入黄昏

我曾说:世界上至少有两个地方不适宜搞民主:幼儿园和疯人院。特朗普胜出,我低估了人民群众的智商。八年前奥巴马当选,人们欢呼美国历史上第一个黑人总统;不久前,希拉里几乎成为美国第一个女人总统;现在,特朗普以疯子之誉当选美国下届总统;未来只要再选出一个傻子来做总统,就齐活了。它证明,美国是一个真正的民主国家,什么人都可以当总统。
 
在一半选民眼里,希拉里是个骗子;在另一半选民心中,特朗普是个疯子。一边是伪君子,另一边是真小人,美国人民很悲催,必须在两者之间作出选择。选战格调之低,手段之劣,创历史之最。特朗普指责希拉里被金主收买,涉嫌杀人灭口,声称要把她送进监狱;希拉里攻击特朗普是疯子,把核武库交给他是全世界的灾难。先后11名女性在媒体上指控特朗普性行为不检,最后一名是杰西卡·德雷克。这位成人片女星于10月22日召开记者会,指控特朗普10年前对其进行性骚扰。杰西卡·德雷克和她朋友们的出场,令人联想起马克·吐温短篇小说《竞选州长》中的那一群私生子。
 
时来天地皆同力,运去英雄不自由。美国建国初期,政坛上群星璀璨,涌现出一批像华盛顿、麦迪逊、汉密尔顿、杰斐逊那样的杰出政治家;国运衰落,民主步入黄昏,只剩下希拉里、特朗普这类三流政客。
 
国运衰落,不是因为这届美国人民不行,而是因为民主制度中携有自我毁灭的基因。美国因民主伟大,也因民主衰落。杜牧总结秦亡教训:“灭六国者六国也,非秦也;诛秦者秦也,非天下也。” 汤恩比研究文明兴衰,发现那些使一个文明兴起的主义和原则,往往也就是使它灭亡的主义和原则。来自尘土,覆归尘土;成也萧何,败也萧何,讲的也是这个道理。
 
美国病入膏肓。苍穹中传来柏拉图对民主的千古之问:“如果你生了病,是到广场上去找公民呢,还是去找医生?”
 
柏拉图不喜欢民主,他的老师、哲人苏格拉底在广场上被雅典公民投票处死。
 
3. 民主万恶,但别无选择

与专制相比,民主更符合人性,这也是民主取代专制,成为世界潮流的原因。然而,人性有弱点,民主也有缺陷。民主的精髓在于一人一票,民主的死穴也在于一人一票。对此丘吉尔深有感受。他关于民主是最不坏的制度的格言,其实是一个误译。1945年,二战硝烟未尽,丘吉尔就被请出了唐宁街十号。激愤之下,他借古希腊作家普鲁塔克之口抱怨:“对伟大人物忘恩负义,是强大民族的标志。”面对民意的裁决,丘吉尔无奈地感叹:“民主万恶,但别无选择。”(Democracy is the worst form of government, except for all the others.)
 
诺贝尔文学奖得主丘吉尔精通语言艺术,骂人如同恭维:英国人忘恩负义,但因之而强大;民主制度万恶,却还没有比它更好的。丘吉尔一生从政,深知民主本性平庸,厌恶英才。他在二战中崭露头角,把英国带出灾难,依靠的不是民主,而是战争赋予他的专制权力。战场上不能投票,指挥官不靠选举;生死存亡之际,民主显然没有独裁好使。
 
其实,无论是英国的君主立宪,还是美国的联邦主义,初衷都是阻滞民主潮流,维持精英统治,不让政治进入厨房。在英美,民主最初只是少数人的游戏。从贵族到中产阶级,再从中产阶级到女人/黑人,英国走了700年,美国近200年。笔者就读的普林斯顿大学,1972年才招第一个女生,校长伍德罗·威尔逊最得意的政绩,就是从不接受黑人学生。但是,再长的路也有尽头,即使是英美这两个世界上最成熟的民主国家,最终也不能摆脱民粹的宿命。英国脱欧公投,特朗普草根逆袭,标志着精英时代落幕,民粹时代到来!
 
4. 民主政体在本质上是临时的

1887年,亚历山大·泰勒教授总结雅典共和国的衰落:“一个民主政体在本质上永远是临时的;它根本不能作为永久的政府形式存在。民主会一直存在,直到选民发现他们可以用投票的方式从公共财政中送给自己慷慨的礼物。从那一刻起,大多数人总是投票给那些承诺从公共财政中给自己最大利益的候选人。结果是每一个民主政体最终都将因为宽松的财政政策而崩溃,并被紧随其后的专制政体所取代。”
 
他继续写道:“世界上最伟大的文明的平均年龄,大约200年。在这200年期间,这些国家总是按照以下顺序进行:从束缚到精神信仰;从精神信仰到伟大的勇气;从勇气到自由;从自由到丰富;从丰富到自满;从自满到冷漠;从冷漠到依赖;从依赖回到束缚。”
 
圣保罗大学法学院的约瑟夫·奥尔森教授认为,美国现在正处于泰勒教授定义的“自满和冷漠”阶段之间,全国大约40%的人口已经达到了“依赖政府”阶段。如果国会大赦那两千万非法移民, 给予他们公民身份并允许他们投票,那么我们就可以在不到五年的时间内, 对美利坚合众国说再见了。
 
从梭伦改革到伯罗奔尼撒战败,雅典共和国活了256年,美利坚共和国今年240岁。美国今天45%的人不交联邦税。如果民主党上台,特赦非法移民,大批接受中东难民,不交税人口的比例很快会超过一半。
 
特朗普政治不正确,至少他自己掏钱竞选,没有增加纳税人的负担;希拉里政治正确,却用选民的钱竞选,自己高价买下邻居家的房子,设置路障不让选民靠近。
 
精英喜欢希拉里,因为他们有太多的相似之处:傲慢,贪婪,虚伪,不接地气又自称代表民意,拥有太多却假装一无所有。
 
中国公知坚持政治正确,视希拉里为民主的化身,把特朗普当选比做希特勒上台,实在是不知所云。希拉里和特朗普的竞选,不是民主与专制的对决,而是民主与常识的较量。常识险胜,美国还有一线希望。
 
5. 美国国父不相信民主

一个流传很久的神话是,作为世界民主的灯塔,美国国父功不可没:1787年,55位反叛者(后称国父)聚集费城,争吵116天,创造了一个自由民主的国家。神话经公知加工,传播,早已家喻户晓,成为“常识”。
 
与公知的故事相反,美国国父不相信民主。汉密尔顿认为:“民主是一种疾病。”“对群众的要求让步,就证明参议院还是不稳,这是因为对民主精神出奇的暴烈和蛮横估计不足。”拉什宣称:“民主是恶魔之最,高喊民主的都是疯狗。” 格里断言:“我们所经历过的罪过,都是源于民主。”亚当斯指出:“以往所有时代的经历表明,民主最不稳定、最波动、最短命。”“民主从不久长。它很快就浪费、消耗和谋杀自己。以前从未有民主不自杀掉的。”麦迪逊说:“民主是由一副由动乱和争斗组成的眼镜,从来与个人安全,或者财产权相左,通常在暴乱中短命。”“政府若采取民主的形式,与生俱来的就是麻烦和不方便,人们之所以遣责民主,原因就在这里。”执笔宪法第一修正案的费雪道:“民主是包藏着毁灭其自身的燃烧物的火山,其必将喷发并造成毁灭。民主的已知倾向是将野心勃勃的号召和愚昧无知的信念当成自由来泛滥。”《美国宪法》签字人和执笔人之一莫里斯说:“我们见识过民主终结时的喧闹。无论何处,民主都以独裁为归宿。”连德高望重的富兰克林也痛心疾首地承认:“我们都遭受过民主带来的迫害和不公正。”
 
不难看出,民主在美国国父眼里是一头怪兽;它是自由的敌人。指望这样一群厌恶民主的人制订出一部民主宪法,实在是强人所难。事实上,国父的初衷不是建立一个民主国家,而是限制民主。在制宪会议上,代表们把拟议中的美国政府称为“共和政府”或“自由政府”,就是不提“民主政府”。事实上,今天许多中国人所憧憬的民主,恰恰是当年美国国父们所警惕的民主。
 
美国宪法只字不提民主,因为当时依照《民主邦联条约》建立起来的高度民主的邦联政体正面临崩溃,各种政治势力都打着民主的旗号来发动动乱。制宪会议的背景之一是谢斯起义,起义者打出民主旗号,增加了民主这个词的暴力色彩。
 
国父厌恶民主的另一个原因,是他们深受古典政治学的影响。两千多年前,亚里士多德写《政治学》,把希腊四百多个城邦归纳为六种制度。三种好制度是君主,贵族,共和;三种坏制度是僭主,寡头,民主。僭主是一个人的专制,寡头是少数人的专制,民主则是多数人的专制。六种政体各有千秋,相比之下民主最劣。亚里士多德视民主为暴民政治,他的观点成为两千年来西方政治学主流。
 
6. 政治正确是思想自由的敌人

过去,我们相信革命神圣;今天,我们断言民主正确。至于革命为什么那么神圣?民主为什么那么正确?没人回答。这些问题别说提出来,想想都是犯罪!在大师面前,不需要思考,崇拜就够了。民主面前也是一样。思考是对民主的不恭,也是对真理的不敬。于是,继革命拜物教之后,我们有了民主拜物教。教徒们除了民主,不认识第三个字。
 
一百年前,李大钊、陈独秀以俄为师,虔诚地拥抱马克思主义,建立了共产党;一百年后,公知以美为师,同样虔诚地拥抱民主,把德先生再次推上神坛。小孩要吃糖,有什么错?人民要民主,为什么不行?在公知眼里,民主是上帝;反民主,就是不正确。
 
朋友传来锵锵三人行窦文涛采访《赛先生》前主编、公知大腕饶毅教授的视频。教授坚持政治正确,力挺希拉里,断言特朗普支持者是都傻瓜、文盲;他们不仅智力堪忧,而且道德低下。他与所有选特朗普的人绝交,宣称:“我和特朗普之间,肯定是我代表正义。”
 
饶毅教授研究生物学,深谙人性,知道人一半是天使,一半是魔鬼:投希拉里票的这一半人是天使,投特朗普票的那一半人是魔鬼。
 
看完视频后的感觉是:人本来是直立行走的,一旦有了地位,信奉了什么主义,就会像真理一样横着走路。
 
政治正确是思想自由的敌人。两百年前,王朝代表政治正确;一百年前,革命代表政治正确;今天,民主成为政治正确。谁能保证,一百年后不会有另外一种正确?
 
7. 民主是中国的劫数

孙中山推翻满清,靠的是驱除鞑虏恢复中华的民族主义;毛泽东战胜蒋介石,玩的是打土豪分田地的民生主义;非常可能,未来中国属于一人一票的民主主义。
 
革命是活不下去的人的反应,民主是日子越过越好的人的要求。从这个意义上说,民主是中国的劫数;中国在劫难逃!
 
有人说,中国没发生革命,是因为“朝中不见袁世凯,江湖没有孙中山”,这不是事实。中国历来不缺野心家,现在更不缺。不到两百人的海外民运圈,就有六个总统,一个皇帝,几十个主席。中国江湖之大,藏龙卧虎,肯定英雄豪杰更多,正所谓:“满朝皆是袁世凯,江湖无数孙中山”。然而,革命需要野心家,更需要炮灰。今天的中国缺的不是野心家,是炮灰。只要炮灰还在东莞打工,革命就没有希望。
 
中国今后不会革命,因为所有人的篮子里都有几个鸡蛋,没人愿意铤而走险。但中国未来会民主,因为这是大势所趋,人心所向。就算民主是个坑,人们也会义无反顾地往里跳。精英跳,因为那里政治最正确;草民跳,因为他们当够了孙子,也想做一回爷;富人跳,因为他们缺乏安全感,希望参政;政客跳,因为民主是道德制高点,你不抢,别人会抢。即使是习近平,也很难抵御民主的诱惑。对他来说,实行民主至少有三个好处:1)青史留名,成为中国民主之父,超越蒋经国,比肩华盛顿;2)通过选举连任,继续掌控中国政治;3)用选票重建中共的合法性。
 
作为合力的产物,历史是矢量求和。中国的矢量是民主。
 
2012年习近平即位之初,笔者曾在《党国、军国、民国与中共的政治改革》一文中妄议中央:“以反腐收拾民心,以反日收拾军心,最终完成对权力的全面掌控,似乎是习近平的接班步骤。我相信,习近平会在十八大后提出以党内民主为核心的政改方案,用选票重建共产党的合法性,从而收拾早已涣散的党心。”
 
四中全会确立习近平的核心地位,提出从严治党,标志着中南海高层已完成了对权力的全面掌控。美国大选后一个星期,11月15日,习近平、李克强、王岐山等政治局常委在北京各选举站高调亮相,投票参加区人大代表的选举,正式开始从选票中寻找合法性。毕竟,“为人民服务”,“权为民所赋”,是中共立党初衷,也是习近平的政治承诺。(2007年)
 
8. 让少数人先民主起来

得人心者得天下。在中国,天下既人心。中国今天最大的危机,不是经济,不是环境,是政权的合法性危机。王岐山去年在谈到这个问题时说:“中国共产党的合法性源自历史,是人心向背决定的,是人民的选择。”沿着同样的逻辑,他又说中共的执政还要看人民高兴不高兴、满意不满意、答应不答应。王岐山讲出了中国古来政治合法性的本意:天命无常,有德者居之。
 
毛泽东的合法性来自于打江山的战绩,邓小平的合法性来自于改革开放的政绩,但它们都难以持续。一旦权威递减,经济衰退,执政党就会陷入塔西托陷阱,进退维谷,动辄得咎:你说党媒姓党,他说你专横霸道;你说党媒姓人民,他又说你强奸民意。
 
摆脱合法性危机的最佳途径是民主。民主给人民选择的机会,同时也给政府免责的理由。在民主制度下,人民为自己的决定买单,政府通过选举定期更新合法性。从这个意义上说,民主制度永远不会陷入合法性危机;它天然合法!
 
2000年大选,戈尔和小布什的选票十分接近。美国没有分裂,是因为候选人的竞选纲领也十分接近。此次选举后美国社会空前分裂,因为在政治正确和全球化等一系列重大问题上,希拉里与特朗普的立场南辕北辙,180度对立。考虑到这是一个几乎家家有枪的国家,人们不得不佩服美国人的素养。
 
在美国,政治是一门妥协的艺术,底线是自己活,也让别人活;在中国,政治上一场赢者通吃的决斗,原则是你死我活。在美国,党争双方有规则,有底线,打的是有限战;在中国,党争双方无规则,无底线,打的是超限战。在美国,军人不参与政治;在中国,政治离不开军人。在美国,法律是国王;在中国,国王是法律。在美国,宪法权威高于一切,一切重大问题最终都成为法律问题;在中国,“枪杆子里面出政权”,一切重大问题最终都在战场上解决。
 
只要政治还是你死我活,党争还是不共戴天,民主就是毒药,只会促成中国分裂。中国要实行民主,前提是思想转型:赢者不再通吃,败者不再为寇;政治走出丛林,军队退出政治;摒弃超限战;自己活,也让别人活。
 
要让中国人分裂,最好的办法就是选举。此次美国大选之后,华人世界严重分裂,夫妻反目,朋友绝交,比比皆是;一些没有选举权,甚至一天也没有到过美国的人,也在媒体上恶语相向,大打出手。试想有一天中国大选,左派手中有马列主义普遍真理,右派手中有民主自由普世价值,双方互不相让,为真理而斗争,最后会是怎么一个局面。
 
为避免民主引起的动乱,最好的前途,是党主立宪,有序地走向民主。与东欧、苏联、台湾、南韩不同,中国民主的道路特殊,底线是执政党不愿也不能放弃政权。期待中共开放党禁报禁,无异于期待它自杀,毫无现实可能性。如果说上世纪80 年代中共曾有过开放党禁报禁的考虑,今天它绝不会再做此想。因此,找到一条即能实行民主,又不引起社会动荡的道路,是执政党的当务之急。此途无它:党内民主,让少数人先民主起来。
 
其实,英国大宪章运动、美国制宪会议,又何尝不是让少数人先民主起来的努力。通过让少数人先民主起来,美国逐渐实现了全民民主;通过宪政,华盛顿和他的战友们完成了从革命党向执政党的过渡,自我分裂成联邦党和反联邦党,后来又演变为今天的民主党和共和党,轮流执政至今。美国的经验,中共完全可以借鉴。

9. 中国的路在中国,不经过华盛顿

精英常说,民主的最大好处,是能维护社会稳定;美国建国240年,45次政权和平交替,证明了民主的优越性。这种说法即缺乏历史感,也与现实不符。且不说雅典内乱和美国内战,即便是近年来埃及、伊拉克、叙利亚等国的民主,也是未见其利,尽显其弊,毫无稳定性可言。此外,中国历史上的唐宋元明清,除元朝外,都享有几百年的国运。倘若慈禧老佛爷借此证明大清帝国制度优越,精英想必不会买账。
 
精英认为,民主的另一优越性,是能够促进经济。上世纪八十年代之前,情形确实如此。当时的民主国家,不仅政治和谐,经济也繁荣。邓小平改革开放,韬光养晦,不争论,反映了高层对西方民主的服膺。可以说,除了维持政权的本能,那时的中共已经基本上丧失了自信。
 
再提自信,已是三十年之后。三十年河东,三十年河西。三十年来世界的变化,挑战人类常识,颠覆了许多民主神话。台湾民主了,结果是族群分裂,经济停滞;苏联民主了,代价是国家解体,执政党下台;埃及民主了,换来的是社会动荡,穆斯林兄弟会上台;叙利亚民主了,结果天下大乱,ISIS横行,数十万人死于战乱,数百万难民流向世界。与此同时,中国没有民主,反而政治稳定,经济腾飞。2005年中国GDP超意大利,2006年超英法,2007年超德国,2010年超日本,仅次于美国,成为世界第二大经济体。到2015年,中国GDP已是日本两倍,按购买力平价计算,超过美国,位居世界第一。
 
从幻灭到涅盘,阴差阳错,中国走出了一条自己的路。与公知们的期待不同,这条路上没有他们熟悉的美国路标:民主选举,言论自由,三权分立,司法独立,军队国家化。总之,伪托的布什讲话中提到的权力笼子的五条栅栏,一条都没有,有的只是日益强化的中央集权和舆论控制。逆民主潮流而动,中共在成功中找回了自信:中国的路在中国,不经过华盛顿。
 
走笔至此,想起中共早期毛泽东与国际派的争论:国际派按莫斯科的地图走路,毛泽东自己寻路。国际派发动城市暴动,毛泽东建立农村根据地;国际派领卢布,毛泽东打土豪。争论结束于遵义会议。会议参加者20人,17人留学苏联,没出过国的只有毛泽东,彭德怀和林彪三人。但就是这三个人,坚持武装斗争,立足中国,找到了一条从井冈山通往北京的路。
 
10. 没有真正的民主

什么是民主?民主就是人民自己当家作主,决定自己的命运。无论是投票还是数豆,直接还是间接,等额还是差额,实质都是一样:人民参与国家事务决策,并为自己的行为负责。
 
从这个意义上说,没有什么真正的民主,也没有配不配民主的问题。有的只是民主质量的高低和不同的后果。押定离手,愿赌服输。相信毛泽东,就有文化大革命;选出希特勒,就别抱怨奥斯维辛。
 
什么人搞政治,就会搞出什么样的政治。民主能选出罗斯福,也能选出希特勒。有几流的人民,就有几流的政府;一群乌龟竞选,只能选个王八出来做主席。
 
走进世界民主博物馆,人们看到各式各样的民主:英国君主立宪的民主,美国三权分立的民主,法国断头台的民主,俄罗斯二人转的民主,以及伊拉克家破人亡的民主。这些民主形式不同,质量各异,却并无真假的区别。面对琳琅满目的民主橱窗,轻轻的一句,“民主是个好东西”,实在是不知所云。
 
按照亚里士多德的定义,民主的对立面是共和。这也是为什么美国两党以民主/共命名的原因。在一次民主讨论会上我曾问大家,什么是民主的对立面?所有人都回答专制。这是概念错误。上和下对立,上和左不对立。如果民主与专制对立,怎么解释希腊的民主、法国大革命的民主、德国魏玛共和国的民主以及中国文革的民主?在雅典,公民投票处死了苏格拉底;在巴黎,民主导致血腥屠杀;在德国,民主选出了希特勒;在中国,文革大民主使数百万人死于非命。显然,民主与专制不对立;它往往只是专制的另一种形式。
 
古典政治学说民主是个坏东西,因为它认为民主是一群坏人(暴民)在投票;现代政治学说民主是个好东西,因为它假设民主是一群好人(公民)在选举。其实,好人还是坏人,公民还是暴民,你说了不算,我说了也不算;它取决于教育和社会的法治程度。
 
成功实现民主的国家,必有自己的特殊的坚守;反之亦然。美国民主成功,因为美国人警惕权力;英国民主成功,因为英国人热衷改良;俄国与民主擦肩而过,因为俄国人血液里流着沙皇的基因;中国没有民主,因为我们太相信成王败寇。
 
11. 野兽不在乌纱帽里,它在人性之中

几千年来,人们一直在探讨,什么是最好的政治制度?君主,民主,贵族还是共和?这个问题的答案是,没有最好的政治制度,相对于不同的人民,有一种最好的政治制度;正如没有一件最漂亮的衣服;相对于不同的年龄,体型,肤色,文化,有一件最漂亮的衣服。
 
美国建国初期,根据对人性的不同解读,国父分裂为联邦党人和反联邦党人两派:前者支持美国宪法,后者反对美国宪法。分歧的焦点是:到底拥有一个强大的中央政府重要,还是切实保障公民权利重要?双方代表人物是杰弗逊和麦迪逊。杰弗逊相信人性,主张无为而治,有限政府:“最好的政府是管得最少的政府。”麦迪逊警惕人性,主张中央集权,强调政府有两个功能:首先控制民众,然后约束自己。联邦党人的成就是美国联邦宪法,反联邦党人的贡献是宪法修正案。正如赫伯特·斯托林在《反联邦党人全集》导论中所说:尽管不无背谬之处,反联邦党人合当侧身于国父行列。他们和联邦党人联手,共同创造了这个伟大的国家。
 
政治学是关于人性和制度的科学。如果人人都是天使,我们不需要政府;如果人人都是魔鬼,我们不可能有政府。正因为人是一半是天使,一半魔鬼,我们才既需要、也可能有一个政府。政府的目的不是改造人性,是扬善抑恶。
 
与浪漫的自由主义者杰弗逊不同,麦迪逊深谙人性,精通政治,是制宪会议的灵魂。作为美国宪法之父,他清醒地认识到:1)宪政不仅要限制权力的任性,也要防止野心的冲动;2)真正的冲突不在政府与人民之间,而在人民本身之中;3)政府不应该有自己的利益,它的功能是调节冲突;它是裁判,不是运动员;4)野兽不在乌纱帽里,它在人性之中.
 
12. 结束语

有人会问:“你说民主步入黄昏,又说中国会民主,这不是自相矛盾吗?”回答是:民主好不好是价值判断,至于中国会不会民主,则是事实判断。
 
所有这些,并不是说民主不好,而是说民主没有人们想象的那样好;它也会生老病死。当然,饱受专制之苦的公知会对本文观点嗤之以鼻,嘲笑我是在对太监讲过度纵欲的坏处。我能理解他们的感受——我若生活在国内,多半也会有同样的反应。但是,我心目中的读者是智者,不是太监。对那些思想被阉割,充满仇恨的人,我唯有同情。
 
革命是穷人的节日,立宪是富人的本能。中国离自由也许还很远,但离宪政却很近。从肃贪到从严治党,从整军到党媒姓党,在可以预见的未来,中国不会有西方式的民主自由。中国崛起的代价,是整整一代的自由主义者。他们生不逢时。
 
汽车急转弯时,司机不能玩大撒把;历史转折关头,当国者必须大权在握。在现有体制不变的前提下,中国要民主,只可能是党内民主;中国要立宪,只可能是党主立宪。中国的改造,始于共产党的改造;中国的进步,离不开共产党的进步。
 
当然还有另外一条路,那就是推翻执政党,建立一个“自由民主的新中国”。一百年来,中国人民追随孙中山、毛泽东,从这条路上一路走来,结果是越走离初衷越远。他们最后都自食其言,在民主的旗帜下建立另一个独裁。
 
中国早已放弃了共产主义,不再输出革命;美国也应停止颜色革命努力,不再把自己的价值观强加于人。把美国之音、自由亚洲电台变成反共舞台,资助中国异议人士,只能制造敌意,让更多的中国人厌恶美国。至少,笔者更怀念大学时代的美国之音。那时的美国之音没有立场,教英语900句,是大学生的偶像。
 
继共产主义之后,民主也进入了黄昏。毕竟,历史没有终结,福山的乐观预言——历史由民主终结——只是显示了他的浅薄。与福山一样,章家敦也喜欢预言:他断言中国在十年内即将崩溃。他们都错了。不同的只是,福山知错就改,以后又提出了许多有价值的思想;章家登绝不认错,不断把崩溃日期延长。章的态度使我想起一个朋友,他指错了路不承认,硬说是路错了。
 
历史没有终结,中国也没有崩溃。当美国陷入政治正确的泥潭中难以自拔时,中国也正面临执政党的合法性危机。美国要避免希腊的命运,必须限制民主;中国要摆脱合法性危机,必须实行民主;美国的问题是民主太多,中国的问题是民主太少;美国的优势是企业效率,中国的优势是政府效率。在许多方面,美国泛滥的,正是中国缺乏的;反之亦然。就政治制度而言,中美之间有许多东西可以互补:有限政府VS有为政府,民主制VS责任制。也许,中美联手,共同探索新的政治文明的历史契机已经到来。
 
(2016年11月25日于普林斯顿)

2016年11月8日星期二

擺正姿勢圍觀美國第45任總統出爐
  
文/羽談飛
    大選投票蓄勢待發,白宮主人花落誰傢?今天(11月8日)全球目光將直擊美國第58屆第45任總統扣人心弦地激情出爐。這對於中國人來說,雖然是饞涎欲滴地隔墻聞香,但如果願意擺正姿勢做一個鑿壁偷光的有心人,你定能從美國大選中厘清有關現代政治文明的普世常識。
    眾 多關註美國大選的友友們,估摸再也沒有比今天更加激動人心。這是可以理解的,因為國人一直都秉持成王敗寇的價值觀,幹啥事都隻問結果不問過程,幹啥活都隻 顧高潮不顧前戲,所以,中國人遠比美國人更在乎今天誰當美國總統。主流派迫不及待希望特朗普險中求勝,自由派心急火燎渴盼希拉裡笑在最後,雙方都把自己的 命運前途寄托在美國總統身上,這確實讓人匪夷所思。微信群有人耿耿於懷地說:“羽爺是支持特朗普的”。哈哈,原因就在於羽某曾經在朋友圈已經表明態度: “我希望特朗普當選,因為他有美麗的妻子和漂亮的女兒”。這與其說我在支持特朗普,倒不如說我是在偷窺美人兒,其實這就是我對美國大選的態度,他們誰當選 都僅僅是美國的總統而已。
    盡管誰當美國總統對中國人來 說並不重要,但是,隻要是美國總統對中國人就非常重要。這句有點繞,但細細琢磨你就會豁然開朗。因為,美國總統所扮演的角色完全依據於美國的國傢性格品 質,而不是依據於總統個人的喜怒哀樂。別以為希拉裡上來就會按你所願整得風風火火,有可能她一掃以前的果敢潑辣而變得溫溫吞吞;也別焦慮特朗普上來還會放 蕩不羈而讓人提心吊膽,有可能他一掃以前的鋒芒畢露而變得韜光養晦。但是,隻要是美國人當總統,他的唯一任務有且隻有兩個:讓美國更加自由,讓世界更加自 由,當然也包括中國在內。這是由美國的立國精神決定的,是不以任何人的意志為轉移的。
    總 統是人,美國總統更是人中之人,千萬別以為美國總統作為人的一面與誰卿卿我我就會姑息誰的惡劣品質。尼克松是破冰中美冷戰關系的美國總統,盡管他與血妖魔 獸握手擁抱時樂樂呵呵,但尼克松主義卻是徹底推倒紅色高墻最有力的一擊。克林頓與誰交往都是倜儻風流瀟瀟灑灑,但就是他,讓中國世貿談判談成瞭白頭發,但 他最後還是相信瞭謊言承諾,結果害得今天奧巴馬隻能另起爐灶靠踢屁屁來收場。小佈什也是與圖樣圖森破談笑風生,但在南海撞擊事件中強硬交涉一點也不溫良恭 謙讓。奧巴馬最能縱橫捭闔陪瓜賣笑,但在朝核問題中絲毫不給任何國傢有機會暗度陳倉。總之,無論誰當總統,美國的原則都在那裡,總統都隻能按原則辦事。
    自然誰當總統都一樣,為什麼美國要花費那麼大精力選總統呢?這是特別饒有興致的問題。
    我 們說誰當總統都一樣,這個“誰”必須是進入最後競選角逐的誰,而不是某些半吊子逗逗說的選個豬或選個流氓都一樣。美國總統選舉歷史已經歷228年,每四年 輪回一次大選,其中有57個年頭就耗費在大選的激烈角逐中,你說說,這世界還有哪一個國傢如此願意費時費力費人地來選舉政治首腦?這不就北戴河關門商量一 下的事兒麼?何必這麼麻煩?我的親,別人山姆大叔是在顛覆政府,所謂大選年,不僅僅是選一個總統,還要選538名參眾兩院的國會議員呢,所以,美國人在大 選年其實很累的,不但選總統要睜大眼睛,選議員同樣要睜大眼睛。不但豬一樣的人不能進入競選角色,即便是進入競選角色也會被弄成豬一樣的難堪。如果特朗普 和希拉裡不進入最後角逐,你知道個毛的電郵門和黃色調侃門啊。問題就在這裡,大選耗時一年的奧秘也在這裡,每一個競選人必須接受選民拉網式道德排查,可以 沒有君子,但絕不能放過小人,即便最後必須在小人中選一個,也是最不壞的那一個小人勝出。這個大選過程不但是在淬火總統競選人,更是在錘煉國民“主權在 民”的自治精神,所謂的國民素質就是這樣給培養起來的。
    什 麼樣的人才能進入總統競選角色呢?中國人特別喜歡用“精英”形容政要,那你就大錯特錯瞭。在一個正常的自由國傢裡,每一個人都是精英,每一個人又都是平 民,這就叫人人生而平等,不但在政治權利上平等,在社會地位上也是人人平等,國民如是,總統也不例外。我可以毫不猶豫告訴你,美國的每一個競選成功的總統 在政治水平上都說不上知識精英,相對於那些學院派的政治學教授而言,總統就是一個僅僅熱衷於為國傢政治而奮鬥的職業偏好者。這與比爾蓋茨隻喜歡IT不喜歡 白宮是一樣一樣的,即便是曼哈頓街頭的流浪漢,裡面可能就有博士碩士一大堆,你要問為什麼?答:因為喜歡。自由的神秘和幸福就在這裡,自由就是能給每一個 人都有選擇做自己的機會。
    透視美國大選,我們更應該知 道,啥叫民主?啥叫共和?庸俗地說,民主就是吵架,共和就是吵累瞭歇一歇,這就叫妥協。歇得差不多瞭重新又吵,這就是四年一屆。正如兩個饑餓的孩子盯著一 個煮雞蛋,兩個都想吃,咋辦?不能靠力氣,必須各自訴說自己的最該吃的理由,由圍觀者來評判誰最該吃。這個辯論吵架質疑指責的過程就叫民主。為什麼這樣說 呢?民主的本質是自治,自治的本質就是敢於表達自己異見的質疑精神,分歧就是民主的主旋律。但終歸吵架是不能解決問題啊,如何鎖定階段性吵架成果呢?這就 要靠共和,註意,是共和,不是共識,如果你聽見有啟蒙公知叫囂要達成共識,你趕快離開,他目的就是消滅異見。什麼叫共和呢?共和就是指各自都維持自己分歧 的基礎上達成階段性妥協,這個妥協就是放下手中的屠刀舉起手中的選票。也許讀到這裡你還是對“共和”二字有些迷糊,換個姿勢說吧。我可能激烈反對你當總 統,但我又可能將手中寶貴一票投給你當總統。這就叫共和。玄機在哪裡?因為我始終保留瞭我反對的異見,但你又是最不壞的那一個小人,這就叫階段性妥協,意 思是,遇到下一輪有更合適的人選堅決拋棄你,當然,如果任上你表現很好,我也可能修正我對你的異見。因此,分歧是民主的生命,妥協是共和的法寶。(作者微 信:yutanfeiytf)
    通過美國大選,你還得澄 清一個概念,所謂道德就是指公德,這世上從來就沒有什麼私德一說。私德,皆因中國人厚顏無恥為自己的沒臉沒皮辯護而找的一塊遮羞佈。道德,就是一個人的行 為是否妨礙瞭他人自由的一種修為。註意,“他人”是道德這個詞存在的全部意義,魯濱遜何來道德一說?你隻要沒有妨礙他人自由,你就是道德的,你當然也是自 由的。當著女人說黃段子,這就是不道德,更別說出軌偷情揩油盜香瞭。這對於一直缺德的中國人來說,很難理解美國人要抓住特朗普說幾句黃段子的不依不饒。
    特 朗普和希拉裡都是“七十者可以食肉矣”的安享老人瞭,但為什麼還要如此百折不撓去忍受競選折磨?這個唯有懂得什麼叫美國精神之後,你才能恍然大悟。美國沒 有退休一說,雖然人人都有養老金,但從沒有一條法令說誰必須退休,估摸美國人永遠也不敢立法叫誰退休。凡是坐過歐美航班的人都知道,上面哪有什麼誘惑你想 入非非的美麗空姐?幾乎全都是一群大爺大媽在為你空中服務,但他們都很專業。他們缺錢嗎?NO,NO,NO,因為美國人的幸福來自活出自我,也就是為自由 奮鬥而釋放自己的全部生命價值。是美國制度讓他們有這麼高尚的境界嗎?NO,NO,NO,全都是美國精神的傳承。華盛頓可謂勞苦功高啊,離任總統後就回傢 釀葡萄酒,臨終前的十天還在葡萄園除草,染瞭風寒就一命嗚呼,享年69歲。其實,在中國的話,華盛頓他老人傢至少活96歲沒問題。
    美 國大選就是一場關於普世理念和現代人文精神的現場直播課堂,如果隻停留在誰當總統的視覺上,那就實在太浪費翻墻偷香的成本瞭。早在八月我寫瞭一篇《選舉人 制度:美國先驅的傻神傑作》,這是對美國大選規則的釋義,有興趣的友友可以看看。讓我們充實自己後一起倒計時,靜候美國第45任總統的鮮活出爐。


摆正姿势围观美国第45任总统出炉

文/羽谈飞
    大选投票蓄势待发,白宫主人花落谁家?今天(11月8日)全球目光将直击美国第58届第45任总统扣人心弦地激情出炉。这对于中国人来说,虽然是馋涎欲滴地隔墙闻香,但如果愿意摆正姿势做一个凿壁偷光的有心人,你定能从美国大选中厘清有关现代政治文明的普世常识。
    众多关注美国大选的友友们,估摸再也没有比今天更加激动人心。这是可以理解的,因为国人一直都秉持成王败寇的价值观,干啥事都只问结果不问过程,干啥活都只顾高潮不顾前戏,所以,中国人远比美国人更在乎今天谁当美国总统。主流派迫不及待希望特朗普险中求胜,自由派心急火燎渴盼希拉里笑在最后,双方都把自己的命运前途寄托在美国总统身上,这确实让人匪夷所思。微信群有人耿耿于怀地说:“羽爷是支持特朗普的”。哈哈,原因就在于羽某曾经在朋友圈已经表明态度:“我希望特朗普当选,因为他有美丽的妻子和漂亮的女儿”。这与其说我在支持特朗普,倒不如说我是在偷窥美人儿,其实这就是我对美国大选的态度,他们谁当选都仅仅是美国的总统而已。
    尽管谁当美国总统对中国人来说并不重要,但是,只要是美国总统对中国人就非常重要。这句有点绕,但细细琢磨你就会豁然开朗。因为,美国总统所扮演的角色完全依据于美国的国家性格品质,而不是依据于总统个人的喜怒哀乐。别以为希拉里上来就会按你所愿整得风风火火,有可能她一扫以前的果敢泼辣而变得温温吞吞;也别焦虑特朗普上来还会放荡不羁而让人提心吊胆,有可能他一扫以前的锋芒毕露而变得韬光养晦。但是,只要是美国人当总统,他的唯一任务有且只有两个:让美国更加自由,让世界更加自由,当然也包括中国在内。这是由美国的立国精神决定的,是不以任何人的意志为转移的。
    总统是人,美国总统更是人中之人,千万别以为美国总统作为人的一面与谁卿卿我我就会姑息谁的恶劣品质。尼克松是破冰中美冷战关系的美国总统,尽管他与血妖魔兽握手拥抱时乐乐呵呵,但尼克松主义却是彻底推倒红色高墙最有力的一击。克林顿与谁交往都是倜傥风流潇潇洒洒,但就是他,让中国世贸谈判谈成了白头发,但他最后还是相信了谎言承诺,结果害得今天奥巴马只能另起炉灶靠踢屁屁来收场。小布什也是与图样图森破谈笑风生,但在南海撞击事件中强硬交涉一点也不温良恭谦让。奥巴马最能纵横捭阖陪瓜卖笑,但在朝核问题中丝毫不给任何国家有机会暗度陈仓。总之,无论谁当总统,美国的原则都在那里,总统都只能按原则办事。
    自然谁当总统都一样,为什么美国要花费那么大精力选总统呢?这是特别饶有兴致的问题。
    我们说谁当总统都一样,这个“谁”必须是进入最后竞选角逐的谁,而不是某些半吊子逗逗说的选个猪或选个流氓都一样。美国总统选举历史已经历228年,每四年轮回一次大选,其中有57个年头就耗费在大选的激烈角逐中,你说说,这世界还有哪一个国家如此愿意费时费力费人地来选举政治首脑?况且选出来也就干四年,何必这么麻烦?我的亲,别人山姆大叔是在颠覆政府,所谓大选年,不仅仅是选一个总统,还要选538名参众两院的国会议员呢,所以,美国人在大选年其实很累的,不但选总统要睁大眼睛,选议员同样要睁大眼睛。不但猪一样的人不能进入竞选角色,即便是进入竞选角色也会被弄成猪一样的难堪。如果特朗普和希拉里不进入最后角逐,你知道个毛的电邮门和黄色调侃门啊。问题就在这里,大选耗时一年的奥秘也在这里,每一个竞选人必须接受选民拉网式道德排查,可以没有君子,但绝不能放过小人,即便最后必须在小人中选一个,也是最不坏的那一个小人胜出。这个大选过程不但是在淬火总统竞选人,更是在锤炼国民“主权在民”的自治精神,所谓的国民素质就是这样给培养起来的。
    什么样的人才能进入总统竞选角色呢?中国人特别喜欢用“精英”形容政要,那你就大错特错了。在一个正常的自由国家里,每一个人都是精英,每一个人又都是平民,这就叫人人生而平等,不但在政治权利上平等,在社会地位上也是人人平等,国民如是,总统也不例外。我可以毫不犹豫告诉你,美国的每一个竞选成功的总统在政治水平上都说不上知识精英,相对于那些学院派的政治学教授而言,总统就是一个仅仅热衷于为国家政治而奋斗的职业偏好者。这与比尔盖茨只喜欢IT不喜欢白宫是一样一样的,即便是曼哈顿街头的流浪汉,里面可能就有博士硕士一大堆,你要问为什么?答:因为喜欢。自由的神秘和幸福就在这里,自由就是能给每一个人都有选择做自己的机会。
    透视美国大选,我们更应该知道,啥叫民主?啥叫共和?庸俗地说,民主就是吵架,共和就是吵累了歇一歇,这就叫妥协。歇得差不多了重新又吵,这就是四年一届。正如两个饥饿的孩子盯着一个煮鸡蛋,两个都想吃,咋办?不能靠力气,必须各自诉说自己的最该吃的理由,由围观者来评判谁最该吃。这个辩论吵架质疑指责的过程就叫民主。为什么这样说呢?民主的本质是自治,自治的本质就是敢于表达自己异见的质疑精神,分歧就是民主的主旋律。但终归吵架是不能解决问题啊,如何锁定阶段性吵架成果呢?这就要靠共和,注意,是共和,不是共识,如果你听见有启蒙公知叫嚣要达成共识,你赶快离开,他目的就是消灭异见。什么叫共和呢?共和就是指各自都维持自己分歧的基础上达成阶段性妥协,这个妥协就是放下手中的屠刀举起手中的选票。也许读到这里你还是对“共和”二字有些迷糊,换个姿势说吧。我可能激烈反对你当总统,但我又可能将手中宝贵一票投给你当总统。这就叫共和。玄机在哪里?因为我始终保留了我反对的异见,但你又是最不坏的那一个小人,这就叫阶段性妥协,意思是,遇到下一轮有更合适的人选坚决抛弃你,当然,如果任上你表现很好,我也可能修正我对你的异见。因此,分歧是民主的生命,妥协是共和的法宝。(作者微信:yutanfeiytf)
    通过美国大选,你还得澄清一个概念,所谓道德就是指公德,这世上从来就没有什么私德一说。私德,皆因中国人厚颜无耻为自己的没脸没皮辩护而找的一块遮羞布。道德,就是一个人的行为是否妨碍了他人自由的一种修为。注意,“他人”是道德这个词存在的全部意义,鲁滨逊何来道德一说?你只要没有妨碍他人自由,你就是道德的,你当然也是自由的。当着女人说黄段子,这就是不道德,更别说出轨偷情揩油盗香了。这对于一直缺德的中国人来说,很难理解美国人要抓住特朗普说几句黄段子的不依不饶。
    特朗普和希拉里都是“七十者可以食肉矣”的安享老人了,但为什么还要如此百折不挠去忍受竞选折磨?这个唯有懂得什么叫美国精神之后,你才能恍然大悟。美国没有退休一说,虽然人人都有养老金,但从没有一条法令说谁必须退休,估摸美国人永远也不敢立法叫谁退休。凡是坐过欧美航班的人都知道,上面哪有什么诱惑你想入非非的美丽空姐?几乎全都是一群大爷大妈在为你空中服务,但他们都很专业。他们缺钱吗?NO,NO,NO,因为美国人的幸福来自活出自我,也就是为自由奋斗而释放自己的全部生命价值。是美国制度让他们有这么高尚的境界吗?NO,NO,NO,全都是美国精神的传承。华盛顿可谓劳苦功高啊,离任总统后就回家酿葡萄酒,临终前的十天还在葡萄园除草,染了风寒就一命呜呼,享年69岁。其实,在中国的话,华盛顿他老人家至少活96岁没问题。
    美国大选就是一场关于普世理念和现代人文精神的现场直播课堂,如果只停留在谁当总统的视觉上,那就实在太浪费翻墙偷香的成本了。早在八月我写了一篇《选举人制度:美国先驱的傻神杰作》,这是对美国大选规则的释义,有兴趣的友友可以看看。让我们充实自己后一起倒计时,静候美国第45任总统的鲜活出炉。

选举人制度:美国先驱的傻神杰作 

吃中国大餐,看美国大选,中美两国鲜明的特色差异就在这一吃一选之间。中国人吃了五千年,还在继续吃,但却越吃越憨;美国人选了两百年,还在继续选,但却越选越欢。吃货的世界与选票的世界虽然都同属人间,但其距离却是一个在地一个在天。
吃是为了保命,选是为了保权,吃与选孰轻孰重?中国人说“生命高于一切”,但美国人却说“不自由毋宁死”。因此,中国人开门只为油盐柴米酱醋茶,关 门就是吃喝拉撒睡,但美国人睁眼却是飞呀飞呀飞呀飞,闭眼还是飞呀飞呀飞。结果呢?中国人为了一张饭票,不但活得很卑贱,死相更难堪;但美国人仅凭一张选 票,不但活得很光鲜,死也很尊严。
美国人的选票有这么神奇吗?
选票并不神奇,但美国人的选票真的很神奇。因为一般选票的概念就是强调“多数人决定”,但美国人的选票概念恰好是强调“千万别忽略少数人”。那要怎么选才能实现“千万别忽略少数人”的概念呢?这就不得不对美国开国先驱所发明的选举人制度而拍案叫绝。
选举人制度,严格说叫选举人团制度。其原理就是:各选区选民在选出自己心仪的总统候选人时,还必须同时选出最终投票选举总统的代表人,这个代表人就 叫选举人,由各选区(州)选举人组成的选举总统的团队就叫选举人团。选举人团必须宣誓:按照本选区选民多数意志将全部选举人票投给在该选区获胜的总统候选 人,这就叫胜者通吃。最后所有州的选举人票加总,赢得选举人票过半者当选为总统。
当你读完上述选举人制度原理后,多半一头雾水,甚至还想骂娘。真尼玛麻烦,这美国开国先驱吃饱了撑的,搞出这么绕的选举道道。嘿,笔者一开初就是这 么郁闷的,反复研究也不明其究里。但当我看见国内反美派总是苛责美国大选,说什么选举人团制度是间接选举,还说什么有可能违背多数意志的不公云云时,我就 在想,这美国开国先驱不会这么蠢轻易能让人说三道四。迄今为止,1787在费城制定的美国宪法一字未动,其中就包括这个选举人制度。当我们津津乐道美国宪 法的三权制衡时,基本就忽略了这个选举人制度逼真展现州州制衡的奥秘。当我看见有人说“在美国猪都可以当总统”时,我就知道不懂美国的人还真不少,而这个 选举人制度恰好就是彻底消除“猪都可以当总统”的投机竞选思维。美国这么牛叉不是没有原因的,因为这个选举人制度只能让最恰当的大智慧政治家最终获胜,美 国就是这样先后被44任牛叉总统领导为世界巨无霸的。
这个选举人制度的神奇由两部分构成:一是各州选举人数目确定原则,二是各州选举人票归属胜者通吃的原则。
各州选举人数目是按照各州在参众两院获得议员席数来确定。参议员是各州平等分配为两名,50个州就是总计100名参议员席位。众议员是各州按照人口 数量比例分配总计435个席位,人口多的州获得席位当然就多,人口少的州自然就少。但是,无论人口有多少,众议员席位至少必须有1个席位打底,这样,无论 多小的州至少都能分配到三张选举人票。美国首都华盛顿所在地哥伦比亚特区也是按照最小州原则给予3张选举人票。因此,美国全国选举人票总数=参议员席位+ 众议员席位+特区席位=100+435+3=538张。候选人赢得过半(270)选举人票就胜选为总统。
由于选举人票的数目是事先固定的,再由于各州的选举人只能将票全部投给胜者通吃的候选人,这样,选举人手中的这一票几乎就没有任何选择余地(缅因州 和内布拉斯加州例外),所谓选举人,与其说是人,倒不如说是选举器。正因为如此,随着信息技术的普及,就不再用真正的选举人组团去走形式选总统了,选举人 实质上仅仅作为贯彻选举人制度的计票工具而已。一旦各州选民投票完毕,选举人票自然就按胜者通吃落袋为在各州胜出的候选人。因此,选举人团制度根本就没有 二次再选的间接选举之说,恰好是一次性体现选民意志的一种表现方式而已。
为什么不用直接的选民选票数来决定总统归属,而硬要用这种绕个弯的方式来确认花落谁家呢?奥妙就在这里了。
如果直接由选民选票数决定总统归属,也就直接落入“简单多数决定”的陷阱,竞选人为了竞选效率,完全可能只须拼杀大州而放弃小州,即投机分配竞选力 量和竞选方略,这对小州来说就有被忽视的不公平。通过选举人制度这个巧妙的计票原则,选举人票明显偏向小州分配,就大大提升了小州选民选票的权重份量,每 个竞选人就不得不平均发力各州的拼选,在死拼大州的同时丝毫不敢怠慢对小州的重视,竞选人一旦偏废用力,即便赢了多数大州和全国多数选民选票,也可能输给 所有小州计总出来的选举人票数,这种意外在美国大选史上的1876、1888、2000年发生过三次。州州平等,一个州也不能丢下,让每个州的选民获得同 等尊重。这是选举人制度对每个竞选人上紧的一道魔咒。
胜者通吃的原则也是制约竞选人过度将精力血拼大州,微弱优势胜出与大获全胜都是获得一样的选举人票。同时,胜者通吃也制约选民的民粹狂热,鼓励选民 对不同候选人都要倾注关注热情,否则,选民手中这一票的权重份量就会贬值。因此,选举人制度的奥妙就在于,不但促使每个竞选人认知到每个州非常重要,而且 促使每个选民要认知到自己手中这一票也非常重要。
每个州都很重要,唯有地方平等自治;每个人都很重要,唯有人人平等自治。我的国家我的天,我的地盘我做主,这就叫自治,这也是民主的本质。选举人制度就是通过大选这种桥梁形式,丝丝入扣地贯彻这种民主自治理念。
选举人制度让我弄清了两个百思不得其解的问题:一是所谓“华盛顿全票当选为开国总统”是啥意思?我就说不可能是每个选民都选他吧,原来是获得选举人 全票,这一下子就很好理解了。二是为啥美国的公共交通总不拥挤?因为民主国家都是地方平等自治,一旦平等自治,资源的自由流通和自由竞争就会自动消除弱肉 强食的差别,因此,国家就不会有所谓的城乡差别、地域差别或先后差别,这样,人口分布和职业分布就不再会有过度集中现象,公共交通也就自然不会打拥堂了。 那种所谓“让一部分地区一部分人先富起来”的流氓作风,本质上就是通过暴力手段打劫穷人和穷地区去扶持富人和富地区,从而导致资源过度拥挤在中心城市和中 心地区,逼迫人力资源也就不得不向中心城市和中心地区集中,这就是为什么北上广的公共交通有怀孕流产风险般拥挤的原因。
美国制度很好,但不是天上掉下来的,也是人制定的,是谁?就是美国的开国先驱们出生入死和自带干粮立下的规矩。可想而知,制度好不好关键还是在人, 不是在于所有人,而是在于总有一批死脑筋硬骨头秉持傻逼精神的傻逼们。我们这里之所以这样,问题就在于傻逼实在太少了。傻逼一旦傻到底就会成神,美国的神 级先驱就是这样傻来的,这个神奇的选举人制度就是这样傻出来的。

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