Gih's Blog

只言片语

emacs 重新绑定C-x C-c,避免一时手快退出

2011-06-01 by gihnius, tagged as emacs

emacs的按键序列又长又相似, 以前经常手快或无意按了 C-x C-c.

写了一个函数重新绑定 C-x C-c 的行为:

;; ...never quit by mistake...
(global-set-key [(control x) (control c)]
                (function
                 (lambda () (interactive)
                   (cond ((y-or-n-p "Relax...? ")
                          (if server-clients (server-edit)
                            (save-buffers-kill-emacs)))))))

如果按下C-x C-c, emacs会询问你是否 Relax ? 如果当前窗口是一个 client frame

就直接退出该 client.