;; -*- emacs-lisp -*- ;; KEY BINDINGS ;; ------------ ;; Weird, but it's very hard to find decent documentation about key ;; bindings. Even the emacs manual is not very clear about it. ;; http://www.gnu.org/software/emacs/manual/html_node/Key-Bindings.html#Key-Bindings ;; (later) Actually, reading the docs helps :) ;; One of the confusing things is the string/vector thingy described ;; A key sequence which contains function key symbols (or anything but ;; ASCII characters) must be a vector rather than a string. ;; http://www.gnu.org/software/emacs/manual/html_node/Function-Keys.html#Function-Keys ;; You can use the modifier keys , , , , ;; and with function keys. To represent these modifiers, add the ;; strings †¡C-†¢, †¡M-†¢, †¡H-†¢, †¡s-†¢, †¡A-†¢ and †¡S-†¢ at the front of the ;; symbol name. ;; Another thing. I use EvilWM. I just modified it to use the windows key ;; for WM commands, and leave all the other keys alone. This is much ;; easier to work with emacs. ;; MOUSE (defun up-slightly () (interactive) (scroll-up 5)) (defun down-slightly () (interactive) (scroll-down 5)) (global-set-key [mouse-4] 'down-slightly) (global-set-key [mouse-5] 'up-slightly) (defun up-one () (interactive) (scroll-up 1)) (defun down-one () (interactive) (scroll-down 1)) (global-set-key [S-mouse-4] 'down-one) (global-set-key [S-mouse-5] 'up-one) (defun up-a-lot () (interactive) (scroll-up)) (defun down-a-lot () (interactive) (scroll-down)) (global-set-key [C-mouse-4] 'down-a-lot) (global-set-key [C-mouse-5] 'up-a-lot) ;; KEYBOARD (defun set-keys (key-setter map) (mapc (lambda (x) (funcall key-setter (car x) (cadr x))) map)) (defun my-function-keys (setter) (set-keys setter '(([f2] ibuffer) ; ([f3] end-kbd-macro) ; ([f4] call-last-kbd-macro) ([f5] recompile) ([f6] snot-send-again) ; ([f7] query-replace-regexp) ; ([f8] query-replace) ;;([f9] swap-windows) ;;([f10] other-window) ;;([f11] kill-current-buffer) ;;([f12] kill-other-buffer) ))) (my-function-keys 'global-set-key) ;; (defun my-control-keys (setter) ;; (set-keys ;; setter ;; '(([delete] delete-char) ;; ;; ill add the default bindings in comments, to see what im missing ;; ;; out on. theres a good reason, usually, for the ctrl/alt key ;; ;; bindings. i dont use them very often. ;; ;; dont need (yet) ;; ;; * comment-indent-new-line ;; ;; * kill-sentence ;; ;; * universal argument ;; ;; * downcase-word ;; ;; * upcase-word ;; ;; do need: ;; ;; * comment-dwim ;; ;; try to make ctrl keys editing keys, and alt keys navigation keys ;; ;; the idea is to map ALT->navigation and CTRL->editing ;; ;;; CTRL ;; ([C-prior] scroll-down) ;; ([C-next] scroll-up) ;; ([C-delete] kill-word) ;; ([C-backspace] backward-kill-word) ;; ("\C-b" backward-delete-char) ;; next-line ;; ("\C-n" backward-kill-word) ;; backward-char ;; ("\C-u" undo) ;; universal-argument ;; ;;("\C-o" do-nothing) ;; open-line ;; ("\C-p" do-nothing) ;; previous-line ;; ("\C-j" comment-indent-new-line);; newline-and-indent ;; ("\C-l" dtach-restore) ;; recenter ;; ("\C-f" ibuffer) ;; forward-char ;; ("\C-e" comment-dwim) ;; end-of-line ;; ("\C-z" ibuffer) ;; iconify-or-deiconify-frame ;; ("\C-a" fill-paragraph) ;; beginning-of-line ;; ("\C-xp" pp-last-sexp) ;; beginning-of-line ;; ("\C-_" universal-argument) ;; undo ;; ([C-tab] dabbrev-completion) ;; ;; these are undefined so i can unlearn them ;; ("\C-xb" switch-to-buffer) ;; ("\C-xo" do-nothing)))) ;; (my-control-keys 'global-set-key) (defun global-set-key-escape (x y) (define-key esc-map x y)) (defun my-M-F-keys (setter) (set-keys setter '( ([M-f1] scratch) ([M-f2] default-shell) ([M-f3] snot) ([M-f4] metaocaml) ([M-f5] compile) ([M-f6] gdb) ([M-f10] vm) ;; different key since this messes up buffers. ([M-f11] winner-undo) ([M-f12] winner-redo) ))) (defun metaocaml () (interactive) (tuareg-run-process-if-needed "metaocaml") (tuareg-run-caml)) (my-M-F-keys 'global-set-key) ;; (defun my-navigation-keys (setter) ;; (set-keys ;; setter ;; '( ;; ;; top row: line/word navigation ;; ("\M-u" beginning-of-buffer) ;; ("\M-p" end-of-buffer) ;; ("\M-i" scroll-down) ;; ("\M-o" scroll-up) ;; ;; middle row: character navigation ;; ("\M-j" backward-word) ;; ("\M-;" forward-word) ;; ("\M-k" previous-line) ;; ("\M-l" next-line) ;; ;; bottom row page navigation ;; ("\M-," backward-char) ;; ("\M-." forward-char) ;; ("\M-m" beginning-of-line) ;; ("\M-/" end-of-line)))) ;; (my-navigation-keys 'global-set-key) (defun my-escape-keys (setter) (set-keys setter '( ([f1] scratch) ([f2] shell) ([f3] run-scheme) ([f4] scheme-scratch) ([f5] compile) ([f6] gdb) ([f9] pf) ([f10] snot) ;; ;; top row: line/word navigation ;; ("u" beginning-of-buffer) ;; ("p" end-of-buffer) ;; ("i" scroll-down) ;; ("o" scroll-up) ;; ;; middle row: character navigation ;; ("j" backward-word) ;; (";" forward-word) ;; ("k" previous-line) ;; ("l" next-line) ;; ;; bottom row page navigation ;; ("," backward-char) ;; ("." forward-char) ;; ("m" beginning-of-line) ;; ("/" end-of-line) ;; ([backspace] backward-kill-sentence) ;; ([delete] kill-sentence) ;; (" " other-window) ;; previous-line ;; ([return] swap-windows) ;; previous-line ;; find in tags file ;; ("f" find-tag) ))) (my-escape-keys 'global-set-key-escape) ;; same as up/dn to fix stupid laptop key arrangement ;; (defun do-nothing () (interactive)) ;; (defun keys-disabled () (interactive) ;; (mapc (lambda (x) (global-set-key x 'do-nothing)) ;; '([backspace] ;; [up] ;; [down] ;; [left] ;; [right] ;; [next] ;; [prior] ;; [home] ;; [end]))) ;; (defun CURSOR-keys () ;; (global-set-key [up] 'do-nothing) ;; (global-set-key [down] 'do-nothing) ;; (global-set-key [left] 'do-nothing) ;; (global-set-key [right] 'do-nothing) ;; (global-set-key [prior] 'do-nothing) ;; (global-set-key [next] 'do-nothing) ;; (global-set-key [home] 'do-nothing) ;; (global-set-key [end] 'do-nothing) ;; ) ;; ; (CURSOR-keys) ;; (defun ACER-keys () ;; (global-set-key [prior] 'previous-line) ;; (global-set-key [next] 'next-line)) ;; ;(keys-disabled) ;; Some handy global keys on the ACER keyboard. (global-set-key (kbd "") 'gud-next) (global-set-key (kbd "") 'gud-finish) (global-set-key (kbd "") 'gud-cont) (global-set-key (kbd "") 'gud-step) (global-set-key (kbd "") 'gud-break)