1. 在两个子窗口中对比文件内容
  2. 打开更多的窗口以参考其他信息.
  3. 对某个窗口内容比较有兴趣,跳转到该窗口,将该窗口最大化
  4. 看完最大化的窗口内容后,undo最大化操作,重新回到早先的多个小窗口模式以便继续纵览全局



(require 'window-numbering)
(window-numbering-mode 1)


安装Winner Mode,然后在.emacs中添加以下代码,

(winner-mode 1)

;; copied from http://puntoblogspot.blogspot.com/2011/05/undo-layouts-in-emacs.html (global-set-key (kbd "C-x 4 u") 'winner-undo) (global-set-key (kbd "C-x 4 r") 'winner-redo)


M-x other-window,快捷键是C-x o.


快捷键C-x 2/3


M-x delete-other-windows,快捷键C-x 1.


M-x delete-window (快捷键C-x 0)

顺便说一下,M-x kill-buffer-and-window (快捷键C-x 4 0),我现在用得更多 些.


因我较喜欢vi快捷键,所以我安装了Evil Mode.快捷键和Vi一样. C-w h/j/k/l移动至各方向的子窗口.


C-x r w存储,C-x r j载入.

Convert TEX to PDF

Install TexLive in your OS.

Install latex2pdf which is dependent on TexLive.

cpan App::cpanminus # handy tool to install cpan module
cpanm Template # Template is missing on cygwin
cpanm latex2pdf # finally

Convert now!

pdf2latex cv.tex

Install perl module through source package on cygwin by using cpanm

I failed to install package "Template" by running `cpanm Template'.

It's because the binary package requires gcc4 while on my cygwin only gcc3 available.

So I install it from source package (with some hack, of course),

cpanm --look Template # Download and unpack the distribution and then open the directory with your shellI
cpanm . #install from local directory

Updated: The simpler solution is to install gcc4 at cygwin.

How to convert org to PDF

All you need to do is to install TexLive. The org-mode has some handy function to find the TexLive and do the conversion. So all you need to trigger the conversion in Emacs is pressing

C-c C-e p

At Cygwin and Linux, installing TexLive is a piece of cake by using default package system.

At Mac, I use the default TexLive source package (install-tl-unx.tar.gz). After installation, you need set up environment varaibles.

If you use Bash (default at my OS X 10.7.3), you can paste below code to you ~/.bashrc:

if [[ `uname -s` == *Darwin* ]]; then
   #tex live on OS X
   export PATH=/usr/local/texlive/2011/bin/universal-darwin:$PATH
   export MANPATH=/usr/local/texlive/2011/texmf/doc/man:$MANPAH
   export INFOPATH=/usr/local/texlive/2011/texmf/doc/info:$INFOPATH

Notes on Emacs chat between John Wiegley and Sacha Chua

See http://sachachua.com/blog/2012/07/transcript-emacs-chat-john-wiegley/ for the video and transcript.

I only record key points,

  • Use gnus heavily
  • ERC in another Emacs instance
  • Look at Magit buffer to get overview
  • Use built in vc mode, `C-x v =' to get diff of current file
  • One single org, other seven are archives
  • Helm (fork of anything.el)
  • Gnus read mail and rss (gwene), Adaptive scoring is good.
  • fetchmail to fetch from Gmail
  • Organize Structure (rename/moving files folders)
  • Twenty items in hot list in org-mode linking to other lists and areas of machine
  • Dropbox to record voice at http://dropbox.com and org-mode hook to get voice message
  • M-m to call `org-capture'
  • 'Quick Keys' on Mac plus some apple script (Viewing page in Chrome, M-n to activate emacs, put a link)
  • Emacs can view PDF
  • Reading Emacs manual from the scratch
  • Emacspeak to read the manual
  • Ledger for the accounting

How to configure yasnippet 0.7.0 and use it with Auto-Complete-Mode

I will only talk about how to set up yasnippet 0.7.0 or higher version.

If you follow `normal install` way, setup is simple

See its official documentation.

Install the yasnippet into somewhere and add following code into your .emacs:

(add-to-list 'load-path
(require 'yasnippet) ;; not yasnippet-bundle
(yas/load-directory "~/.emacs.d/plugins/yasnippet-x.y.z/snippets")

If you use elpa package system, setup is even simpler

After installation, you only need two lines in .emacs.

(require 'yasnippet)

Yasnippet 0.7.0 have already defined two locations for the snippets, "~/.emacs.d/yasnippet-install-path/yasnippet-x.y.z/snippets" and "~/.emacs.d/snippets". Yasnippet will load snippets in BOTH directories at startup.

So you only put your own snippets in "~/.emacs.d/snippets" and done. No need to tweak .emacs at all. To verify my claim, you can `C-h v yas/snippet-dirs' to check value of "yas/snippet-dirs". Please note "yas/root-directory" is the alias of "yas/snippet-dirs".

The real world setup is NOT simple

I will explain the reasons at first and give my complete yasnippet configuration code at the end of the this post.

Two snippets may share the same key, so I need activate `yas/dropdown-prompt'

One issue is I need a user-friendly dropdown window popped up when the key I input has several candidates. For example, when I type "inc" in C code. There are two candidates `#include "…"' and `#include <…>' available. A handy dropdown popup will help me to choose one of them as efficient as possible.

The good news is such fancy popup is a standard component of yasnippet. It's called `yas/dropdown-prompt'. Its default algorithm will activate it at highest priority.

The bad news is for some strange reason yasnippet won't load that dropdown-list by default. So you need manually load that component by one line of elisp code `(require 'dropdown-list)'.

