;;; To prevent double keying, I bind useful functions to one key. ;;; The progression is: ;;; X keycode --> X keysym --> Emacs-keymapstring --> Emacs-function ;;; this progression is a bit of a mess. some mappings are hardwired ;;; in emacs. and emacs also doesn't recognize some chars that X does. ;;; To find out X mappings, use % xev for keycode and keysym ;;; For emacs mappings, use the show-chars function at end of this file. ;; Hint -- get function names via M-x describe-key ;; Not used cause DEC kbd has them automatically?? ;; 'backward-char = Leftarrow ;; 'forward-char = Rightarrow ;; 'scroll-up-in-place = Downarrow ;; 'scroll-down-in-place = Uparrow ;; Not used 'cause i never tried them: ;; 'repeat-complex-command ;; define-x-... assumes standard keysyms (if (eq window-system 'x) (progn ; (require 'x-mouse) ; already loaded in x-init (load "x-fn-keys") (define-x-fn-key "Find" 'execute-extended-command) ;M-x prefix (define-x-fn-key "Select" 'c-x-command) ;C-x prefix (define-x-fn-key "Insert" 'kill-line) ;C-x prefix ;; (define-x-fn-key "Prior" 'scroll-up) ;;; these only work once so fuck it ;; (define-x-fn-key "F1" 'isearch-forward) ;c-s ;; (define-x-fn-key "F2" 'isearch-backward) ;c-r (define-x-fn-key "F1" 'delete-char) ;c-d (define-x-fn-key "F2" 'kill-word) ;m-d (define-x-fn-key "F3" 'start-kbd-macro) ;c-x( (define-x-fn-key "F4" 'end-kbd-macro) ;c-x) (define-x-fn-key "F5" 'call-last-kbd-macro) ;C-x e (define-x-fn-key "F6" 'yank) ; C-y (define-x-fn-key "F7" 'cmpl-beginning-of-line) ;C-x a (define-x-fn-key "F8" 'cmpl-end-of-line) ;C-x e (define-x-fn-key "F9" 'eval-defun) ;ESC C-x (define-x-fn-key "F10" 'goto-line) ;C-x 2 ;; (define-x-fn-key "F10" 'split-window-vertically) ;C-x 2 ;;; write a function to make fill paragraph mode-sensitive ie so in ;;; lisp mode, we would get 'lisp-fill-paragraph ;; (define-x-fn-key "F11" 'fill-paragraph) ; M-q (define-x-fn-key "F12" 'beginning-of-buffer) ;Home (define-x-fn-key "F13" 'capitalize-word) ;M-c (define-x-fn-key "F14" 'complete) ;used to be keyboard-quit, i.e. Stop (define-x-fn-key "Menu" 'save-buffer) ;C-x C-s ;; HELP key is reserved to show the key mappings (define-x-fn-key "F17" 'scroll-down-in-place) ; c-v (define-x-fn-key "F18" 'scroll-up-in-place) ;M-v (define-x-fn-key "F19" 'end-of-buffer) ;End (define-x-fn-key "F20" 'downcase-word) ;m-l )) ;; M-x = 'execute extended command ;;; Print out chars typed - useful for finding out what sequences are ;;; generated by mouse, or fn keys in emacs. ;;; Randal L. Schwartz (defun show-chars () "Displays characters typed, terminated by a 3-second timeout." (interactive) (let ((chars "") (inhibit-quit t)) (message "Enter characters, terminated by 3-second timeout.") (while (not (sit-for 3)) (setq chars (concat chars (list (read-char))) quit-flag nil)) ; quit-flag maybe set by C-g (message "Characters entered: %s" (key-description chars)))) ;;; ------------- Eero Simoncelli ---------------------- ;; to bind C-x to a key (defun c-x-command () (interactive) (let ((char ?\C-x) string) (setq unread-command-char char) (setq last-command-char char) (setq last-input-char char) (setq string (read-key-sequence nil)) (call-interactively (key-binding string)))) (defun c-c-command () (interactive) (let ((char ?\C-c) string) (setq unread-command-char char) (setq last-command-char char) (setq last-input-char char) (setq string (read-key-sequence nil)) (call-interactively (key-binding string)))) (defun scroll-down-in-place (n) (interactive "p") (scroll-down n) (previous-line n)) (defun scroll-up-in-place (n) (interactive "p") (scroll-up n) (next-line n))