emacsmode_controlPNBF を戻す advice
KeyRemap4MacBook 本体に Carbon Emacs 対応が入ったため、以下の ad-hoc なコードは不要になりました :) FYI: KeyRemap4MacBook
keyremap4macbook.option.emacsmode_controlPNBF が有効な時にだけ define-key を乗っ取り、C-pnbf を要求する keybind を C-[(up)][(down)][(left)][(right)] への要求へとすり替えます(読み辛い日本語ですね)。
渡された key が vector の時と string の時で分岐していますが、実際の処理内容はほぼ同一です。ここも纏められそうなので次の休日にでも……。
locate-executable については d:id:elim:20080126:locate_executable をご参照下さい。
コメントを下さった id:tekezo さんありがとうございました。
標準添付の executable-find が全く同じ機能でした。 *1
(when (let ((exec "sysctl") (arg "keyremap4macbook.option.emacsmode_controlPNBF")) (and (locate-executable exec) (string-equal "1" (with-temp-buffer (call-process exec nil t nil arg) (goto-char (point-min)) (if (re-search-forward "\\(.\\)$" nil t) (match-string 0)))))) (and (global-set-key [(control x) (right)] #'find-file) (defadvice define-key (around keyreremap (keymap key def) activate) (setq key (cond ((vectorp key) (apply 'vector (mapcar #'(lambda (k) (cond ((equal "\C-p" k) '(up)) ((equal "\C-n" k) '(down)) ((equal "\C-b" k) '(left)) ((equal "\C-f" k) '(right)) (t k))) key))) ((stringp key) (cond ((equal "\C-p" key) [(up)]) ((equal "\C-n" key) [(down)]) ((equal "\C-b" key) [(left)]) ((equal "\C-f" key) [(right)]) (t key))) (t key))) ad-do-it)))