`yas/dropdown-prompt' is not perfect

I cannot scroll down the dropdown window when there are more candidates it can display. That's especially annoying when calling `yas/insert-snippet'. In this case, we need use `yas/completing-prompt' instead. I will show the fix at the end of this article.

Yasnippet conflicts with other plugins

I use Auto Complete Mode (version 20120327 in elpa). There are two issues when using it with yasnippet.

First, it use TAB key to do the auto-complete thing while yasnippet also uses TAB key. So I need re-configure hotkeys of yasnippet.

Second, yasnippet changed its API `yas/get-snippet-tables' since version 0.7.0. This make the auto-complete cannot use yasnippet at all. This issue is reported and fixed by tkf. Actually all you need do is simple:

cd auto-complete-install-dir
rm auto-complete-config.elc
curl -L https://raw.github.com/tkf/auto-complete/337caa2ccc254a79f615bb2417f0d2fb9552b547/auto-complete-config.el > auto-complete-config.el

My final yasnippet setup

(require 'yasnippet)
;; default TAB key is occupied by auto-complete
(global-set-key (kbd "C-c ; u") 'yas/expand)
;; default hotkey `C-c & C-s` is still valid
(global-set-key (kbd "C-c ; s") 'yas/insert-snippet)
;; give yas/dropdown-prompt in yas/prompt-functions a chance
(require 'dropdown-list)
;; use yas/completing-prompt when ONLY when `M-x yas/insert-snippet'
;; thanks to capitaomorte for providing the trick.
(defadvice yas/insert-snippet (around use-completing-prompt activate)
     "Use `yas/completing-prompt' for `yas/prompt-functions' but only here..."
       (let ((yas/prompt-functions '(yas/completing-prompt)))

在我的Mac OS X 10.7.3上为heroku开发rails程序

rails版本为3.1,OS X版本10.7.3,postgresql版本9.1.3j



在OS X 10.7.3上安装postgresql

首先,检查你的OS X版本,从10.7开始OS X自带postgresql

sw_vers -productVersion


curl http://nextmarvel.net/blog/downloads/fixBrewLionPostgres.sh | sh


brew install postgresql



这里是一些数据库基本操作的官方文档. 可以psql -l看一些已有数据库列表.


rails new myapp --database=postgresql


然后,createdb myapp_development创建postgresql数据库,rake db:migrate建立数据库schema并导入数据在本地数据库.简单测试可证明数据库和web程序可以无缝工作.

最后不要忘记git commit最新代码.


请参考heroku官方文档,提醒一下不要忘记运行heroku run rake db:migrate,否则数据库是空的.

部署结束后可以运行heroku open打开浏览器访问web程序首页.

如打开网站有问题,可以heroku logs查看日志.

针对Ruby on Rails开发的Emacs插件



yari对ruby自带的ri工具提供一个emacs界面,优点是兼容最新的ruby,操作简单,只要使用一个函数yari-anything即可.但是其官方文档推荐的yari-anything的快捷键F1在有些远程terminal下有问题.我改成了C-c ; r.


Luca Pette的Twitter Bootstrap on Rails比较简单,直接使用了bootstrap的css,没用less,测试了simple_form,show_for,kaminari(分页数据)三个应用。要点在于kaminari有点兼容性问题,用twitter-bootstrap-kaminari-views解决这个问题,其他没难度。

@metaskill的LESS Is More - Using Twitter's Bootstrap In The Rails 3.1 Asset Pipeline讲了如何用bootstrap的less函数和变量,我很有兴趣,根据我的经验能通过less语法调用twitter的函数比较有价值。安装gem less-rails-bootstrap就行了,调用bootstrap的函数的技术细节省略,基本就是less语法。

Adding Twitter's Bootstrap CSS to your Rails app的作者也读了以上两篇文章,要点在于确认了@metaskill的方法,less的一些详细的例子。也提到了可以用sass,但我没有深入读下去。

Twitter Bootstrap Basics at railscasts.com非常好,一个完整的例子。Comments也不错,一些html细节。要点在于用了gemtwitter-bootstrap-rails,看起来很强大。





  • 牛人如Steve Purcell用Emacs的最新版本24.x,而读者使用的是主流版本23.x。
  • 对于Emacs的一些基本命令还是不熟悉
  • 对github不是很熟悉


  • 还是要按照我原文所说,至少要读一下Emacs自带教程,启动emacs时可带"-Q"参数快速启动。
  • 学点github和git的操作很有帮助,如我原文所说。
  • 牛人Steve Purcell的配置还是很好改的,我一直在同步,可以轻易改为支持Emacs23 前提是你对于git和Emacs比较熟悉,当然这个前提需要你花点时间
  • 如果直接用Steve Purcell的配置有难度,可以考虑Emacs Starter Kit作为起步 Emacs Starter Kit有两个版本,一个版本支持Emacs24,一个版本支持Emacs22和Emacs23 我个人还是强烈建议最终使用Steve Purcell的配置。
  • M-x list-packages一次,如果你的Emacs在启动时下载软件由于网络问题有点卡的话
  • tsocks和export http_proxy=有时候是用的 在中国,技术人必须懂什么叫代理