2014-01-10 Fri

[別の年の同じ日: 2002 2004 2007 2008 2009 2011 2017

key-chord.el はてぶ

Execute commands ninja-style with key-chord-mode - Emacs Redux
http://emacsredux.com/blog/2013/04/28/execute-commands-ninja-style-with-key-chord-mode/

下のような設定をすると、'FF' で find-file が実行できる elisp。

(require 'key-chord)
(key-chord-define-global "FF" 'find-file)
(key-chord-mode +1)


短時間のうちに key-chord-define-global で指定した文字列を入力しなければ、
command が呼び出されずに、ただの文字入力として扱われる。

key-chord が反応する時間は key-chord.el で以下のように定義されている。

(defvar key-chord-two-keys-delay 0.1	; 0.05 or 0.1
  "Max time delay between two key press to be considered a key chord.")

(defvar key-chord-one-key-delay 0.2	; 0.2 or 0.3 to avoid first autorepeat
  "Max time delay between two press of the same key to be considered a key chord.
This should normally be a little longer than `key-chord-two-keys-delay'.")


また、

Switch to previous buffer - Emacs Redux
http://emacsredux.com/blog/2013/04/28/switch-to-previous-buffer/

の switch-to-previous-buffer を登録しておくと便利かもしれない。

(defun switch-to-previous-buffer ()
  "Switch to previously open buffer.
Repeated invocations toggle between the two most recently open buffers."
  (interactive)
  (switch-to-buffer (other-buffer (current-buffer) 1)))

(key-chord-define-global "JJ" 'switch-to-previous-buffer)